diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ChangeLog | 23 | ||||
-rw-r--r-- | lib/gai_strerror.c | 6 | ||||
-rw-r--r-- | lib/getaddrinfo.h | 16 | ||||
-rw-r--r-- | lib/vasnprintf.c | 48 |
4 files changed, 66 insertions, 27 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog index b91cba3ff..47481ddd4 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,26 @@ +2006-02-14 Paul Eggert <eggert@cs.ucla.edu> + + * vasnprintf.c (VASNPRINTF): Rewrite the computation so that we + need not use xsum. + +2006-02-14 Bruno Haible <bruno@clisp.org> + + Sync from gnulib. + + * vasnprintf.c (VASNPRINTF): In the computation of the size of the + temporary buffer for sprintf, take into account the precision also + for 'd', 'i', 'u', 'o', 'x', 'X'. + +2006-02-14 Simon Josefsson <jas@extundo.com> + + Sync from gnulib. + + * getaddrinfo.h: Define EAI_ADDRFAMILY and EAI_SYSTEM if not set, + for mingw32. + + * gai_strerror.c, getaddrinfo.h: Protect netdb.h #include (for + mingw32). + 2006-02-07 Paul Eggert <eggert@cs.ucla.edu> * closeout.c (close_stdout): Don't assume 'bool' converts nonzero diff --git a/lib/gai_strerror.c b/lib/gai_strerror.c index f2898706e..d97b858be 100644 --- a/lib/gai_strerror.c +++ b/lib/gai_strerror.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997, 2001, 2002, 2004, 2005 Free Software Foundation, Inc. +/* Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Philip Blundell <pjb27@cam.ac.uk>, 1997. @@ -25,7 +25,9 @@ #endif #include <stdio.h> -#include <netdb.h> +#ifdef HAVE_NETDB_H +# include <netdb.h> +#endif #ifdef _LIBC # include <libintl.h> diff --git a/lib/getaddrinfo.h b/lib/getaddrinfo.h index 65f52cda6..7722c14ba 100644 --- a/lib/getaddrinfo.h +++ b/lib/getaddrinfo.h @@ -1,5 +1,5 @@ /* Get address information. - Copyright (C) 1996-2002, 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 1996-2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Contributed by Simon Josefsson <simon@josefsson.org>. This program is free software; you can redistribute it and/or modify @@ -26,7 +26,9 @@ # include <sys/types.h> /* Get all getaddrinfo related declarations, if available. */ # include <sys/socket.h> +#ifdef HAVE_NETDB_H # include <netdb.h> +#endif # ifndef HAVE_STRUCT_ADDRINFO @@ -65,10 +67,18 @@ struct addrinfo # define EAI_FAMILY -6 /* `ai_family' not supported. */ # define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */ # define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */ -# define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */ # define EAI_MEMORY -10 /* Memory allocation failure. */ -# define EAI_SYSTEM -11 /* System error returned in `errno'. */ # define EAI_OVERFLOW -12 /* Argument buffer overflow. */ +#endif +# ifndef EAI_ADDRFAMILY +/* Not defined on mingw32. XXX May be incorrect? Perhaps it is never + returned? */ +# define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */ +# endif +# ifndef EAI_SYSTEM +/* Not defined on mingw32. XXX May be incorrect? Perhaps it is never + returned? */ +# define EAI_SYSTEM -11 /* System error returned in `errno'. */ # endif # ifdef __USE_GNU diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c index 16d6fbd29..6a6354370 100644 --- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -1,5 +1,5 @@ /* vsprintf with automatic memory allocation. - Copyright (C) 1999, 2002-2005 Free Software Foundation, Inc. + Copyright (C) 1999, 2002-2006 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 @@ -344,28 +344,29 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar tmp_length = (unsigned int) (sizeof (unsigned long long) * CHAR_BIT * 0.30103 /* binary -> decimal */ - * 2 /* estimate for FLAG_GROUP */ ) - + 1 /* turn floor into ceil */ - + 1; /* account for leading sign */ + + 1; /* turn floor into ceil */ else # endif if (type == TYPE_LONGINT || type == TYPE_ULONGINT) tmp_length = (unsigned int) (sizeof (unsigned long) * CHAR_BIT * 0.30103 /* binary -> decimal */ - * 2 /* estimate for FLAG_GROUP */ ) - + 1 /* turn floor into ceil */ - + 1; /* account for leading sign */ + + 1; /* turn floor into ceil */ else tmp_length = (unsigned int) (sizeof (unsigned int) * CHAR_BIT * 0.30103 /* binary -> decimal */ - * 2 /* estimate for FLAG_GROUP */ ) - + 1 /* turn floor into ceil */ - + 1; /* account for leading sign */ + + 1; /* turn floor into ceil */ + if (tmp_length < precision) + tmp_length = precision; + /* Multiply by 2, as an estimate for FLAG_GROUP. */ + /* Add 1, to account for a leading sign. */ + tmp_length = (tmp_length < SIZE_MAX / 2 + ? 2 * tmp_length + 1 + : SIZE_MAX); break; case 'o': @@ -375,8 +376,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar (unsigned int) (sizeof (unsigned long long) * CHAR_BIT * 0.333334 /* binary -> octal */ ) - + 1 /* turn floor into ceil */ - + 1; /* account for leading sign */ + + 1; /* turn floor into ceil */ else # endif if (type == TYPE_LONGINT || type == TYPE_ULONGINT) @@ -384,15 +384,17 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar (unsigned int) (sizeof (unsigned long) * CHAR_BIT * 0.333334 /* binary -> octal */ ) - + 1 /* turn floor into ceil */ - + 1; /* account for leading sign */ + + 1; /* turn floor into ceil */ else tmp_length = (unsigned int) (sizeof (unsigned int) * CHAR_BIT * 0.333334 /* binary -> octal */ ) - + 1 /* turn floor into ceil */ - + 1; /* account for leading sign */ + + 1; /* turn floor into ceil */ + if (tmp_length < precision) + tmp_length = precision; + /* Add 1, to account for a leading sign. */ + tmp_length += (tmp_length < SIZE_MAX); break; case 'x': case 'X': @@ -402,8 +404,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar (unsigned int) (sizeof (unsigned long long) * CHAR_BIT * 0.25 /* binary -> hexadecimal */ ) - + 1 /* turn floor into ceil */ - + 2; /* account for leading sign or alternate form */ + + 1; /* turn floor into ceil */ else # endif if (type == TYPE_LONGINT || type == TYPE_ULONGINT) @@ -411,15 +412,18 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar (unsigned int) (sizeof (unsigned long) * CHAR_BIT * 0.25 /* binary -> hexadecimal */ ) - + 1 /* turn floor into ceil */ - + 2; /* account for leading sign or alternate form */ + + 1; /* turn floor into ceil */ else tmp_length = (unsigned int) (sizeof (unsigned int) * CHAR_BIT * 0.25 /* binary -> hexadecimal */ ) - + 1 /* turn floor into ceil */ - + 2; /* account for leading sign or alternate form */ + + 1; /* turn floor into ceil */ + if (tmp_length < precision) + tmp_length = precision; + /* Add 2, to account for a leading sign or alternate form. */ + if (tmp_length <= SIZE_MAX / 2) + tmp_length *= 2; break; case 'f': case 'F': |