diff options
author | Simon Josefsson <simon@josefsson.org> | 2004-10-12 13:26:28 +0000 |
---|---|---|
committer | Simon Josefsson <simon@josefsson.org> | 2004-10-12 13:26:28 +0000 |
commit | 945c7da4f6af976e4317c616b31118871d8f3709 (patch) | |
tree | 6a7e811df445081b3ec79506e9499dcf760a6d5d /gl | |
parent | 0888b47113aaffbc5955e66c5363affa930fca35 (diff) | |
download | gnutls-945c7da4f6af976e4317c616b31118871d8f3709.tar.gz |
Update gnulib.
Diffstat (limited to 'gl')
-rw-r--r-- | gl/getpass.c | 11 | ||||
-rw-r--r-- | gl/snprintf.c | 12 | ||||
-rw-r--r-- | gl/snprintf.h | 2 |
3 files changed, 18 insertions, 7 deletions
diff --git a/gl/getpass.c b/gl/getpass.c index bc8eb4498d..78f21e0197 100644 --- a/gl/getpass.c +++ b/gl/getpass.c @@ -57,6 +57,17 @@ # define funlockfile(s) _IO_funlockfile (s) #elif USE_UNLOCKED_IO # include "unlocked-io.h" +#else +# undef fflush_unlocked +# define fflush_unlocked(x) fflush (x) +# undef flockfile +# define flockfile(x) ((void) 0) +# undef funlockfile +# define funlockfile(x) ((void) 0) +# undef fputs_unlocked +# define fputs_unlocked(str,stream) fputs (str, stream) +# undef putc_unlocked +# define putc_unlocked(c,stream) putc (c, stream) #endif #if _LIBC diff --git a/gl/snprintf.c b/gl/snprintf.c index 667ed94625..9a4edc1f5f 100644 --- a/gl/snprintf.c +++ b/gl/snprintf.c @@ -42,19 +42,19 @@ snprintf (char *str, size_t size, const char *format, ...) va_list args; va_start (args, format); - output = vasnprintf (NULL, &len, format, args); + len = size; + output = vasnprintf (str, &len, format, args); va_end (args); if (!output) return -1; - if (str && size > 0) - { - memcpy (str, output, MIN (len + 1, size)); + if (str != NULL) + if (len > size - 1) /* equivalent to: (size > 0 && len >= size) */ str[size - 1] = '\0'; - } - free (output); + if (output != str) + free (output); return len; } diff --git a/gl/snprintf.h b/gl/snprintf.h index 18628f66d8..a72f74d639 100644 --- a/gl/snprintf.h +++ b/gl/snprintf.h @@ -23,7 +23,7 @@ #include <stdio.h> #if defined HAVE_DECL_SNPRINTF && !HAVE_DECL_SNPRINTF -int snprintf(char *str, size_t size, const char *format, ...); +int snprintf (char *str, size_t size, const char *format, ...); #endif #endif /* SNPRINTF_H */ |