Hi Paul, Eric Blake wrote: > one _very_ common use of snprintf is to call it with size 0 to see > how much to allocate, then allocate and call again.
Among all the portability problems fixed by snprintf-posix, the return value for size 0 buffer makes the most sense to me to promote to plain snprintf. Paul Eggert wrote: > GNU code shouldn't have arbitrary limits like that. > ... > I checked today, and coreutils proper uses snprintf in three places: > once with (NULL, 0, ...), and twice with a fixed buffer as in the > above example. The latter two uses are buggy. OK, if you agree that a correct return value from snprintf() should be part of the 'snprintf' module, I won't further object. But I would find it good if - you would modify m4/vsnprintf.m4 like m4/snprintf.m4 - otherwise the gnulib modules 'vsnprintf' and 'snprintf' are inconsistent. - the files doc/posix-functions/{snprintf,vsnprintf}.texi were be updated to match the code. - the test suite would be updated accordingly, i.e. the tests for the correct return value were moved from tests/test-snprintf-posix.h to tests/test-snprintf.c and tests/test-vsnprintf.c. Bruno