diff options
46 files changed, 1677 insertions, 67 deletions
@@ -1,7 +1,129 @@ +2007-09-17 Jakub Jelinek <jakub@redhat.com> + + * include/stdio.h (__isoc99_fscanf, __isoc99_scanf, + __isoc99_sscanf, __isoc99_vscanf): New prototypes. + (__isoc99_vsscanf, __isoc99_vfscanf): New prototypes, add + libc_hidden_proto. + * include/wchar.h (__isoc99_fwscanf, __isoc99_wscanf, + __isoc99_swscanf, __isoc99_vwscanf): New prototypes. + (__isoc99_vswscanf, __isoc99_vfwscanf): New prototypes, + add libc_hidden_proto. + * libio/stdio.h (fscanf, scanf, sscanf, vfscanf, vscanf, + vsscanf): Redirect to __isoc99_* if strict ISO C99 or POSIX + conformance requested. + * wcsmbs/wchar.h (fwscanf, wscanf, swscanf, vfwscanf, vwscanf, + vswscanf): Redirect to __isoc99_* if strict ISO C99 or POSIX + conformance requested. + * libio/bits/stdio-ldbl.h (fscanf, scanf, sscanf, vfscanf, vscanf, + vsscanf): Redirect to __nldbl___isoc99_* if strict ISO C99 or POSIX + conformance requested. + * wcsmbs/bits/wchar-ldbl.h (fwscanf, wscanf, swscanf, vfwscanf, + vwscanf, vswscanf): Redirect to __nldbl___isoc99_* if strict + ISO C99 or POSIX conformance requested. + * stdio-common/Versions (libc): Export __isoc99_scanf@@GLIBC_2.7, + __isoc99_vscanf@@GLIBC_2.7, __isoc99_fscanf@@GLIBC_2.7, + __isoc99_vfscanf@@GLIBC_2.7, __isoc99_sscanf@@GLIBC_2.7 + and __isoc99_vsscanf@@GLIBC_2.7. + * stdio-common/Makefile (routines): Add isoc99_scanf, isoc99_vscanf, + isoc99_fscanf, isoc99_vfscanf, isoc99_sscanf and isoc99_vsscanf. + (tests): Add scanf14. + (CFLAGS-vfprintf.c, CFLAGS-fprintf.c, CFLAGS-printf.c, + CFLAGS-vfwprintf.c, CFLAGS-vfscanf.c, CFLAGS-vfwscanf.c, + CFLAGS-fscanf.c, CFLAGS-scanf.c, CFLAGS-isoc99_vfscanf.c, + CFLAGS-isoc99_vscanf.c, CFLAGS-isoc99_fscanf.c, + CFLAGS-isoc99_scanf.c): Add $(exceptions). + (CFLAGS-scanf15.c): Add various -I paths to prevent the compiler + from using internal headers. + * wcsmbs/Versions (libc): Export __isoc99_wscanf@@GLIBC_2.7, + __isoc99_vwscanf@@GLIBC_2.7, __isoc99_fwscanf@@GLIBC_2.7, + __isoc99_vfwscanf@@GLIBC_2.7, __isoc99_swscanf@@GLIBC_2.7 + and __isoc99_vswscanf@@GLIBC_2.7. + * wcsmbs/Makefile (routines): Add isoc99_wscanf, isoc99_vwscanf, + isoc99_fwscanf, isoc99_vfwscanf, isoc99_swscanf and isoc99_vswscanf. + (CFLAGS-isoc99_wscanf.c, CFLAGS-isoc99_fwscanf.c, + CFLAGS-isoc99_vwscanf.c, CFLAGS-isoc99_vfwscanf.c): Add $(exceptions). + (CPPFLAGS): Add -D_IO_MTSAFE_IO if needed. + * stdio-common/isoc99_scanf.c: New file. + * stdio-common/isoc99_vsscanf.c: New file. + * stdio-common/isoc99_vscanf.c: New file. + * stdio-common/isoc99_vfscanf.c: New file. + * stdio-common/isoc99_fscanf.c: New file. + * stdio-common/isoc99_sscanf.c: New file. + * wcsmbs/isoc99_fwscanf.c: New file. + * wcsmbs/isoc99_vswscanf.c: New file. + * wcsmbs/isoc99_swscanf.c: New file. + * wcsmbs/isoc99_wscanf.c: New file. + * wcsmbs/isoc99_vwscanf.c: New file. + * wcsmbs/isoc99_vfwscanf.c: New file. + * libio/libio.h (_IO_FLAGS2_SCANF_STD): Define. + * libio/libioP.h (_IO_acquire_lock_clear_flags2_fct): Also + clear _IO_FLAGS2_SCANF_STD bit from _flags2. + * stdio-common/vfscanf.c (_IO_vfscanf_internal): Don't + handle %as, %aS and %a[ if _IO_FLAGS2_SCANF_STD is set in _flags2. + * stdio-common/scanf14.c: New test. + * stdio-common/scanf15.c: New test. + * sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add + isoc99_scanf, isoc99_fscanf, isoc99_sscanf, + isoc99_vscanf, isoc99_vfscanf, isoc99_vsscanf, + isoc99_wscanf, isoc99_fwscanf, isoc99_swscanf, + isoc99_vwscanf, isoc99_vfwscanf and isoc99_vswscanf. + * sysdeps/ieee754/ldbl-opt/Versions (libc): Export + __nldbl___isoc99_scanf@@GLIBC_2.7, + __nldbl___isoc99_fscanf@@GLIBC_2.7, + __nldbl___isoc99_sscanf@@GLIBC_2.7, + __nldbl___isoc99_vscanf@@GLIBC_2.7, + __nldbl___isoc99_vfscanf@@GLIBC_2.7, + __nldbl___isoc99_vsscanf@@GLIBC_2.7, + __nldbl___isoc99_wscanf@@GLIBC_2.7, + __nldbl___isoc99_fwscanf@@GLIBC_2.7, + __nldbl___isoc99_swscanf@@GLIBC_2.7, + __nldbl___isoc99_vwscanf@@GLIBC_2.7, + __nldbl___isoc99_vfwscanf@@GLIBC_2.7 + and __nldbl___isoc99_vswscanf@@GLIBC_2.7. + * sysdeps/ieee754/ldbl-opt/nldbl-compat.h (__isoc99_scanf, + __isoc99_fscanf, __isoc99_sscanf, __isoc99_vscanf, + __isoc99_vfscanf, __isoc99_vsscanf, __isoc99_wscanf, + __isoc99_fwscanf, __isoc99_swscanf, __isoc99_vwscanf, + __isoc99_vfwscanf, __isoc99_vswscanf): Add NLDBL_DECL. + * sysdeps/ieee754/ldbl-opt/nldbl-compat.c + (__nldbl___isoc99_scanf, __nldbl___isoc99_fscanf, + __nldbl___isoc99_sscanf, __nldbl___isoc99_vscanf, + __nldbl___isoc99_vfscanf, __nldbl___isoc99_vsscanf, + __nldbl___isoc99_wscanf, __nldbl___isoc99_fwscanf, + __nldbl___isoc99_swscanf, __nldbl___isoc99_vwscanf, + __nldbl___isoc99_vfwscanf, __nldbl___isoc99_vswscanf): New + functions. + * sysdeps/ieee754/ldbl-opt/nldbl-isoc99_vfscanf.c: New file. + * sysdeps/ieee754/ldbl-opt/nldbl-isoc99_swscanf.c: New file. + * sysdeps/ieee754/ldbl-opt/nldbl-isoc99_vwscanf.c: New file. + * sysdeps/ieee754/ldbl-opt/nldbl-isoc99_wscanf.c: New file. + * sysdeps/ieee754/ldbl-opt/nldbl-isoc99_scanf.c: New file. + * sysdeps/ieee754/ldbl-opt/nldbl-isoc99_sscanf.c: New file. + * sysdeps/ieee754/ldbl-opt/nldbl-isoc99_vsscanf.c: New file. + * sysdeps/ieee754/ldbl-opt/nldbl-isoc99_fwscanf.c: New file. + * sysdeps/ieee754/ldbl-opt/nldbl-isoc99_vfwscanf.c: New file. + * sysdeps/ieee754/ldbl-opt/nldbl-isoc99_vswscanf.c: New file. + * sysdeps/ieee754/ldbl-opt/nldbl-isoc99_vscanf.c: New file. + * sysdeps/ieee754/ldbl-opt/nldbl-isoc99_fscanf.c: New file. + + * stdio-common/Makefile (tests): Add scanf13. + (scanf13-ENV): New. + * stdio-common/vfscanf.c (_IO_vfscanf_internal): Handle + m modifier followed by l. + (STRING_ARG): Add width argument. + (_IO_vfscanf_internal) <case L_('c')>: Handle %mc. + <case L_('C')>: Handle %mlc and %mC. + <case L_('s'), case L_('S'), case L_('[')>: Adjust STRING_ARG + arguments. + * stdio-common/scanf13.c: New test. + + * libio/libioP.h (_IO_acquire_lock_clear_flags2_fct): Clear + the _IO_FLAGS2_FORTIFY bit from _flags2 rather than _flags. + 2007-09-18 Ulrich Drepper <drepper@redhat.com> * sysdeps/unix/sysv/linux/i386/bits/fcntl.h: Correct return value - type __THROW marker of splice, vmsplice, and tee. + type and __THROW marker of splice, vmsplice, and tee. * sysdeps/unix/sysv/linux/ia64/bits/fcntl.h: Likewise. * sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h: Likewise. * sysdeps/unix/sysv/linux/s390/bits/fcntl.h: Likewise. diff --git a/include/stdio.h b/include/stdio.h index 4b30e6a359..084c02ea1e 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -43,6 +43,22 @@ extern char *__fgets_unlocked_chk (char *buf, size_t size, int n, FILE *fp); extern char *__fgets_chk (char *buf, size_t size, int n, FILE *fp); #endif +extern int __isoc99_fscanf (FILE *__restrict __stream, + __const char *__restrict __format, ...) __wur; +extern int __isoc99_scanf (__const char *__restrict __format, ...) __wur; +extern int __isoc99_sscanf (__const char *__restrict __s, + __const char *__restrict __format, ...) __THROW; +extern int __isoc99_vfscanf (FILE *__restrict __s, + __const char *__restrict __format, + _G_va_list __arg) __wur; +extern int __isoc99_vscanf (__const char *__restrict __format, + _G_va_list __arg) __wur; +extern int __isoc99_vsscanf (__const char *__restrict __s, + __const char *__restrict __format, + _G_va_list __arg) __THROW; +libc_hidden_proto (__isoc99_vsscanf) +libc_hidden_proto (__isoc99_vfscanf) + /* Prototypes for compatibility functions. */ extern FILE *__new_tmpfile (void); extern FILE *__old_tmpfile (void); diff --git a/include/wchar.h b/include/wchar.h index 7651f6de29..bca847731d 100644 --- a/include/wchar.h +++ b/include/wchar.h @@ -166,6 +166,23 @@ libc_hidden_proto (__vfwprintf_chk) libc_hidden_proto (__vswprintf_chk) #endif +extern int __isoc99_fwscanf (__FILE *__restrict __stream, + __const wchar_t *__restrict __format, ...); +extern int __isoc99_wscanf (__const wchar_t *__restrict __format, ...); +extern int __isoc99_swscanf (__const wchar_t *__restrict __s, + __const wchar_t *__restrict __format, ...) + __THROW; +extern int __isoc99_vfwscanf (__FILE *__restrict __s, + __const wchar_t *__restrict __format, + __gnuc_va_list __arg); +extern int __isoc99_vwscanf (__const wchar_t *__restrict __format, + __gnuc_va_list __arg); +extern int __isoc99_vswscanf (__const wchar_t *__restrict __s, + __const wchar_t *__restrict __format, + __gnuc_va_list __arg) __THROW; +libc_hidden_proto (__isoc99_vswscanf) +libc_hidden_proto (__isoc99_vfwscanf) + /* Internal functions. */ extern size_t __mbsrtowcs_l (wchar_t *dst, const char **src, size_t len, mbstate_t *ps, __locale_t l) attribute_hidden; diff --git a/inet/tst-network.c b/inet/tst-network.c index 564a366a44..5491740e37 100644 --- a/inet/tst-network.c +++ b/inet/tst-network.c @@ -34,7 +34,10 @@ struct {"1.0", 0x100}, {"1", 0x1}, {"192.168.0.0", 0xC0A80000}, + {"0", 0}, + {"0x0", 0}, /* Now some invalid addresses. */ + {"0x", INADDR_NONE}, {"141.30.225.2800", INADDR_NONE}, {"141.76.1.1.1", INADDR_NONE}, {"141.76.1.11.", INADDR_NONE}, diff --git a/libio/bits/stdio-ldbl.h b/libio/bits/stdio-ldbl.h index b6ec7f3c92..c93e6c48fb 100644 --- a/libio/bits/stdio-ldbl.h +++ b/libio/bits/stdio-ldbl.h @@ -28,9 +28,17 @@ __LDBL_REDIR_DECL (sprintf) __LDBL_REDIR_DECL (vfprintf) __LDBL_REDIR_DECL (vprintf) __LDBL_REDIR_DECL (vsprintf) +#if defined __USE_ISOC99 && !defined __USE_GNU \ + && !defined __REDIRECT \ + && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K) +__LDBL_REDIR1_DECL (fscanf, __nldbl___isoc99_fscanf) +__LDBL_REDIR1_DECL (scanf, __nldbl___isoc99_scanf) +__LDBL_REDIR1_DECL (sscanf, __nldbl___isoc99_sscanf) +#else __LDBL_REDIR_DECL (fscanf) __LDBL_REDIR_DECL (scanf) __LDBL_REDIR_DECL (sscanf) +#endif __END_NAMESPACE_STD #if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98 @@ -42,9 +50,16 @@ __END_NAMESPACE_C99 #ifdef __USE_ISOC99 __BEGIN_NAMESPACE_C99 +# if !defined __USE_GNU && !defined __REDIRECT \ + && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K) +__LDBL_REDIR1_DECL (vfscanf, __nldbl___isoc99_vfscanf) +__LDBL_REDIR1_DECL (vscanf, __nldbl___isoc99_vscanf) +__LDBL_REDIR1_DECL (vsscanf, __nldbl___isoc99_vsscanf) +# else __LDBL_REDIR_DECL (vfscanf) __LDBL_REDIR_DECL (vsscanf) __LDBL_REDIR_DECL (vscanf) +# endif __END_NAMESPACE_C99 #endif diff --git a/libio/libio.h b/libio/libio.h index a807883856..643812f72b 100644 --- a/libio/libio.h +++ b/libio/libio.h @@ -143,6 +143,9 @@ # define _IO_FLAGS2_FORTIFY 4 #endif #define _IO_FLAGS2_USER_WBUF 8 +#ifdef _LIBC +# define _IO_FLAGS2_SCANF_STD 16 +#endif /* These are "formatting flags" matching the iostream fmtflags enum values. */ #define _IO_SKIPWS 01 diff --git a/libio/libioP.h b/libio/libioP.h index b99b81743f..854f049291 100644 --- a/libio/libioP.h +++ b/libio/libioP.h @@ -974,7 +974,7 @@ __attribute__ ((__always_inline__)) _IO_acquire_lock_clear_flags2_fct (_IO_FILE **p) { _IO_FILE *fp = *p; - fp->_flags &= ~_IO_FLAGS2_FORTIFY; + fp->_flags2 &= ~(_IO_FLAGS2_FORTIFY | _IO_FLAGS2_SCANF_STD); if ((fp->_flags & _IO_USER_LOCK) == 0) _IO_funlockfile (fp); } diff --git a/libio/stdio.h b/libio/stdio.h index c1ba9b2235..47c6cb0a90 100644 --- a/libio/stdio.h +++ b/libio/stdio.h @@ -410,6 +410,34 @@ extern int scanf (__const char *__restrict __format, ...) __wur; /* Read formatted input from S. */ extern int sscanf (__const char *__restrict __s, __const char *__restrict __format, ...) __THROW; + +#if defined __USE_ISOC99 && !defined __USE_GNU \ + && (!defined __LDBL_COMPAT || !defined __REDIRECT) \ + && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K) +# ifdef __REDIRECT +/* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[ + GNU extension which conflicts with valid %a followed by letter + s, S or [. */ +extern int __REDIRECT (fscanf, (FILE *__restrict __stream, + __const char *__restrict __format, ...), + __isoc99_fscanf) __wur; +extern int __REDIRECT (scanf, (__const char *__restrict __format, ...), + __isoc99_scanf) __wur; +extern int __REDIRECT (sscanf, (__const char *__restrict __s, + __const char *__restrict __format, ...), + __isoc99_sscanf) __THROW; +# else +extern int __isoc99_fscanf (FILE *__restrict __stream, + __const char *__restrict __format, ...) __wur; +extern int __isoc99_scanf (__const char *__restrict __format, ...) __wur; +extern int __isoc99_sscanf (__const char *__restrict __s, + __const char *__restrict __format, ...) __THROW; +# define fscanf __isoc99_fscanf +# define scanf __isoc99_scanf +# define sscanf __isoc99_sscanf +# endif +#endif + __END_NAMESPACE_STD #ifdef __USE_ISOC99 @@ -433,6 +461,42 @@ extern int vscanf (__const char *__restrict __format, _G_va_list __arg) extern int vsscanf (__const char *__restrict __s, __const char *__restrict __format, _G_va_list __arg) __THROW __attribute__ ((__format__ (__scanf__, 2, 0))); + +# if !defined __USE_GNU \ + && (!defined __LDBL_COMPAT || !defined __REDIRECT) \ + && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K) +# ifdef __REDIRECT +/* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[ + GNU extension which conflicts with valid %a followed by letter + s, S or [. */ +extern int __REDIRECT (vfscanf, + (FILE *__restrict __s, + __const char *__restrict __format, _G_va_list __arg), + __isoc99_vfscanf) + __attribute__ ((__format__ (__scanf__, 2, 0))) __wur; +extern int __REDIRECT (vscanf, (__const char *__restrict __format, + _G_va_list __ar |
