Luca Barbato <[email protected]> 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.

> +#define snprintf(...) ff_snprintf(__VA_ARGS__)
> +#endif

[...]

> diff --git a/libavutil/os_support.h b/libavutil/os_support.h
> new file mode 100644
> index 0000000..efecfe6
> --- /dev/null
> +++ b/libavutil/os_support.h

[...]

> +#if !HAVE_SNPRINTF
> +int ff_snprintf(char *buffer, size_t bufsize, const char *fmt, ...);
> +#define snprintf(...) ff_snprintf(__VA_ARGS__)
> +#endif

WTF?

-- 
Måns Rullgård
[email protected]
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to