Hi,
The following:
[makefilename %.7s]
will truncate a symbol to 7 chars; obviously you may replace 7 with any positive integer.
BUT
[makefilename %.0s]
when it receive a symbol, won't output anything. Shouldn't it output an empty (or null, whatever it is called) symbol?
What does printf do? It probably should mimic that behavior.
.hc
On Dec 9, 2009, at 8:36 AM, Matteo Sisti Sette wrote:
Hi,
The following:
[makefilename %.7s]
will truncate a symbol to 7 chars; obviously you may replace 7 with
any positive integer.BUT
[makefilename %.0s]
when it receive a symbol, won't output anything. Shouldn't it output an empty (or null, whatever it is called) symbol?
-- Matteo Sisti Sette matteosistisette@gmail.com http://www.matteosistisette.com
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Using ReBirth is like trying to play an 808 with a long stick. - David Zicarelli
Hans-Christoph Steiner escribió:
What does printf do? It probably should mimic that behavior.
I think it should mimic sprintf's behaviour to be precise. I don't know what it is but I dubt it can leave the string (a pointer to which is passed as parameter) unmodified.
The funny thing is the documentation (if this http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/ is a reliable reference) is not very explicit about that. It says the function can "fail" (which is the only case in which it would be acceptable "not to output anything"), but does not specify when:
"Return Value On success, the total number of characters written is returned. This count does not include the additional null-character automatically appended at the end of the string. On failure, a negative number is returned."
There are a few "should be" in the description. If we take those "should be" as the conditions that determine success or failure, a 0 precision is not a failure condition, so according to the definition it should just output a 0-length string.
On Dec 9, 2009, at 12:41 PM, Matteo Sisti Sette wrote:
Hans-Christoph Steiner escribió:
What does printf do? It probably should mimic that behavior.
I think it should mimic sprintf's behaviour to be precise. I don't know what it is but I dubt it can leave the string (a
pointer to which is passed as parameter) unmodified.The funny thing is the documentation (if this http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/ is a reliable reference) is not very explicit about that. It says the function can "fail" (which is the only case in which it
would be acceptable "not to output anything"), but does not specify
when:"Return Value On success, the total number of characters written is returned. This
count does not include the additional null-character automatically
appended at the end of the string. On failure, a negative number is returned."There are a few "should be" in the description. If we take those
"should be" as the conditions that determine success or failure, a 0
precision is not a failure condition, so according to the definition
it should just output a 0-length string.
Just write a tiny C program to test what sprintf() actually does.
.hc
You can't steal a gift. Bird gave the world his music, and if you can
hear it, you can have it. - Dizzy Gillespie
afaik, matteo is right:
sprintf(&s, "%.0s", "whatever")
outputs a null-length string to &s; i.e. afterwards
strcmp(s,{'\0'})==0
marmosets, Bryan
On 2009-12-11 06:13:20, Hans-Christoph Steiner hans@at.or.at appears to have written:
On Dec 9, 2009, at 12:41 PM, Matteo Sisti Sette wrote:
Hans-Christoph Steiner escribió:
What does printf do? It probably should mimic that behavior.
I think it should mimic sprintf's behaviour to be precise.
...
according to the definition it should just output a 0-length string.
Just write a tiny C program to test what sprintf() actually does.