+2004-09-08 Bruno Haible <bruno@clisp.org>
+
+ * vasnprintf.c (VASNPRINTF): Signal EOVERFLOW if the resulting length
+ is > INT_MAX.
+
2005-01-01 Bruno Haible <bruno@clisp.org>
* dcigettext.c (guess_category_value): Let the environment variables
#include <stdlib.h> /* abort(), malloc(), realloc(), free() */
#include <string.h> /* memcpy(), strlen() */
#include <errno.h> /* errno */
-#include <limits.h> /* CHAR_BIT */
+#include <limits.h> /* CHAR_BIT, INT_MAX */
#include <float.h> /* DBL_MAX_EXP, LDBL_MAX_EXP */
#if WIDE_CHAR_VERSION
# include "wprintf-parse.h"
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);
/* 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
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)
* alloca_.h: Conditionalize on _GNULIB_ALLOCA_H, not _ALLOCA_H.
+2004-09-08 Bruno Haible <bruno@clisp.org>
+
+ * 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 <bruno@clisp.org>
* vasnprintf.c (VASNPRINTF): Correctly handle the case of a precision
#include <stdlib.h> /* abort(), malloc(), realloc(), free() */
#include <string.h> /* memcpy(), strlen() */
#include <errno.h> /* errno */
-#include <limits.h> /* CHAR_BIT */
+#include <limits.h> /* CHAR_BIT, INT_MAX */
#include <float.h> /* DBL_MAX_EXP, LDBL_MAX_EXP */
#if WIDE_CHAR_VERSION
# include "wprintf-parse.h"
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);
/* 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
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)
/* Specification. */
#include "vasprintf.h"
-#include <limits.h>
#include <stdlib.h>
#include "vasnprintf.h"
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;
}
/* 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
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)
+2004-06-01 Paul Eggert <eggert@cs.ucla.edu>
+
+ * longlong.m4, ulonglong.m4: Fix copyright date and/or serial number.
+
2004-09-05 Bruno Haible <bruno@clisp.org>
* gettext.m4 (AM_INTL_SUBDIR): Test for CFPreferencesCopyAppValue.
# 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
# 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
* alloca_.h: Conditionalize on _GNULIB_ALLOCA_H, not _ALLOCA_H.
+2004-11-02 Bruno Haible <bruno@clisp.org>
+
+ * setenv.h (unsetenv): Define as a macro if the system's unsetenv()
+ function returns void.
+
+2003-09-08 Paul Eggert <eggert@twinsun.com>
+
+ * atexit.c (atexit): Define using a prototype.
+
+2004-08-06 Paul Eggert <eggert@cs.ucla.edu>
+
+ * setenv.c: Import changes from coreutils.
+
2004-12-10 Bruno Haible <bruno@clisp.org>
* obstack.h: Update from current gnulib version.
#include <alloca.h>
#include <errno.h>
-#if !_LIBC
-# if !defined errno && !defined HAVE_ERRNO_DECL
-extern int errno;
-# endif
+#ifndef __set_errno
# define __set_errno(ev) ((errno) = (ev))
#endif
/* 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
#if HAVE_SETENV || HAVE_UNSETENV
/* Get setenv(), unsetenv() declarations. */
-#include <stdlib.h>
+# include <stdlib.h>
#endif
#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);
+2005-01-06 Bruno Haible <bruno@clisp.org>
+
+ * stdbool.m4: Upgrade to gnulib version.
+
+2004-11-02 Bruno Haible <bruno@clisp.org>
+
+ * setenv.m4 (gt_FUNC_SETENV): Define VOID_UNSETENV if unsetenv()
+ returns void.
+
+2004-10-04 Paul Eggert <eggert@cs.ucla.edu>
+
+ * unlocked-io.m4: Add copyright notice.
+ (gl_FUNC_GLIBC_UNLOCKED_IO): Define USE_UNLOCKED_IO.
+
+2004-06-01 Paul Eggert <eggert@cs.ucla.edu>
+
+ * quotearg.m4: Fix copyright date and/or serial number.
+
+2003-11-24 Bruno Haible <bruno@clisp.org>
+
+ * allocsa.m4 (gl_ALLOCSA): Require also gl_AC_TYPE_LONG_LONG and
+ gt_TYPE_LONGDOUBLE.
+
+2003-09-17 Paul Eggert <eggert@twinsun.com>
+
+ * 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 <eggert@twinsun.com>
+
+ * extensions.m4 (gl_USE_SYSTEM_EXTENSIONS): Require AC_AIX
+ and AC_MINIX, too, so that their extensions are available.
+
+2003-09-10 Bruno Haible <bruno@clisp.org>
+
+ * xreadlink.m4 (gl_XREADLINK): Remove <stdlib.h> check.
+
+2003-09-10 Bruno Haible <bruno@clisp.org>
+
+ * setenv.m4 (gl_PREREQ_SETENV, gl_PREREQ_UNSETENV): Remove
+ <stdlib.h> and <string.h> checks.
+
2004-04-26 Bruno Haible <bruno@clisp.org>
* csharpcomp.m4 (gt_CSHARPCOMP): Avoid using !.