Hi Eric.

On Tue, 29 Sep 2009, Eric Blake wrote:

> For this to work on all platforms, you need the gnulib module fprintf-posix 
> (sadly, %zu is not completely portable yet).

Thanks for pointing that out.

While we're on the topic and I already have two experts watching this 
thread, is snprintf-posix helpful in order to use the following portably?

  length = snprintf (NULL, 0, format, args);
  str = malloc (length + 1);
  snprintf (str, length + 1, format, args);

The snprintf man page warns of portability problems here, but 
snprintf-posix only appears to test vsnprintf's functionality for this 
purpose by invoking gl_VSNPRINTF_ZEROSIZE_C99.  Is it just assumed 
snprintf and vsnprintf will be consistent in this respect?

Also, is there any single module that ensures portability of all *printf 
functions, or should I include every *printf-posix module individually in 
order to ensure consistent behavior?

If I should add bug-gnulib, let me know.


Reply via email to