bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-gnulib] Re: snprintf


From: Simon Josefsson
Subject: [Bug-gnulib] Re: snprintf
Date: Fri, 01 Oct 2004 01:53:39 +0200
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux)

Paul Eggert <address@hidden> writes:

> I installed your patch, except with this change to MODULES.html.sh instead,
> since snprintf is indeed part of C99.

And with the patch below it might even compile... Sorry about that.

Thanks.

PS. These '/* Get X. */' comments feel a bit overworked...

Index: snprintf.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/snprintf.c,v
retrieving revision 1.1
diff -u -p -u -w -r1.1 snprintf.c
--- snprintf.c  30 Sep 2004 23:29:25 -0000      1.1
+++ snprintf.c  30 Sep 2004 23:52:18 -0000
@@ -20,6 +20,15 @@
 # include <config.h>
 #endif
 
+/* Get va_list, va_start, va_end. */
+#include <stdarg.h>
+
+/* Get memcpy, size_t. */
+#include <string.h>
+
+/* Get free. */
+#include <stdlib.h>
+
 /* Get specification.  */
 #include "snprintf.h"
 
@@ -37,8 +46,13 @@
 int
 snprintf (char *str, size_t size, const char *format, ...)
 {
+  char *out;
   size_t len;
-  char *out = vasnprintf (NULL, &len, format, args);
+  va_list ap;
+
+  va_start(ap, format);
+  out = vasnprintf (NULL, &len, format, ap);
+  va_end(ap);
 
   if (!out)
     return -1;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]