On 02/12/2012 05:27 PM, Eli Zaretskii wrote: >> Date: Sun, 12 Feb 2012 05:07:48 +0100 >> From: Sebastian Pipping <sebast...@pipping.org> >> CC: psm...@gnu.org, bug-make@gnu.org >> >> So far both of these have been requirements: (1) keep the overall format >> translatable so other languages can adjust order of elements and (2) use >> C89 functions, only. It seems that (1) requires function vsnprintf >> which violates (2). > > Why does (1) violate (2)? (1) will only be possible with C libraries > that support the n$ positional specifiers. AFAIK, when these are > supported, they can be used with any of the *printf functions.
The problem is nesting. If we have _("%s[%u]: %s%s%s%s") ^^ for the final output, the actual message (third %s above) needs to be present in linear string form already. With constant messages that's given, but we are dealing with _("%s: Entering directory `%s'\n") too. So that inner format needs to be written to a string buffer first or we lose the gained abstraction. Since we would run into buffer overflows with sprintf/vsprintf, we rely on snprintf/vsnprintf for that task. Quoting from my "man 3 printf" output: snprintf(), vsnprintf(): _BSD_SOURCE || _XOPEN_SOURCE >= 500 || _ISOC99_SOURCE \ || _POSIX_C_SOURCE >= 200112L; or cc -std=c99 That's my understanding of the situation. Best, Sebastian _______________________________________________ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make