From: Bruno Haible Date: Tue, 11 Jan 2005 13:00:09 +0000 (+0000) Subject: Update from gnulib. X-Git-Tag: v0.14.2~191 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4cfda02168a4017240ec53001671b83865f4fe5e;p=thirdparty%2Fgettext.git Update from gnulib. --- diff --git a/gettext-runtime/intl/ChangeLog b/gettext-runtime/intl/ChangeLog index ae5b24cfd..64c19b41e 100644 --- a/gettext-runtime/intl/ChangeLog +++ b/gettext-runtime/intl/ChangeLog @@ -1,3 +1,8 @@ +2004-09-08 Bruno Haible + + * vasnprintf.c (VASNPRINTF): Signal EOVERFLOW if the resulting length + is > INT_MAX. + 2005-01-01 Bruno Haible * dcigettext.c (guess_category_value): Let the environment variables diff --git a/gettext-runtime/intl/vasnprintf.c b/gettext-runtime/intl/vasnprintf.c index fc4a23039..8f2cc8484 100644 --- a/gettext-runtime/intl/vasnprintf.c +++ b/gettext-runtime/intl/vasnprintf.c @@ -41,7 +41,7 @@ #include /* abort(), malloc(), realloc(), free() */ #include /* memcpy(), strlen() */ #include /* errno */ -#include /* CHAR_BIT */ +#include /* CHAR_BIT, INT_MAX */ #include /* DBL_MAX_EXP, LDBL_MAX_EXP */ #if WIDE_CHAR_VERSION # include "wprintf-parse.h" @@ -863,8 +863,19 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar free (buf_malloced); CLEANUP (); *lengthp = length; + if (length > INT_MAX) + goto length_overflow; return result; + length_overflow: + /* We could produce such a big string, but its length doesn't fit into + an 'int'. POSIX says that snprintf() fails with errno = EOVERFLOW in + this case. */ + if (result != resultbuf) + free (result); + errno = EOVERFLOW; + return NULL; + out_of_memory: if (!(result == resultbuf || result == NULL)) free (result); diff --git a/gettext-runtime/intl/vasnprintf.h b/gettext-runtime/intl/vasnprintf.h index 65f1bc13d..84da20813 100644 --- a/gettext-runtime/intl/vasnprintf.h +++ b/gettext-runtime/intl/vasnprintf.h @@ -1,5 +1,5 @@ /* vsprintf with automatic memory allocation. - Copyright (C) 2002-2003 Free Software Foundation, Inc. + Copyright (C) 2002-2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published @@ -48,7 +48,24 @@ extern "C" { If successful, return the address of the string (this may be = RESULTBUF if no dynamic memory allocation was necessary) and set *LENGTHP to the number of resulting bytes, excluding the trailing NUL. Upon error, set - errno and return NULL. */ + errno and return NULL. + + When dynamic memory allocation occurs, the preallocated buffer is left + alone (with possibly modified contents). This makes it possible to use + a statically allocated or stack-allocated buffer, like this: + + char buf[100]; + size_t len = sizeof (buf); + char *output = vasnprintf (buf, &len, format, args); + if (output == NULL) + ... error handling ...; + else + { + ... use the output string ...; + if (output != buf) + free (output); + } + */ extern char * asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...) __attribute__ ((__format__ (__printf__, 3, 4))); extern char * vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args) diff --git a/gettext-runtime/libasprintf/ChangeLog b/gettext-runtime/libasprintf/ChangeLog index 7d39b6985..3a42ec101 100644 --- a/gettext-runtime/libasprintf/ChangeLog +++ b/gettext-runtime/libasprintf/ChangeLog @@ -2,6 +2,12 @@ * alloca_.h: Conditionalize on _GNULIB_ALLOCA_H, not _ALLOCA_H. +2004-09-08 Bruno Haible + + * vasnprintf.c (VASNPRINTF): Signal EOVERFLOW if the resulting length + is > INT_MAX. + * vasprintf.c (vasprintf): Don't test for length > INT_MAX any more. + 2004-05-14 Bruno Haible * vasnprintf.c (VASNPRINTF): Correctly handle the case of a precision diff --git a/gettext-runtime/libasprintf/vasnprintf.c b/gettext-runtime/libasprintf/vasnprintf.c index fc4a23039..8f2cc8484 100644 --- a/gettext-runtime/libasprintf/vasnprintf.c +++ b/gettext-runtime/libasprintf/vasnprintf.c @@ -41,7 +41,7 @@ #include /* abort(), malloc(), realloc(), free() */ #include /* memcpy(), strlen() */ #include /* errno */ -#include /* CHAR_BIT */ +#include /* CHAR_BIT, INT_MAX */ #include /* DBL_MAX_EXP, LDBL_MAX_EXP */ #if WIDE_CHAR_VERSION # include "wprintf-parse.h" @@ -863,8 +863,19 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar free (buf_malloced); CLEANUP (); *lengthp = length; + if (length > INT_MAX) + goto length_overflow; return result; + length_overflow: + /* We could produce such a big string, but its length doesn't fit into + an 'int'. POSIX says that snprintf() fails with errno = EOVERFLOW in + this case. */ + if (result != resultbuf) + free (result); + errno = EOVERFLOW; + return NULL; + out_of_memory: if (!(result == resultbuf || result == NULL)) free (result); diff --git a/gettext-runtime/libasprintf/vasnprintf.h b/gettext-runtime/libasprintf/vasnprintf.h index 65f1bc13d..84da20813 100644 --- a/gettext-runtime/libasprintf/vasnprintf.h +++ b/gettext-runtime/libasprintf/vasnprintf.h @@ -1,5 +1,5 @@ /* vsprintf with automatic memory allocation. - Copyright (C) 2002-2003 Free Software Foundation, Inc. + Copyright (C) 2002-2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published @@ -48,7 +48,24 @@ extern "C" { If successful, return the address of the string (this may be = RESULTBUF if no dynamic memory allocation was necessary) and set *LENGTHP to the number of resulting bytes, excluding the trailing NUL. Upon error, set - errno and return NULL. */ + errno and return NULL. + + When dynamic memory allocation occurs, the preallocated buffer is left + alone (with possibly modified contents). This makes it possible to use + a statically allocated or stack-allocated buffer, like this: + + char buf[100]; + size_t len = sizeof (buf); + char *output = vasnprintf (buf, &len, format, args); + if (output == NULL) + ... error handling ...; + else + { + ... use the output string ...; + if (output != buf) + free (output); + } + */ extern char * asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...) __attribute__ ((__format__ (__printf__, 3, 4))); extern char * vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args) diff --git a/gettext-runtime/libasprintf/vasprintf.c b/gettext-runtime/libasprintf/vasprintf.c index d20f8ca63..fb88f1928 100644 --- a/gettext-runtime/libasprintf/vasprintf.c +++ b/gettext-runtime/libasprintf/vasprintf.c @@ -23,7 +23,6 @@ /* Specification. */ #include "vasprintf.h" -#include #include #include "vasnprintf.h" @@ -35,15 +34,10 @@ vasprintf (char **resultp, const char *format, va_list args) char *result = vasnprintf (NULL, &length, format, args); if (result == NULL) return -1; - if (length > INT_MAX) - { - /* We could produce such a big string, but can't return its length - as an 'int'. */ - free (result); - return -1; - } *resultp = result; - /* Return the number of resulting bytes, excluding the trailing NUL. */ + /* Return the number of resulting bytes, excluding the trailing NUL. + If it wouldn't fit in an 'int', vasnprintf() would have returned NULL + and set errno to EOVERFLOW. */ return length; } diff --git a/gettext-runtime/libasprintf/vasprintf.h b/gettext-runtime/libasprintf/vasprintf.h index c82d7b7bb..fc128031e 100644 --- a/gettext-runtime/libasprintf/vasprintf.h +++ b/gettext-runtime/libasprintf/vasprintf.h @@ -1,5 +1,5 @@ /* vsprintf with automatic memory allocation. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002-2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published @@ -39,6 +39,10 @@ extern "C" { #endif +/* Write formatted output to a string dynamically allocated with malloc(). + If the memory allocation succeeds, store the address of the string in + *RESULT and return the number of resulting bytes, excluding the trailing + NUL. Upon memory allocation error, or some other error, return -1. */ extern int asprintf (char **result, const char *format, ...) __attribute__ ((__format__ (__printf__, 2, 3))); extern int vasprintf (char **result, const char *format, va_list args) diff --git a/gettext-runtime/m4/ChangeLog b/gettext-runtime/m4/ChangeLog index da472d859..d168dfef5 100644 --- a/gettext-runtime/m4/ChangeLog +++ b/gettext-runtime/m4/ChangeLog @@ -1,3 +1,7 @@ +2004-06-01 Paul Eggert + + * longlong.m4, ulonglong.m4: Fix copyright date and/or serial number. + 2004-09-05 Bruno Haible * gettext.m4 (AM_INTL_SUBDIR): Test for CFPreferencesCopyAppValue. diff --git a/gettext-runtime/m4/longlong.m4 b/gettext-runtime/m4/longlong.m4 index 698d2ae7b..028422b61 100644 --- a/gettext-runtime/m4/longlong.m4 +++ b/gettext-runtime/m4/longlong.m4 @@ -1,5 +1,5 @@ # longlong.m4 serial 5 -dnl Copyright (C) 1999-2003 Free Software Foundation, Inc. +dnl Copyright (C) 1999-2004 Free Software Foundation, Inc. dnl This file is free software, distributed under the terms of the GNU dnl General Public License. As a special exception to the GNU General dnl Public License, this file may be distributed as part of a program diff --git a/gettext-runtime/m4/ulonglong.m4 b/gettext-runtime/m4/ulonglong.m4 index 3c7c5f03d..1123ccb83 100644 --- a/gettext-runtime/m4/ulonglong.m4 +++ b/gettext-runtime/m4/ulonglong.m4 @@ -1,5 +1,5 @@ # ulonglong.m4 serial 4 -dnl Copyright (C) 1999-2003 Free Software Foundation, Inc. +dnl Copyright (C) 1999-2004 Free Software Foundation, Inc. dnl This file is free software, distributed under the terms of the GNU dnl General Public License. As a special exception to the GNU General dnl Public License, this file may be distributed as part of a program diff --git a/gettext-tools/lib/ChangeLog b/gettext-tools/lib/ChangeLog index 997ac31b2..7b758adcb 100644 --- a/gettext-tools/lib/ChangeLog +++ b/gettext-tools/lib/ChangeLog @@ -2,6 +2,19 @@ * alloca_.h: Conditionalize on _GNULIB_ALLOCA_H, not _ALLOCA_H. +2004-11-02 Bruno Haible + + * setenv.h (unsetenv): Define as a macro if the system's unsetenv() + function returns void. + +2003-09-08 Paul Eggert + + * atexit.c (atexit): Define using a prototype. + +2004-08-06 Paul Eggert + + * setenv.c: Import changes from coreutils. + 2004-12-10 Bruno Haible * obstack.h: Update from current gnulib version. diff --git a/gettext-tools/lib/setenv.c b/gettext-tools/lib/setenv.c index 55b9bf2da..c06fec4eb 100644 --- a/gettext-tools/lib/setenv.c +++ b/gettext-tools/lib/setenv.c @@ -22,10 +22,7 @@ #include #include -#if !_LIBC -# if !defined errno && !defined HAVE_ERRNO_DECL -extern int errno; -# endif +#ifndef __set_errno # define __set_errno(ev) ((errno) = (ev)) #endif diff --git a/gettext-tools/lib/setenv.h b/gettext-tools/lib/setenv.h index 9068b70ff..7ac5ae645 100644 --- a/gettext-tools/lib/setenv.h +++ b/gettext-tools/lib/setenv.h @@ -1,5 +1,5 @@ /* Setting environment variables. - Copyright (C) 2001-2002 Free Software Foundation, Inc. + Copyright (C) 2001-2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,7 +18,7 @@ #if HAVE_SETENV || HAVE_UNSETENV /* Get setenv(), unsetenv() declarations. */ -#include +# include #endif @@ -34,7 +34,15 @@ extern int setenv (const char *name, const char *value, int replace); #endif -#if !HAVE_UNSETENV +#if HAVE_UNSETENV + +# if VOID_UNSETENV +/* On some systems, unsetenv() returns void. + This is the case for FreeBSD 4.8, NetBSD 1.6, OpenBSD 3.4. */ +# define unsetenv(name) ((unsetenv)(name), 0) +# endif + +#else /* Remove the variable NAME from the environment. */ extern int unsetenv (const char *name); diff --git a/gettext-tools/m4/ChangeLog b/gettext-tools/m4/ChangeLog index 44c525d56..f234bdcb1 100644 --- a/gettext-tools/m4/ChangeLog +++ b/gettext-tools/m4/ChangeLog @@ -1,3 +1,46 @@ +2005-01-06 Bruno Haible + + * stdbool.m4: Upgrade to gnulib version. + +2004-11-02 Bruno Haible + + * setenv.m4 (gt_FUNC_SETENV): Define VOID_UNSETENV if unsetenv() + returns void. + +2004-10-04 Paul Eggert + + * unlocked-io.m4: Add copyright notice. + (gl_FUNC_GLIBC_UNLOCKED_IO): Define USE_UNLOCKED_IO. + +2004-06-01 Paul Eggert + + * quotearg.m4: Fix copyright date and/or serial number. + +2003-11-24 Bruno Haible + + * allocsa.m4 (gl_ALLOCSA): Require also gl_AC_TYPE_LONG_LONG and + gt_TYPE_LONGDOUBLE. + +2003-09-17 Paul Eggert + + * extensions.m4 (gl_USE_SYSTEM_EXTENSIONS): Call AC_BEFORE first, + to avoid spurious warnings like "AC_RUN_IFELSE was called before + gl_USE_SYSTEM_EXTENSIONS" from autoreconf. + +2003-09-12 Paul Eggert + + * extensions.m4 (gl_USE_SYSTEM_EXTENSIONS): Require AC_AIX + and AC_MINIX, too, so that their extensions are available. + +2003-09-10 Bruno Haible + + * xreadlink.m4 (gl_XREADLINK): Remove check. + +2003-09-10 Bruno Haible + + * setenv.m4 (gl_PREREQ_SETENV, gl_PREREQ_UNSETENV): Remove + and checks. + 2004-04-26 Bruno Haible * csharpcomp.m4 (gt_CSHARPCOMP): Avoid using !.