Created attachment 6500 [details]
Some nested #if changes.
I was synchronizing the rsync snprintf.c code with samba's version (since I had noticed the lack of some va_end() calls in rsync's version), and I discovered that there are some #ifdef nesting issues in the code.
Note that this code (at line 144) leaves a dangling "#ifndef VA_COPY" open:
#define VA_COPY(dest, src) va_copy(dest, src)
#define VA_COPY(dest, src) __va_copy(dest, src)
#define VA_COPY(dest, src) (dest) = (src)
That section remains open all the way down to line 1194 (after the short vsnprintf() function. This code is inside the "#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF)" section, which would seem to be the ifdef that should actually be matching up with it. There are three more conditionally-defined functions that follow until an extra #endif on line 1257 finally closes the !HAVE_VSNPRINTF section (snprintf, printf, and fprintf).
So, it's very strange that vsnprintf() won't get defined if VA_COPY is already defined. To fix this, I moved the #endif from line 1257 up to the VA_COPY section. However, an alternate fix might be to move the #endif from line 1194 (depending on when you really want snprintf, printf, and fprintf to be defined).
Another issue that turned up:
Right after line 1257 is the vasprintf function, which makes use of the VA_COPY define. However, on an OS that has is own vsnprintf but does not have vasprintf, the VA_COPY define won't be there (since it was nested inside the vsnprintf section), causing a link error (e.g. Solaris 10 hits this bug).
To fix this latter issue, I moved the start of the vsnprintf #if past the VA_COPY setup.
I haven't tried to compile this in samba, just in rsync (which uses a slightly different file than samba, but is mostly the same).
Well, if you guys don't care about this, I certainly don't. Closing.