no vasnprintf.h, either; argz_.h from libtool
[gnulib.git] / lib / snprintf.c
index 92c2652..667ed94 100644 (file)
 # include <config.h>
 #endif
 
-/* Specification.  */
 #include "snprintf.h"
 
-/* Get va_list, va_start, va_end. */
 #include <stdarg.h>
-/* Get free. */
 #include <stdlib.h>
-/* Get memcpy, size_t. */
 #include <string.h>
 
-/* Get vasnprintf.  */
-#include "vasnprintf.h"
-
-/* Get MIN. */
 #include "minmax.h"
+#include "vasnprintf.h"
 
 /* Print formatted output to string STR.  Similar to sprintf, but
    additional length SIZE limit how much is written into STR.  Returns
@@ -55,7 +48,7 @@ snprintf (char *str, size_t size, const char *format, ...)
   if (!output)
     return -1;
 
-  if (str)
+  if (str && size > 0)
     {
       memcpy (str, output, MIN (len + 1, size));
       str[size - 1] = '\0';