"Ronald S. Bultje" <rsbul...@gmail.com> writes: > Hi, > > On Wed, Aug 1, 2012 at 11:58 AM, Måns Rullgård <m...@mansr.com> wrote: >> Luca Barbato <lu_z...@gentoo.org> writes: >> >>> +#if !HAVE_SNPRINTF >>> +#ifdef _MSC_VER >>> +#define vsnprintf _vsnprintf >>> +#endif >>> + >>> +int snprintf(char *buffer, size_t bufsize, const char *fmt, ...) >>> +{ >>> + va_list ap; >>> + int ret; >>> + >>> + if ((int)bufsize <= 0) return -1; >>> + va_start(ap, fmt); >>> + ret = vsnprintf(buffer, bufsize-1, fmt, ap); >>> + if (ret < 0) { >>> + buffer[bufsize - 1] = '\0'; >>> + ret = bufsize - 1; >>> + } >>> + va_end(ap); >>> + return ret; >>> +} >> >> This assumes that any system without snprintf will have vsnprintf with >> microsoft semantics. That's a pretty bold assumption. > > Well, it is harmless in the sense that non-MS vsnprintf() never > returns <0, right? But we can put this under #ifdef _MSC_VER if you > prefer that.
I forgot to say, system/compiler-specific #ifdefs should only be used in the most exceptional of circumstances. This does not qualify by a long shot. -- Måns Rullgård m...@mansr.com _______________________________________________ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel