Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[makefilename] help file - wrong description of %p pattern #737

Open
mariobuoninfante opened this issue Sep 2, 2019 · 15 comments
Labels

Comments

@mariobuoninfante
Copy link

@mariobuoninfante mariobuoninfante commented Sep 2, 2019

Ubuntu Studio 19.04 - Pd 0.50

[makefilename %p] returns '(nil)' when receives a 0.
It works fine on MacOS High Sierra 10.13.1

pd_linux_makefilename_bug_%p

@Spacechild1

This comment has been minimized.

Copy link
Contributor

@Spacechild1 Spacechild1 commented Sep 2, 2019

"%p" is for C pointers and the actual format can vary across platforms. What are you trying to do?

@umlaeute

This comment has been minimized.

Copy link
Contributor

@umlaeute umlaeute commented Sep 2, 2019

what did you expect?

@mariobuoninfante

This comment has been minimized.

Copy link
Author

@mariobuoninfante mariobuoninfante commented Sep 2, 2019

maybe I'm missing something obvious, but I'd expect '0x0' to be printed. at least according to the [makefilename] help file
makefilename_help

@mariobuoninfante

This comment has been minimized.

Copy link
Author

@mariobuoninfante mariobuoninfante commented Sep 2, 2019

also because with numbers bigger than 0, that is what I get

makefilename_issue

@Spacechild1

This comment has been minimized.

Copy link
Contributor

@Spacechild1 Spacechild1 commented Sep 2, 2019

OK, this is a bug in the help file. %p is for printing memory addresses and there is no standardized format. "unsigned hexadecimal with preceded by '0x'" is just one possible way. With MinGW, [1( -> [makefilename %p] gives me 00000001

@Spacechild1

This comment has been minimized.

Copy link
Contributor

@Spacechild1 Spacechild1 commented Sep 2, 2019

0 is the NULL pointer, and your system decides to print it as (nil).

@mariobuoninfante

This comment has been minimized.

Copy link
Author

@mariobuoninfante mariobuoninfante commented Sep 2, 2019

understood. It does make sense, also because it was 'working' on MacOS, and I found it quite weird.
that said, I think it would be useful if we could have a way of printing hex preceded by '0x'.

@mariobuoninfante

This comment has been minimized.

Copy link
Author

@mariobuoninfante mariobuoninfante commented Sep 2, 2019

PS I know that all you need to do is to have 2 makefilename in cascade to obtain that
[makefilename %X]
|
|
[makefilename 0x%s]

but still since the object is meant to be use for formatting purposes, I think having that by default without need to use a 'workaround' would be great

@Spacechild1

This comment has been minimized.

Copy link
Contributor

@Spacechild1 Spacechild1 commented Sep 2, 2019

[makefilename] is modelled after printf, and there you would also have to do printf("0x%x", mynumber);

@Spacechild1

This comment has been minimized.

Copy link
Contributor

@Spacechild1 Spacechild1 commented Sep 2, 2019

there's no need to cascade, just do [makefilename 0x%x]

@mariobuoninfante

This comment has been minimized.

Copy link
Author

@mariobuoninfante mariobuoninfante commented Sep 2, 2019

@Spacechild1 of course it is, I don't really know what I was thinking when I wrote that :(
so focused on the %p thing.
Anyway thanks for looking into it. I suppose like you said the bug is just in the help file.

@Spacechild1

This comment has been minimized.

Copy link
Contributor

@Spacechild1 Spacechild1 commented Sep 2, 2019

no problem. can you change the description or open a new issue?

@mariobuoninfante mariobuoninfante changed the title [makefilename %p] returns (nil) when receiving 0 on Linux [makefilename] help file - wrong description of %p pattern Sep 2, 2019
@porres

This comment has been minimized.

Copy link
Contributor

@porres porres commented Sep 3, 2019

I have a revision of the documentation here: 831d93e

and discuss issues here: #549

so if you think there's something else to discuss about the documentation...

@mariobuoninfante

This comment has been minimized.

Copy link
Author

@mariobuoninfante mariobuoninfante commented Sep 3, 2019

@porres what should I do? you already referred this issue in #549 .
is it worth having this one open? should I write a brief summary in there?

@porres

This comment has been minimized.

Copy link
Contributor

@porres porres commented Sep 12, 2019

should I write a brief summary in there?

seems like a good idea. Close this one and let's move the discussion there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.