Guard against vsnprintf implementations that mishandle a size=0 argument.
[gnulib.git] / m4 / snprintf-posix.m4
index 890605d..9e9ef1d 100644 (file)
@@ -1,4 +1,4 @@
-# snprintf-posix.m4 serial 3
+# snprintf-posix.m4 serial 4
 dnl Copyright (C) 2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -18,6 +18,7 @@ AC_DEFUN([gl_FUNC_SNPRINTF_POSIX],
     gl_SNPRINTF_TRUNCATION_C99
     gl_SNPRINTF_RETVAL_C99
     gl_SNPRINTF_DIRECTIVE_N
+    gl_VSNPRINTF_ZEROSIZE_C99
     case "$gl_cv_func_printf_sizes_c99" in
       *yes)
         case "$gl_cv_func_printf_directive_a" in
@@ -34,9 +35,13 @@ AC_DEFUN([gl_FUNC_SNPRINTF_POSIX],
                               *yes)
                                 case "$gl_cv_func_snprintf_directive_n" in
                                   *yes)
-                                    # snprintf exists and is already POSIX
-                                    # compliant.
-                                    gl_cv_func_snprintf_posix=yes
+                                    case "$gl_cv_func_vsnprintf_zerosize_c99" in
+                                      *yes)
+                                        # snprintf exists and is already POSIX
+                                        # compliant.
+                                        gl_cv_func_snprintf_posix=yes
+                                        ;;
+                                    esac
                                     ;;
                                 esac
                                 ;;