From 874aa52349cc111d1f6ea5dff24bb14c306714e0 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 18 Sep 2007 19:04:01 +0000 Subject: * 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) : Handle %mc. : Handle %mlc and %mC. : 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. type and __THROW marker of splice, vmsplice, and tee. --- libio/bits/stdio-ldbl.h | 15 ++++++++++++ libio/libio.h | 3 +++ libio/libioP.h | 2 +- libio/stdio.h | 64 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 1 deletion(-) (limited to 'libio') 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 __arg), __isoc99_vfscanf) + __attribute__ ((__format__ (__scanf__, 1, 0))) __wur; +extern int __REDIRECT (vsscanf, + (__const char *__restrict __s, + __const char *__restrict __format, _G_va_list __arg), + __isoc99_vsscanf) + __THROW __attribute__ ((__format__ (__scanf__, 2, 0))); +# else +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; +# define vfscanf __isoc99_vfscanf +# define vscanf __isoc99_vsscanf +# define vsscanf __isoc99_vsscanf +# endif +# endif + __END_NAMESPACE_C99 #endif /* Use ISO C9x. */ -- cgit 1.4.1