Re:dd built-in progress introduced in coreutils 8.24
by Luyt on Sunday January 10, 2016 @09:29PM
(#10878408)
I find this style of formatting specifiers an eyesore:
[ Parent
| on HN ]
Re:dd built-in progress introduced in coreutils 8.24
by LukeShu on Sunday January 10, 2016 @09:57PM
(#10878496)
I assume you mean the `%"PRIuMAX"` bits. It is an eyesore, but it is how to portably write the specifiers for types whose size my vary across architectures. That is, blame POSIX, not GNU coding style.
Re:dd built-in progress introduced in coreutils 8.24
by _kst_ on Sunday January 10, 2016 @10:16PM
(#10878563)
The `PRIuMAX` et al macros are specified by ISO C (starting with the 1999 standard), not (just) by POSIX.
Re:dd built-in progress introduced in coreutils 8.24
by LukeShu on Sunday January 10, 2016 @11:02PM
(#10878709)
That makes sense; the most recent editions of POSIX "import" ISO C '99. I had a copy of POSIX handy to check it, but not ISO C :)
Re:dd built-in progress introduced in coreutils 8.24
by __david__ on Sunday January 10, 2016 @09:58PM
(#10878502)
Yeah, it's ugly, but it's sadly the only way to correctly do cross platform prints where the type may or may not be 64 bit.
Re:dd built-in progress introduced in coreutils 8.24
by _kst_ on Sunday January 10, 2016 @10:20PM
(#10878576)
The `PRIuMAX` macro in particular is not necessary. It expands to a format usable for `uintmax_t`, but you can also use `"%ju"`. Both were introduced in ISO C99.
(Unless your `printf` implementation doesn't recognize `"%ju"`, and the `PRIuMAX` macro and friends are defined in some non-standard system-specific manner.)
Re:dd built-in progress introduced in coreutils 8.24
by e12e on Monday January 11, 2016 @12:14AM
(#10878955)
Related, the recently posted "How to write C in 2016":
Re:dd built-in progress introduced in coreutils 8.24
by garethrees on Monday January 11, 2016 @06:24AM
(#10880179)
How is this supposed to work? The underscore is a convenience macro for the gettext localization function. But gettext works by looking up its string argument in the localization database, and here the string varies from one platform to another, so how can you be sure that the localization will be found?
I guess the answer is that you have to redo the localization for each platform that has a different expansion of PRIuMAX. But that's horrible: the localization will be identical except for the format specifiers, which will just be copied from the English version of the string. Is there support for automating this in the translation toolchain?
Re:dd built-in progress introduced in coreutils 8.24
by arantius on Monday January 11, 2016 @12:51PM
(#10881903)
What is the behavior of gettext() if the message is not found?
(This question is the answer to your question.)
Re:dd built-in progress introduced in coreutils 8.24
by garethrees on Wednesday January 13, 2016 @05:09PM
(#10897972)
If the message is not found, gettext returns the argument unchanged, which would be a bug (English text incorrectly appearing instead of localized text). So that's not it.
The answer to my question is that xgettext and gettext have special handling for PRIuMAX and the other formatting macros in inttypes.h. http://www.gnu.org/software/gettext/manual/gettext.html#Prep...