Mercurial > hg > octave-nkf > gnulib-hg
changeset 9838:c73f27c8e6f0
Merge branch 'master' of ssh://karl@git.sv.gnu.org/srv/git/gnulib
author | Karl Berry <karl@freefriends.org> |
---|---|
date | Sun, 30 Mar 2008 15:04:25 -0700 |
parents | ac3a4b0c4b7e (current diff) 8c80e0046993 (diff) |
children | 3dc6b2551b2e |
files | |
diffstat | 82 files changed, 477 insertions(+), 246 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,164 @@ +2008-03-30 Bruno Haible <bruno@clisp.org> + + * lib/striconveh.h (mem_iconveh, str_iconveh): Optimize the conversion + from UTF-8 to UTF-8//TRANSLIT in the same way as from UTF-8 to UTF-8. + +2008-03-30 Bruno Haible <bruno@clisp.org> + + Avoid failure when attempting to return empty iconv results on some + platforms. + * lib/striconveh.c (mem_cd_iconveh_internal): In the final memory + allocation, don't report ENOMEM when the resulting string is empty. + +2008-03-30 Bruno Haible <bruno@clisp.org> + + Fix buffer overrun. + * lib/vasnprintf.c (VASNPRINTF): If !USE_SNPRINTF && pad_ourselves: + Don't consider the width for tmp_length. Check count against tmp_length + before doing the padding. Ensure enough allocation during padding. + +2008-03-30 Eric Blake <ebb9@byu.net> + + More strtod touchups. + * tests/test-strtod.c (main): Ignore tests for signbit on NaN, and + sign of negative underflow, for now. Use .5, not .1. + * doc/posix-functions/strtod.texi (strtod): Mention these + limitations. + Reported by Jim Meyering. + +2008-03-30 Eric Blake <ebb9@byu.net> + + strtod touchups. + * lib/strtod.c (strtod): Avoid compiler warnings. + Reported by Jim Meyering. + +2008-03-30 Bruno Haible <bruno@clisp.org> + + * lib/unistdio/u-vsprintf.h (EOVERFLOW): Remove fallback. + * modules/unistdio/ulc-vsprintf (Depends-on): Add EOVERFLOW. + * modules/unistdio/u8-vsprintf (Depends-on): Add EOVERFLOW. + * modules/unistdio/u8-u8-vsprintf (Depends-on): Add EOVERFLOW. + * modules/unistdio/u16-vsprintf (Depends-on): Add EOVERFLOW. + * modules/unistdio/u16-u16-vsprintf (Depends-on): Add EOVERFLOW. + * modules/unistdio/u32-vsprintf (Depends-on): Add EOVERFLOW. + * modules/unistdio/u32-u32-vsprintf (Depends-on): Add EOVERFLOW. + + * lib/unistdio/u-vsnprintf.h (EOVERFLOW): Remove fallback. + * modules/unistdio/ulc-vsnprintf (Depends-on): Add EOVERFLOW. + * modules/unistdio/u8-vsnprintf (Depends-on): Add EOVERFLOW. + * modules/unistdio/u8-u8-vsnprintf (Depends-on): Add EOVERFLOW. + * modules/unistdio/u16-vsnprintf (Depends-on): Add EOVERFLOW. + * modules/unistdio/u16-u16-vsnprintf (Depends-on): Add EOVERFLOW. + * modules/unistdio/u32-vsnprintf (Depends-on): Add EOVERFLOW. + * modules/unistdio/u32-u32-vsnprintf (Depends-on): Add EOVERFLOW. + + * lib/unistdio/u-vasprintf.h (EOVERFLOW): Remove fallback. + * modules/unistdio/ulc-vasprintf (Depends-on): Add EOVERFLOW. + * modules/unistdio/u8-vasprintf (Depends-on): Add EOVERFLOW. + * modules/unistdio/u8-u8-vasprintf (Depends-on): Add EOVERFLOW. + * modules/unistdio/u16-vasprintf (Depends-on): Add EOVERFLOW. + * modules/unistdio/u16-u16-vasprintf (Depends-on): Add EOVERFLOW. + * modules/unistdio/u32-vasprintf (Depends-on): Add EOVERFLOW. + * modules/unistdio/u32-u32-vasprintf (Depends-on): Add EOVERFLOW. + + * lib/unistdio/ulc-vfprintf.c (EOVERFLOW): Remove fallback. + * modules/unistdio/ulc-vfprintf (Depends-on): Add EOVERFLOW. + + * lib/unistdio/ulc-fprintf.c (EOVERFLOW): Remove fallback. + * modules/unistdio/ulc-fprintf (Depends-on): Add EOVERFLOW. + + * lib/xvasprintf.c (EOVERFLOW): Remove fallback. + * modules/xvasprintf (Depends-on): Add EOVERFLOW. + + * lib/vsprintf.c (EOVERFLOW): Remove fallback. + * m4/vsprintf-posix.m4 (gl_FUNC_VSPRINTF_POSIX): Drop gl_EOVERFLOW. + * modules/vsprintf-posix (Depends-on): Add EOVERFLOW. + + * lib/vsnprintf.c (EOVERFLOW): Remove fallback. + * m4/vsnprintf-posix.m4 (gl_FUNC_VSNPRINTF_POSIX): Drop gl_EOVERFLOW. + * modules/vsnprintf (Depends-on): Add EOVERFLOW. + + * lib/vfprintf.c (EOVERFLOW): Remove fallback. + * m4/vfprintf-posix.m4 (gl_FUNC_VFPRINTF_POSIX): Drop gl_EOVERFLOW. + * modules/vfprintf-posix (Depends-on): Add EOVERFLOW. + + * lib/vasprintf.c (EOVERFLOW): Remove fallback. + * m4/vasprintf-posix.m4 (gl_FUNC_VASPRINTF_POSIX): Drop gl_EOVERFLOW. + * modules/vasprintf (Depends-on): Add EOVERFLOW. + + * lib/vasnprintf.c (EOVERFLOW): Remove fallback. + * m4/vasnprintf.m4 (gl_FUNC_VASNPRINTF): Drop gl_EOVERFLOW. + * m4/vasnprintf-posix.m4 (gl_FUNC_VASNPRINTF_POSIX): Drop gl_EOVERFLOW. + * modules/vasnprintf (Files): Remove m4/eoverflow.m4. + (Depends-on): Add EOVERFLOW. + * modules/unistdio/ulc-vasnprintf (Files): Remove m4/eoverflow.m4. + (Depends-on): Add EOVERFLOW. + * modules/unistdio/u8-vasnprintf (Files): Remove m4/eoverflow.m4. + (Depends-on): Add EOVERFLOW. + * modules/unistdio/u8-u8-vasnprintf (Files): Remove m4/eoverflow.m4. + (Depends-on): Add EOVERFLOW. + * modules/unistdio/u16-vasnprintf (Files): Remove m4/eoverflow.m4. + (Depends-on): Add EOVERFLOW. + * modules/unistdio/u16-u16-vasnprintf (Files): Remove m4/eoverflow.m4. + (Depends-on): Add EOVERFLOW. + * modules/unistdio/u32-vasnprintf (Files): Remove m4/eoverflow.m4. + (Depends-on): Add EOVERFLOW. + * modules/unistdio/u32-u32-vasnprintf (Files): Remove m4/eoverflow.m4. + (Depends-on): Add EOVERFLOW. + + * lib/sprintf.c (EOVERFLOW): Remove fallback. + * m4/sprintf-posix.m4 (gl_FUNC_SPRINTF_POSIX): Drop gl_EOVERFLOW. + * modules/sprintf-posix (Depends-on): Add EOVERFLOW. + + * lib/snprintf.c (EOVERFLOW): Remove fallback. + * m4/snprintf-posix.m4 (gl_FUNC_SNPRINTF_POSIX): Drop gl_EOVERFLOW. + * modules/snprintf (Depends-on): Add EOVERFLOW. + + * lib/poll.c (EOVERFLOW): Remove fallback. + * modules/poll (Depends-on): Add EOVERFLOW. + + * lib/getugroups.c (EOVERFLOW): Remove fallback. + * modules/getugroups (Depends-on): Add EOVERFLOW. + + * lib/getdelim.c (EOVERFLOW): Remove fallback. + * modules/getdelim (Depends-on): Add EOVERFLOW. + + * lib/ftell.c (EOVERFLOW): Remove fallback. + * modules/ftell (Depends-on): Add EOVERFLOW. + + * lib/fprintf.c (EOVERFLOW): Remove fallback. + * m4/fprintf-posix.m4 (gl_FUNC_FPRINTF_POSIX): Drop gl_EOVERFLOW. + * modules/fprintf-posix (Depends-on): Add EOVERFLOW. + + * lib/c-stack.c (EOVERFLOW): Remove unused fallback. + + * modules/EOVERFLOW-tests: New file. + * tests/test-EOVERFLOW.c: New file. + + * modules/EOVERFLOW: New file. + * doc/posix-headers/errno.texi: Mention EOVERFLOW portability problem. + +2008-03-30 Bruno Haible <bruno@clisp.org> + + Fix bug introduced on 2007-06-10. + * lib/vasnprintf.c (VASNPRINTF): When performing zero-padding, use + spaces instead of 0 digits for 's' also when ENABLE_UNISTDIO. + +2008-03-30 Bruno Haible <bruno@clisp.org> + + Improve freadseek's efficiency after ungetc. + * lib/freadseek.c: Include freadahead.h. + (freadptrinc): New function, extracted from freadseek. + (freadseek): Use it in a loop. Use freadahead to determine the number + of loop iterations. + * modules/freadseek (Depends-on): Add freadahead. + (configure.ac): Require AC_C_INLINE. + +2008-03-30 Bruno Haible <bruno@clisp.org> + + * lib/freadseek.c (freadseek): Don't ignore the return value of + freadptr. + 2008-03-29 Eric Blake <ebb9@byu.net> Add hex float support. @@ -36,9 +197,10 @@ * tests/test-ftello.c (main): Likewise. Pass test-freadseek on cygwin. - * modules/freadseek (Depends-on): Use freadptr, not freadseek. + * modules/freadseek (Depends-on): Use freadptr, not freadahead. * lib/freadseek.c (freadseek): Don't increment beyond bounds of ungetc buffer. + * tests/test-fflush2.c (main): Fix typo. 2008-03-29 Bruno Haible <bruno@clisp.org>
--- a/doc/posix-functions/strtod.texi +++ b/doc/posix-functions/strtod.texi @@ -52,7 +52,12 @@ @item This function returns a positive value for negative underflow on some platforms: -glibc 2.4, Mingw, Cygwin. +glibc 2.7, Mingw, Cygwin. + +@item +This function cannot distinguish between ``nan'' and ``-nan'' on some +platforms: +glibc 2.7. @item This function fails to correctly parse very long strings on some
--- a/doc/posix-headers/errno.texi +++ b/doc/posix-headers/errno.texi @@ -3,10 +3,13 @@ POSIX specification: @url{http://www.opengroup.org/susv3xbd/errno.h.html} -Gnulib module: --- +Gnulib module: EOVERFLOW Portability problems fixed by Gnulib: @itemize +@item +The macro @code{EOVERFLOW} is not defined on some platforms: +OSF/1 4.0, mingw. @end itemize Portability problems not fixed by Gnulib:
--- a/lib/c-stack.c +++ b/lib/c-stack.c @@ -48,9 +48,6 @@ #ifndef ENOTSUP # define ENOTSUP EINVAL #endif -#ifndef EOVERFLOW -# define EOVERFLOW EINVAL -#endif #include <signal.h> #if ! HAVE_STACK_T && ! defined stack_t
--- a/lib/fprintf.c +++ b/lib/fprintf.c @@ -1,5 +1,5 @@ /* Formatted output to a stream. - Copyright (C) 2004, 2006-2007 Free Software Foundation, Inc. + Copyright (C) 2004, 2006-2008 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 @@ -29,11 +29,6 @@ #include "fseterr.h" #include "vasnprintf.h" -/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */ -#ifndef EOVERFLOW -# define EOVERFLOW E2BIG -#endif - /* Print formatted output to the stream FP. Return string length of formatted string. On error, return a negative value. */
--- a/lib/freadseek.c +++ b/lib/freadseek.c @@ -22,29 +22,21 @@ #include <stdlib.h> #include <unistd.h> +#include "freadahead.h" #include "freadptr.h" -int -freadseek (FILE *fp, size_t offset) +/* Increment the in-memory pointer. INCREMENT must be at most the buffer size + returned by freadptr(). + This is very cheap (no system calls). */ +static inline void +freadptrinc (FILE *fp, size_t increment) { - size_t buffered; - int fd; - - if (offset == 0) - return 0; - - /* Increment the in-memory pointer. This is very cheap (no system calls). */ - freadptr (fp, &buffered); - if (buffered > 0) - { - size_t increment = (buffered < offset ? buffered : offset); - - /* Keep this code in sync with freadahead and freadptr! */ + /* Keep this code in sync with freadptr! */ #if defined _IO_ferror_unlocked /* GNU libc, BeOS */ - fp->_IO_read_ptr += increment; + fp->_IO_read_ptr += increment; #elif defined __sferror /* FreeBSD, NetBSD, OpenBSD, MacOS X, Cygwin */ - fp->_p += increment; - fp->_r -= increment; + fp->_p += increment; + fp->_r -= increment; #elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, mingw */ # if defined __sun && defined _LP64 /* Solaris/{SPARC,AMD64} 64-bit */ # define fp_ ((struct { unsigned char *_ptr; \ @@ -54,27 +46,63 @@ int _file; \ unsigned int _flag; \ } *) fp) - fp_->_ptr += increment; - fp_->_cnt -= increment; + fp_->_ptr += increment; + fp_->_cnt -= increment; # else - fp->_ptr += increment; - fp->_cnt -= increment; + fp->_ptr += increment; + fp->_cnt -= increment; # endif #elif defined __UCLIBC__ /* uClibc */ # ifdef __STDIO_BUFFERS - fp->__bufpos += increment; + fp->__bufpos += increment; # else - abort (); + abort (); # endif #elif defined __QNX__ /* QNX */ - fp->_Next += increment; + fp->_Next += increment; #else #error "Please port gnulib freadseek.c to your platform! Look at the definition of getc, getc_unlocked on your system, then report this to bug-gnulib." #endif +} - offset -= increment; +int +freadseek (FILE *fp, size_t offset) +{ + size_t total_buffered; + int fd; + + if (offset == 0) + return 0; + + /* Seek over the already read and buffered input as quickly as possible, + without doing any system calls. */ + total_buffered = freadahead (fp); + /* This loop is usually executed at most twice: once for ungetc buffer (if + present) and once for the main buffer. */ + while (total_buffered > 0) + { + size_t buffered; + + if (freadptr (fp, &buffered) != NULL && buffered > 0) + { + size_t increment = (buffered < offset ? buffered : offset); + + freadptrinc (fp, increment); + offset -= increment; + if (offset == 0) + return 0; + total_buffered -= increment; + if (total_buffered == 0) + break; + } + /* Read one byte. If we were reading from the ungetc buffer, this + switches the stream back to the main buffer. */ + if (fgetc (fp) == EOF) + goto eof; + offset--; if (offset == 0) return 0; + total_buffered--; } /* Test whether the stream is seekable or not. */ @@ -94,18 +122,19 @@ { size_t count = (sizeof (buf) < offset ? sizeof (buf) : offset); if (fread (buf, 1, count, fp) < count) - { - if (ferror (fp)) - /* EOF, or error before or while reading. */ - return EOF; - else - /* Encountered EOF. */ - return 0; - } + goto eof; offset -= count; } while (offset > 0); return 0; } + + eof: + /* EOF, or error before or while reading. */ + if (ferror (fp)) + return EOF; + else + /* Encountered EOF. */ + return 0; }
--- a/lib/ftell.c +++ b/lib/ftell.c @@ -23,11 +23,6 @@ /* Get off_t. */ #include <unistd.h> -/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */ -#ifndef EOVERFLOW -# define EOVERFLOW E2BIG -#endif - long ftell (FILE *fp) {
--- a/lib/getdelim.c +++ b/lib/getdelim.c @@ -1,5 +1,5 @@ /* getdelim.c --- Implementation of replacement getdelim function. - Copyright (C) 1994, 1996, 1997, 1998, 2001, 2003, 2005, 2006, 2007 Free + Copyright (C) 1994, 1996, 1997, 1998, 2001, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or @@ -42,11 +42,6 @@ # define funlockfile(x) ((void) 0) #endif -/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */ -#ifndef EOVERFLOW -# define EOVERFLOW E2BIG -#endif - /* Read up to (and including) a DELIMITER from FP into *LINEPTR (and NUL-terminate it). *LINEPTR is a pointer returned from malloc (or NULL), pointing to *N characters of space. It is realloc'ed as
--- a/lib/getugroups.c +++ b/lib/getugroups.c @@ -1,6 +1,6 @@ /* getugroups.c -- return a list of the groups a user is in - Copyright (C) 1990, 1991, 1998-2000, 2003-2007 Free Software Foundation. + Copyright (C) 1990, 1991, 1998-2000, 2003-2008 Free Software Foundation. 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 @@ -28,9 +28,6 @@ #include <unistd.h> #include <errno.h> -#ifndef EOVERFLOW -# define EOVERFLOW EINVAL -#endif /* Some old header files might not declare setgrent, getgrent, and endgrent. If you don't have them at all, we can't implement this function.
--- a/lib/poll.c +++ b/lib/poll.c @@ -43,10 +43,6 @@ #define INFTIM (-1) #endif -#ifndef EOVERFLOW -#define EOVERFLOW EINVAL -#endif - /* BeOS does not have MSG_PEEK. */ #ifndef MSG_PEEK #define MSG_PEEK 0
--- a/lib/snprintf.c +++ b/lib/snprintf.c @@ -1,5 +1,5 @@ /* Formatted output to strings. - Copyright (C) 2004, 2006-2007 Free Software Foundation, Inc. + Copyright (C) 2004, 2006-2008 Free Software Foundation, Inc. Written by Simon Josefsson and Paul Eggert. This program is free software; you can redistribute it and/or modify @@ -29,11 +29,6 @@ #include "vasnprintf.h" -/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */ -#ifndef EOVERFLOW -# define EOVERFLOW E2BIG -#endif - /* Print formatted output to string STR. Similar to sprintf, but additional length SIZE limit how much is written into STR. Returns string length of formatted string (which may be larger than SIZE).
--- a/lib/sprintf.c +++ b/lib/sprintf.c @@ -1,5 +1,5 @@ /* Formatted output to strings. - Copyright (C) 2004, 2006-2007 Free Software Foundation, Inc. + Copyright (C) 2004, 2006-2008 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 @@ -29,11 +29,6 @@ #include "vasnprintf.h" -/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */ -#ifndef EOVERFLOW -# define EOVERFLOW E2BIG -#endif - #ifndef SIZE_MAX # define SIZE_MAX ((size_t) -1) #endif
--- a/lib/striconveh.c +++ b/lib/striconveh.c @@ -1,5 +1,5 @@ /* Character set conversion with error handling. - Copyright (C) 2001-2007 Free Software Foundation, Inc. + Copyright (C) 2001-2008 Free Software Foundation, Inc. Written by Bruno Haible and Simon Josefsson. This program is free software: you can redistribute it and/or modify @@ -870,9 +870,10 @@ /* Now the final memory allocation. */ if (result == tmpbuf) { + size_t memsize = length + extra_alloc; char *memory; - memory = (char *) malloc (length + extra_alloc); + memory = (char *) malloc (memsize > 0 ? memsize : 1); if (memory != NULL) { memcpy (memory, tmpbuf, length); @@ -887,9 +888,10 @@ else if (result != *resultp && length + extra_alloc < allocated) { /* Shrink the allocated memory if possible. */ + size_t memsize = length + extra_alloc; char *memory; - memory = (char *) realloc (result, length + extra_alloc); + memory = (char *) realloc (result, memsize > 0 ? memsize : 1); if (memory != NULL) result = memory; } @@ -1015,7 +1017,11 @@ } } - if (STRCASEEQ (to_codeset, "UTF-8", 'U','T','F','-','8',0,0,0,0)) + if (STRCASEEQ (to_codeset, "UTF-8", 'U','T','F','-','8',0,0,0,0) +# if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || __GLIBC__ > 2 || _LIBICONV_VERSION >= 0x0105 + || c_strcasecmp (to_codeset, "UTF-8//TRANSLIT") == 0 +# endif + ) cd2 = (iconv_t)(-1); else { @@ -1151,7 +1157,11 @@ } } - if (STRCASEEQ (to_codeset, "UTF-8", 'U','T','F','-','8',0,0,0,0)) + if (STRCASEEQ (to_codeset, "UTF-8", 'U','T','F','-','8',0,0,0,0) +# if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || __GLIBC__ > 2 || _LIBICONV_VERSION >= 0x0105 + || c_strcasecmp (to_codeset, "UTF-8//TRANSLIT") == 0 +# endif + ) cd2 = (iconv_t)(-1); else {
--- a/lib/strtod.c +++ b/lib/strtod.c @@ -51,7 +51,8 @@ goto noconv; } - s = nptr; + /* Use unsigned char for the ctype routines. */ + s = (unsigned char *) nptr; /* Eat whitespace. */ while (isspace (*s)) @@ -191,11 +192,11 @@ /* Get the exponent specified after the `e' or `E'. */ int save = errno; char *end; - long int exp; + long int value; errno = 0; ++s; - exp = strtol (s, &end, 10); + value = strtol ((char *) s, &end, 10); if (errno == ERANGE && num) { /* The exponent overflowed a `long int'. It is probably a safe @@ -203,7 +204,7 @@ a `long int' exceeds the limits of a `double'. */ if (endptr != NULL) *endptr = end; - if (exp < 0) + if (value < 0) goto underflow; else goto overflow; @@ -213,8 +214,8 @@ the 'e' or 'E', so *ENDPTR will be set there. */ end = (char *) s - 1; errno = save; - s = end; - exponent += exp; + s = (unsigned char *) end; + exponent += value; } if (num == 0.0)
--- a/lib/unistdio/u-vasprintf.h +++ b/lib/unistdio/u-vasprintf.h @@ -1,5 +1,5 @@ /* Formatted output to strings. - Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006-2008 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published @@ -14,11 +14,6 @@ You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */ -#ifndef EOVERFLOW -# define EOVERFLOW E2BIG -#endif - int VASPRINTF (DCHAR_T **resultp, const FCHAR_T *format, va_list args) {
--- a/lib/unistdio/u-vsnprintf.h +++ b/lib/unistdio/u-vsnprintf.h @@ -1,5 +1,5 @@ /* Formatted output to strings. - Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006-2008 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published @@ -14,11 +14,6 @@ You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */ -#ifndef EOVERFLOW -# define EOVERFLOW E2BIG -#endif - int VSNPRINTF (DCHAR_T *buf, size_t size, const FCHAR_T *format, va_list args) {
--- a/lib/unistdio/u-vsprintf.h +++ b/lib/unistdio/u-vsprintf.h @@ -1,5 +1,5 @@ /* Formatted output to strings. - Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006-2008 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published @@ -14,11 +14,6 @@ You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */ -#ifndef EOVERFLOW -# define EOVERFLOW E2BIG -#endif - #ifndef SIZE_MAX # define SIZE_MAX ((size_t) -1) #endif
--- a/lib/unistdio/ulc-fprintf.c +++ b/lib/unistdio/ulc-fprintf.c @@ -1,5 +1,5 @@ /* Formatted output to a stream. - Copyright (C) 2004, 2006-2007 Free Software Foundation, Inc. + Copyright (C) 2004, 2006-2008 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 @@ -29,11 +29,6 @@ #include "fseterr.h" -/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */ -#ifndef EOVERFLOW -# define EOVERFLOW E2BIG -#endif - /* Print formatted output to the stream FP. Return string length of formatted string. On error, return a negative value. */
--- a/lib/unistdio/ulc-vfprintf.c +++ b/lib/unistdio/ulc-vfprintf.c @@ -1,5 +1,5 @@ /* Formatted output to a stream. - Copyright (C) 2004, 2006-2007 Free Software Foundation, Inc. + Copyright (C) 2004, 2006-2008 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 @@ -29,11 +29,6 @@ #include "fseterr.h" -/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */ -#ifndef EOVERFLOW -# define EOVERFLOW E2BIG -#endif - /* Print formatted output to the stream FP. Return string length of formatted string. On error, return a negative value. */
--- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -117,11 +117,6 @@ # include "fpucw.h" #endif -/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */ -#ifndef EOVERFLOW -# define EOVERFLOW E2BIG -#endif - #if HAVE_WCHAR_T # if HAVE_WCSLEN # define local_wcslen wcslen @@ -3661,6 +3656,44 @@ } #endif + /* Decide whether to handle the precision ourselves. */ +#if NEED_PRINTF_UNBOUNDED_PRECISION + switch (dp->conversion) + { + case 'd': case 'i': case 'u': + case 'o': + case 'x': case 'X': case 'p': + prec_ourselves = has_precision && (precision > 0); + break; + default: + prec_ourselves = 0; + break; + } +#endif + + /* Decide whether to perform the padding ourselves. */ +#if !NEED_PRINTF_FLAG_LEFTADJUST && (!DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION) + switch (dp->conversion) + { +# if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO + /* If we need conversion from TCHAR_T[] to DCHAR_T[], we need + to perform the padding after this conversion. Functions + with unistdio extensions perform the padding based on + character count rather than element count. */ + case 'c': case 's': +# endif +# if NEED_PRINTF_FLAG_ZERO + case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': + case 'a': case 'A': +# endif + pad_ourselves = 1; + break; + default: + pad_ourselves = prec_ourselves; + break; + } +#endif + #if !USE_SNPRINTF /* Allocate a temporary buffer of sufficient size for calling sprintf. */ @@ -3837,18 +3870,22 @@ abort (); } + if (!pad_ourselves) + { # if ENABLE_UNISTDIO - /* Padding considers the number of characters, therefore the - number of elements after padding may be - > max (tmp_length, width) - but is certainly - <= tmp_length + width. */ - tmp_length = xsum (tmp_length, width); + /* Padding considers the number of characters, therefore + the number of elements after padding may be + > max (tmp_length, width) + but is certainly + <= tmp_length + width. */ + tmp_length = xsum (tmp_length, width); # else - /* Padding considers the number of elements, says POSIX. */ - if (tmp_length < width) - tmp_length = width; + /* Padding considers the number of elements, + says POSIX. */ + if (tmp_length < width) + tmp_length = width; # endif + } tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */ } @@ -3869,44 +3906,6 @@ } #endif - /* Decide whether to handle the precision ourselves. */ -#if NEED_PRINTF_UNBOUNDED_PRECISION - switch (dp->conversion) - { - case 'd': case 'i': case 'u': - case 'o': - case 'x': case 'X': case 'p': - prec_ourselves = has_precision && (precision > 0); - break; - default: - prec_ourselves = 0; - break; - } -#endif - - /* Decide whether to perform the padding ourselves. */ -#if !NEED_PRINTF_FLAG_LEFTADJUST && (!DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION) - switch (dp->conversion) - { -# if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO - /* If we need conversion from TCHAR_T[] to DCHAR_T[], we need - to perform the padding after this conversion. Functions - with unistdio extensions perform the padding based on - character count rather than element count. */ - case 'c': case 's': -# endif -# if NEED_PRINTF_FLAG_ZERO - case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': - case 'a': case 'A': -# endif - pad_ourselves = 1; - break; - default: - pad_ourselves = prec_ourselves; - break; - } -#endif - /* Construct the format string for calling snprintf or sprintf. */ fbp = buf; @@ -4403,14 +4402,14 @@ } #endif -#if !DCHAR_IS_TCHAR -# if !USE_SNPRINTF +#if !USE_SNPRINTF if (count >= tmp_length) /* tmp_length was incorrectly calculated - fix the code above! */ abort (); -# endif - +#endif + +#if !DCHAR_IS_TCHAR /* Convert from TCHAR_T[] to DCHAR_T[]. */ if (dp->conversion == 'c' || dp->conversion == 's') { @@ -4528,7 +4527,7 @@ if (w < width) { size_t pad = width - w; -# if USE_SNPRINTF + /* Make room for the result. */ if (xsum (count, pad) > allocated - length) { @@ -4538,12 +4537,16 @@ xmax (xsum3 (length, count, pad), xtimes (allocated, 2)); +# if USE_SNPRINTF length += count; ENSURE_ALLOCATION (n); length -= count; +# else + ENSURE_ALLOCATION (n); +# endif } /* Here count + pad <= allocated - length. */ -# endif + { # if !DCHAR_IS_TCHAR || USE_SNPRINTF DCHAR_T * const rp = result + length; @@ -4553,7 +4556,7 @@ DCHAR_T *p = rp + count; DCHAR_T *end = p + pad; DCHAR_T *pad_ptr; -# if !DCHAR_IS_TCHAR +# if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO if (dp->conversion == 'c' || dp->conversion == 's') /* No zero-padding for string directives. */ @@ -4604,13 +4607,6 @@ } #endif -#if DCHAR_IS_TCHAR && !USE_SNPRINTF - if (count >= tmp_length) - /* tmp_length was incorrectly calculated - fix the - code above! */ - abort (); -#endif - /* Here still count <= allocated - length. */ #if !DCHAR_IS_TCHAR || USE_SNPRINTF
--- a/lib/vasprintf.c +++ b/lib/vasprintf.c @@ -1,5 +1,5 @@ /* Formatted output to strings. - Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006-2008 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 @@ -30,11 +30,6 @@ #include "vasnprintf.h" -/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */ -#ifndef EOVERFLOW -# define EOVERFLOW E2BIG -#endif - int vasprintf (char **resultp, const char *format, va_list args) {
--- a/lib/vfprintf.c +++ b/lib/vfprintf.c @@ -1,5 +1,5 @@ /* Formatted output to a stream. - Copyright (C) 2004, 2006-2007 Free Software Foundation, Inc. + Copyright (C) 2004, 2006-2008 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 @@ -29,11 +29,6 @@ #include "fseterr.h" #include "vasnprintf.h" -/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */ -#ifndef EOVERFLOW -# define EOVERFLOW E2BIG -#endif - /* Print formatted output to the stream FP. Return string length of formatted string. On error, return a negative value. */
--- a/lib/vsnprintf.c +++ b/lib/vsnprintf.c @@ -1,5 +1,5 @@ /* Formatted output to strings. - Copyright (C) 2004, 2006-2007 Free Software Foundation, Inc. + Copyright (C) 2004, 2006-2008 Free Software Foundation, Inc. Written by Simon Josefsson and Yoann Vandoorselaere <yoann@prelude-ids.org>. This program is free software; you can redistribute it and/or modify @@ -31,11 +31,6 @@ #include "vasnprintf.h" -/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */ -#ifndef EOVERFLOW -# define EOVERFLOW E2BIG -#endif - /* Print formatted output to string STR. Similar to vsprintf, but additional length SIZE limit how much is written into STR. Returns string length of formatted string (which may be larger than SIZE).
--- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -1,5 +1,5 @@ /* Formatted output to strings. - Copyright (C) 2004, 2006-2007 Free Software Foundation, Inc. + Copyright (C) 2004, 2006-2008 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 @@ -29,11 +29,6 @@ #include "vasnprintf.h" -/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */ -#ifndef EOVERFLOW -# define EOVERFLOW E2BIG -#endif - #ifndef SIZE_MAX # define SIZE_MAX ((size_t) -1) #endif
--- a/lib/xvasprintf.c +++ b/lib/xvasprintf.c @@ -1,5 +1,5 @@ /* vasprintf and asprintf with out-of-memory checking. - Copyright (C) 1999, 2002-2004, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 1999, 2002-2004, 2006-2008 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 @@ -29,11 +29,6 @@ /* Checked size_t computations. */ #include "xsize.h" -/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */ -#ifndef EOVERFLOW -# define EOVERFLOW E2BIG -#endif - static inline char * xstrcat (size_t argcount, va_list args) {
--- a/m4/fprintf-posix.m4 +++ b/m4/fprintf-posix.m4 @@ -1,4 +1,4 @@ -# fprintf-posix.m4 serial 10 +# fprintf-posix.m4 serial 11 dnl Copyright (C) 2007-2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,7 +6,6 @@ AC_DEFUN([gl_FUNC_FPRINTF_POSIX], [ - AC_REQUIRE([gl_EOVERFLOW]) AC_REQUIRE([gl_PRINTF_SIZES_C99]) AC_REQUIRE([gl_PRINTF_LONG_DOUBLE]) AC_REQUIRE([gl_PRINTF_INFINITE])
--- a/m4/snprintf-posix.m4 +++ b/m4/snprintf-posix.m4 @@ -1,4 +1,4 @@ -# snprintf-posix.m4 serial 11 +# snprintf-posix.m4 serial 12 dnl Copyright (C) 2007-2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,7 +6,6 @@ AC_DEFUN([gl_FUNC_SNPRINTF_POSIX], [ - AC_REQUIRE([gl_EOVERFLOW]) AC_REQUIRE([gl_PRINTF_SIZES_C99]) AC_REQUIRE([gl_PRINTF_LONG_DOUBLE]) AC_REQUIRE([gl_PRINTF_INFINITE])
--- a/m4/sprintf-posix.m4 +++ b/m4/sprintf-posix.m4 @@ -1,4 +1,4 @@ -# sprintf-posix.m4 serial 10 +# sprintf-posix.m4 serial 11 dnl Copyright (C) 2007-2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,7 +6,6 @@ AC_DEFUN([gl_FUNC_SPRINTF_POSIX], [ - AC_REQUIRE([gl_EOVERFLOW]) AC_REQUIRE([gl_PRINTF_SIZES_C99]) AC_REQUIRE([gl_PRINTF_LONG_DOUBLE]) AC_REQUIRE([gl_PRINTF_INFINITE])
--- a/m4/vasnprintf-posix.m4 +++ b/m4/vasnprintf-posix.m4 @@ -1,4 +1,4 @@ -# vasnprintf-posix.m4 serial 11 +# vasnprintf-posix.m4 serial 12 dnl Copyright (C) 2007-2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,7 +6,6 @@ AC_DEFUN([gl_FUNC_VASNPRINTF_POSIX], [ - AC_REQUIRE([gl_EOVERFLOW]) AC_REQUIRE([gl_PRINTF_SIZES_C99]) AC_REQUIRE([gl_PRINTF_LONG_DOUBLE]) AC_REQUIRE([gl_PRINTF_INFINITE])
--- a/m4/vasnprintf.m4 +++ b/m4/vasnprintf.m4 @@ -1,4 +1,4 @@ -# vasnprintf.m4 serial 24 +# vasnprintf.m4 serial 25 dnl Copyright (C) 2002-2004, 2006-2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,7 +6,6 @@ AC_DEFUN([gl_FUNC_VASNPRINTF], [ - AC_REQUIRE([gl_EOVERFLOW]) AC_CHECK_FUNCS_ONCE([vasnprintf]) if test $ac_cv_func_vasnprintf = no; then gl_REPLACE_VASNPRINTF
--- a/m4/vasprintf-posix.m4 +++ b/m4/vasprintf-posix.m4 @@ -1,4 +1,4 @@ -# vasprintf-posix.m4 serial 11 +# vasprintf-posix.m4 serial 12 dnl Copyright (C) 2007-2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,7 +6,6 @@ AC_DEFUN([gl_FUNC_VASPRINTF_POSIX], [ - AC_REQUIRE([gl_EOVERFLOW]) AC_REQUIRE([gl_PRINTF_SIZES_C99]) AC_REQUIRE([gl_PRINTF_LONG_DOUBLE]) AC_REQUIRE([gl_PRINTF_INFINITE])
--- a/m4/vfprintf-posix.m4 +++ b/m4/vfprintf-posix.m4 @@ -1,4 +1,4 @@ -# vfprintf-posix.m4 serial 10 +# vfprintf-posix.m4 serial 11 dnl Copyright (C) 2007-2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,7 +6,6 @@ AC_DEFUN([gl_FUNC_VFPRINTF_POSIX], [ - AC_REQUIRE([gl_EOVERFLOW]) AC_REQUIRE([gl_PRINTF_SIZES_C99]) AC_REQUIRE([gl_PRINTF_LONG_DOUBLE]) AC_REQUIRE([gl_PRINTF_INFINITE])
--- a/m4/vsnprintf-posix.m4 +++ b/m4/vsnprintf-posix.m4 @@ -1,4 +1,4 @@ -# vsnprintf-posix.m4 serial 11 +# vsnprintf-posix.m4 serial 12 dnl Copyright (C) 2007-2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,7 +6,6 @@ AC_DEFUN([gl_FUNC_VSNPRINTF_POSIX], [ - AC_REQUIRE([gl_EOVERFLOW]) AC_REQUIRE([gl_PRINTF_SIZES_C99]) AC_REQUIRE([gl_PRINTF_LONG_DOUBLE]) AC_REQUIRE([gl_PRINTF_INFINITE])
--- a/m4/vsprintf-posix.m4 +++ b/m4/vsprintf-posix.m4 @@ -1,4 +1,4 @@ -# vsprintf-posix.m4 serial 10 +# vsprintf-posix.m4 serial 11 dnl Copyright (C) 2007-2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,7 +6,6 @@ AC_DEFUN([gl_FUNC_VSPRINTF_POSIX], [ - AC_REQUIRE([gl_EOVERFLOW]) AC_REQUIRE([gl_PRINTF_SIZES_C99]) AC_REQUIRE([gl_PRINTF_LONG_DOUBLE]) AC_REQUIRE([gl_PRINTF_INFINITE])
new file mode 100644 --- /dev/null +++ b/modules/EOVERFLOW @@ -0,0 +1,22 @@ +Description: +EOVERFLOW macro + +Files: +m4/eoverflow.m4 + +Depends-on: + +configure.ac: +gl_EOVERFLOW + +Makefile.am: + +Include: +<errno.h> + +License: +LGPLv2+ + +Maintainer: +Bruno Haible +
new file mode 100644 --- /dev/null +++ b/modules/EOVERFLOW-tests @@ -0,0 +1,10 @@ +Files: +tests/test-EOVERFLOW.c + +Depends-on: + +configure.ac: + +Makefile.am: +TESTS += test-EOVERFLOW +check_PROGRAMS += test-EOVERFLOW
--- a/modules/fprintf-posix +++ b/modules/fprintf-posix @@ -20,6 +20,7 @@ fpucw nocrash printf-safe +EOVERFLOW configure.ac: gl_FUNC_FPRINTF_POSIX
--- a/modules/freadseek +++ b/modules/freadseek @@ -6,10 +6,12 @@ lib/freadseek.c Depends-on: +freadahead freadptr lseek configure.ac: +AC_REQUIRE([AC_C_INLINE]) Makefile.am: lib_SOURCES += freadseek.c
--- a/modules/ftell +++ b/modules/ftell @@ -8,6 +8,7 @@ Depends-on: ftello stdio +EOVERFLOW configure.ac: gl_FUNC_FTELL
--- a/modules/getdelim +++ b/modules/getdelim @@ -9,6 +9,7 @@ extensions stdio realloc-posix +EOVERFLOW configure.ac: gl_FUNC_GETDELIM
--- a/modules/getugroups +++ b/modules/getugroups @@ -7,6 +7,7 @@ m4/getugroups.m4 Depends-on: +EOVERFLOW configure.ac: gl_GETUGROUPS
--- a/modules/poll +++ b/modules/poll @@ -9,6 +9,7 @@ Depends-on: sys_select sys_time +EOVERFLOW configure.ac: gl_FUNC_POLL
--- a/modules/snprintf +++ b/modules/snprintf @@ -8,6 +8,7 @@ Depends-on: stdio vasnprintf +EOVERFLOW configure.ac: gl_FUNC_SNPRINTF
--- a/modules/sprintf-posix +++ b/modules/sprintf-posix @@ -20,6 +20,7 @@ nocrash printf-safe stdint +EOVERFLOW configure.ac: gl_FUNC_SPRINTF_POSIX
--- a/modules/unistdio/u16-u16-vasnprintf +++ b/modules/unistdio/u16-u16-vasnprintf @@ -12,7 +12,6 @@ m4/intmax_t.m4 m4/stdint_h.m4 m4/inttypes_h.m4 -m4/eoverflow.m4 Depends-on: unistdio/base @@ -42,6 +41,7 @@ alloca-opt localcharset xsize +EOVERFLOW configure.ac: gl_PREREQ_VASNPRINTF_WITH_EXTRAS
--- a/modules/unistdio/u16-u16-vasprintf +++ b/modules/unistdio/u16-u16-vasprintf @@ -8,6 +8,7 @@ Depends-on: unistdio/base unistdio/u16-u16-vasnprintf +EOVERFLOW configure.ac:
--- a/modules/unistdio/u16-u16-vsnprintf +++ b/modules/unistdio/u16-u16-vsnprintf @@ -9,6 +9,7 @@ unistdio/base unistdio/u16-u16-vasnprintf unistr/u16-cpy +EOVERFLOW configure.ac:
--- a/modules/unistdio/u16-u16-vsprintf +++ b/modules/unistdio/u16-u16-vsprintf @@ -9,6 +9,7 @@ unistdio/base unistdio/u16-u16-vasnprintf stdint +EOVERFLOW configure.ac:
--- a/modules/unistdio/u16-vasnprintf +++ b/modules/unistdio/u16-vasnprintf @@ -12,7 +12,6 @@ m4/intmax_t.m4 m4/stdint_h.m4 m4/inttypes_h.m4 -m4/eoverflow.m4 Depends-on: unistdio/base @@ -42,6 +41,7 @@ alloca-opt localcharset xsize +EOVERFLOW configure.ac: gl_PREREQ_VASNPRINTF_WITH_EXTRAS
--- a/modules/unistdio/u16-vasprintf +++ b/modules/unistdio/u16-vasprintf @@ -8,6 +8,7 @@ Depends-on: unistdio/base unistdio/u16-vasnprintf +EOVERFLOW configure.ac:
--- a/modules/unistdio/u16-vsnprintf +++ b/modules/unistdio/u16-vsnprintf @@ -9,6 +9,7 @@ unistdio/base unistdio/u16-vasnprintf unistr/u16-cpy +EOVERFLOW configure.ac:
--- a/modules/unistdio/u16-vsprintf +++ b/modules/unistdio/u16-vsprintf @@ -9,6 +9,7 @@ unistdio/base unistdio/u16-vasnprintf stdint +EOVERFLOW configure.ac:
--- a/modules/unistdio/u32-u32-vasnprintf +++ b/modules/unistdio/u32-u32-vasnprintf @@ -12,7 +12,6 @@ m4/intmax_t.m4 m4/stdint_h.m4 m4/inttypes_h.m4 -m4/eoverflow.m4 Depends-on: unistdio/base @@ -42,6 +41,7 @@ alloca-opt localcharset xsize +EOVERFLOW configure.ac: gl_PREREQ_VASNPRINTF_WITH_EXTRAS
--- a/modules/unistdio/u32-u32-vasprintf +++ b/modules/unistdio/u32-u32-vasprintf @@ -8,6 +8,7 @@ Depends-on: unistdio/base unistdio/u32-u32-vasnprintf +EOVERFLOW configure.ac:
--- a/modules/unistdio/u32-u32-vsnprintf +++ b/modules/unistdio/u32-u32-vsnprintf @@ -9,6 +9,7 @@ unistdio/base unistdio/u32-u32-vasnprintf unistr/u32-cpy +EOVERFLOW configure.ac:
--- a/modules/unistdio/u32-u32-vsprintf +++ b/modules/unistdio/u32-u32-vsprintf @@ -9,6 +9,7 @@ unistdio/base unistdio/u32-u32-vasnprintf stdint +EOVERFLOW configure.ac:
--- a/modules/unistdio/u32-vasnprintf +++ b/modules/unistdio/u32-vasnprintf @@ -12,7 +12,6 @@ m4/intmax_t.m4 m4/stdint_h.m4 m4/inttypes_h.m4 -m4/eoverflow.m4 Depends-on: unistdio/base @@ -42,6 +41,7 @@ alloca-opt localcharset xsize +EOVERFLOW configure.ac: gl_PREREQ_VASNPRINTF_WITH_EXTRAS
--- a/modules/unistdio/u32-vasprintf +++ b/modules/unistdio/u32-vasprintf @@ -8,6 +8,7 @@ Depends-on: unistdio/base unistdio/u32-vasnprintf +EOVERFLOW configure.ac:
--- a/modules/unistdio/u32-vsnprintf +++ b/modules/unistdio/u32-vsnprintf @@ -9,6 +9,7 @@ unistdio/base unistdio/u32-vasnprintf unistr/u32-cpy +EOVERFLOW configure.ac:
--- a/modules/unistdio/u32-vsprintf +++ b/modules/unistdio/u32-vsprintf @@ -9,6 +9,7 @@ unistdio/base unistdio/u32-vasnprintf stdint +EOVERFLOW configure.ac:
--- a/modules/unistdio/u8-u8-vasnprintf +++ b/modules/unistdio/u8-u8-vasnprintf @@ -12,7 +12,6 @@ m4/intmax_t.m4 m4/stdint_h.m4 m4/inttypes_h.m4 -m4/eoverflow.m4 Depends-on: unistdio/base @@ -42,6 +41,7 @@ alloca-opt localcharset xsize +EOVERFLOW configure.ac: gl_PREREQ_VASNPRINTF_WITH_EXTRAS
--- a/modules/unistdio/u8-u8-vasprintf +++ b/modules/unistdio/u8-u8-vasprintf @@ -8,6 +8,7 @@ Depends-on: unistdio/base unistdio/u8-u8-vasnprintf +EOVERFLOW configure.ac:
--- a/modules/unistdio/u8-u8-vsnprintf +++ b/modules/unistdio/u8-u8-vsnprintf @@ -9,6 +9,7 @@ unistdio/base unistdio/u8-u8-vasnprintf unistr/u8-cpy +EOVERFLOW configure.ac:
--- a/modules/unistdio/u8-u8-vsprintf +++ b/modules/unistdio/u8-u8-vsprintf @@ -9,6 +9,7 @@ unistdio/base unistdio/u8-u8-vasnprintf stdint +EOVERFLOW configure.ac:
--- a/modules/unistdio/u8-vasnprintf +++ b/modules/unistdio/u8-vasnprintf @@ -12,7 +12,6 @@ m4/intmax_t.m4 m4/stdint_h.m4 m4/inttypes_h.m4 -m4/eoverflow.m4 Depends-on: unistdio/base @@ -42,6 +41,7 @@ alloca-opt localcharset xsize +EOVERFLOW configure.ac: gl_PREREQ_VASNPRINTF_WITH_EXTRAS
--- a/modules/unistdio/u8-vasprintf +++ b/modules/unistdio/u8-vasprintf @@ -8,6 +8,7 @@ Depends-on: unistdio/base unistdio/u8-vasnprintf +EOVERFLOW configure.ac:
--- a/modules/unistdio/u8-vsnprintf +++ b/modules/unistdio/u8-vsnprintf @@ -9,6 +9,7 @@ unistdio/base unistdio/u8-vasnprintf unistr/u8-cpy +EOVERFLOW configure.ac:
--- a/modules/unistdio/u8-vsprintf +++ b/modules/unistdio/u8-vsprintf @@ -9,6 +9,7 @@ unistdio/base unistdio/u8-vasnprintf stdint +EOVERFLOW configure.ac:
--- a/modules/unistdio/ulc-fprintf +++ b/modules/unistdio/ulc-fprintf @@ -8,6 +8,7 @@ unistdio/base unistdio/ulc-vasnprintf fseterr +EOVERFLOW configure.ac:
--- a/modules/unistdio/ulc-vasnprintf +++ b/modules/unistdio/ulc-vasnprintf @@ -12,7 +12,6 @@ m4/intmax_t.m4 m4/stdint_h.m4 m4/inttypes_h.m4 -m4/eoverflow.m4 Depends-on: unistdio/base @@ -40,6 +39,7 @@ alloca-opt localcharset xsize +EOVERFLOW configure.ac: gl_PREREQ_VASNPRINTF_WITH_EXTRAS
--- a/modules/unistdio/ulc-vasprintf +++ b/modules/unistdio/ulc-vasprintf @@ -8,6 +8,7 @@ Depends-on: unistdio/base unistdio/ulc-vasnprintf +EOVERFLOW configure.ac:
--- a/modules/unistdio/ulc-vfprintf +++ b/modules/unistdio/ulc-vfprintf @@ -8,6 +8,7 @@ unistdio/base unistdio/ulc-vasnprintf fseterr +EOVERFLOW configure.ac:
--- a/modules/unistdio/ulc-vsnprintf +++ b/modules/unistdio/ulc-vsnprintf @@ -8,6 +8,7 @@ Depends-on: unistdio/base unistdio/ulc-vasnprintf +EOVERFLOW configure.ac:
--- a/modules/unistdio/ulc-vsprintf +++ b/modules/unistdio/ulc-vsprintf @@ -9,6 +9,7 @@ unistdio/base unistdio/ulc-vasnprintf stdint +EOVERFLOW configure.ac:
--- a/modules/vasnprintf +++ b/modules/vasnprintf @@ -16,7 +16,6 @@ m4/intmax_t.m4 m4/stdint_h.m4 m4/inttypes_h.m4 -m4/eoverflow.m4 m4/vasnprintf.m4 Depends-on: @@ -24,6 +23,7 @@ float stdint xsize +EOVERFLOW configure.ac: gl_FUNC_VASNPRINTF
--- a/modules/vasprintf +++ b/modules/vasprintf @@ -15,6 +15,7 @@ extensions vasnprintf stdio +EOVERFLOW configure.ac: gl_FUNC_VASPRINTF
--- a/modules/vfprintf-posix +++ b/modules/vfprintf-posix @@ -20,6 +20,7 @@ fpucw nocrash printf-safe +EOVERFLOW configure.ac: gl_FUNC_VFPRINTF_POSIX
--- a/modules/vsnprintf +++ b/modules/vsnprintf @@ -9,6 +9,7 @@ Depends-on: stdio vasnprintf +EOVERFLOW configure.ac: gl_FUNC_VSNPRINTF
--- a/modules/vsprintf-posix +++ b/modules/vsprintf-posix @@ -20,6 +20,7 @@ nocrash printf-safe stdint +EOVERFLOW configure.ac: gl_FUNC_VSPRINTF_POSIX
--- a/modules/xvasprintf +++ b/modules/xvasprintf @@ -17,6 +17,7 @@ xalloc-die xsize stdarg +EOVERFLOW configure.ac: gl_XVASPRINTF
new file mode 100644 --- /dev/null +++ b/tests/test-EOVERFLOW.c @@ -0,0 +1,32 @@ +/* Test of EOVERFLOW macro. + Copyright (C) 2008 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 + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <errno.h> + +/* Check that it can be used as an initializer outside of a function. */ +static int err = EOVERFLOW; + +int +main () +{ + /* snprintf() callers want to distinguish EINVAL and EOVERFLOW. */ + if (err == EINVAL) + return 1; + + return 0; +}
--- a/tests/test-strtod.c +++ b/tests/test-strtod.c @@ -143,10 +143,10 @@ } { errno = 0; - const char input[] = ".1"; + const char input[] = ".5"; char *ptr; double result = strtod (input, &ptr); - ASSERT (result == 0.1); + ASSERT (result == 0.5); ASSERT (ptr == input + 2); ASSERT (errno == 0); } @@ -215,10 +215,10 @@ } { errno = 0; - const char input[] = "1e-1"; + const char input[] = "5e-1"; char *ptr; double result = strtod (input, &ptr); - ASSERT (result == 0.1); + ASSERT (result == 0.5); ASSERT (ptr == input + 4); ASSERT (errno == 0); } @@ -443,7 +443,7 @@ /* Overflow/underflow. */ { errno = 0; - const char input[] = "1E100000"; + const char input[] = "1E1000000"; char *ptr; double result = strtod (input, &ptr); ASSERT (result == HUGE_VAL); @@ -452,7 +452,7 @@ } { errno = 0; - const char input[] = "-1E100000"; + const char input[] = "-1E1000000"; char *ptr; double result = strtod (input, &ptr); ASSERT (result == -HUGE_VAL); @@ -475,7 +475,13 @@ char *ptr; double result = strtod (input, &ptr); ASSERT (-FLT_MIN <= result && result <= 0.0); +#if 0 + /* FIXME - this is glibc bug 5995; POSIX allows returning positive + 0 on negative underflow, even though quality of implementation + demands preserving the sign. Disable this test until fixed + glibc is more prevalent. */ ASSERT (signbit (result) == signbit (-0.0)); +#endif ASSERT (ptr == input + 10); ASSERT (errno == ERANGE); } @@ -539,7 +545,11 @@ #ifdef NAN ASSERT (isnan (result1)); ASSERT (isnan (result2)); +# if 0 + /* Sign bits of NaN is a portability sticking point, not worth + worrying about. */ ASSERT (signbit (result1) != signbit (result2)); +# endif ASSERT (ptr1 == input + 4); ASSERT (ptr2 == input + 4); ASSERT (errno == 0); @@ -587,7 +597,11 @@ #ifdef NAN ASSERT (isnan (result1)); ASSERT (isnan (result2)); +# if 0 + /* Sign bits of NaN is a portability sticking point, not worth + worrying about. */ ASSERT (signbit (result1) != signbit (result2)); +# endif ASSERT (ptr1 == input + 6); ASSERT (ptr2 == input + 6); ASSERT (errno == 0); @@ -630,7 +644,11 @@ #ifdef NAN ASSERT (isnan (result1)); ASSERT (isnan (result2)); +# if 0 + /* Sign bits of NaN is a portability sticking point, not worth + worrying about. */ ASSERT (signbit (result1) != signbit (result2)); +# endif ASSERT (ptr1 == input + 7); ASSERT (ptr2 == input + 7); ASSERT (errno == 0);