diff options
Diffstat (limited to 'wcsmbs')
-rw-r--r-- | wcsmbs/Makefile | 14 | ||||
-rw-r--r-- | wcsmbs/Versions | 4 | ||||
-rw-r--r-- | wcsmbs/bits/wchar-ldbl.h | 17 | ||||
-rw-r--r-- | wcsmbs/isoc99_fwscanf.c | 41 | ||||
-rw-r--r-- | wcsmbs/isoc99_swscanf.c | 38 | ||||
-rw-r--r-- | wcsmbs/isoc99_vfwscanf.c | 36 | ||||
-rw-r--r-- | wcsmbs/isoc99_vswscanf.c | 49 | ||||
-rw-r--r-- | wcsmbs/isoc99_vwscanf.c | 35 | ||||
-rw-r--r-- | wcsmbs/isoc99_wscanf.c | 43 | ||||
-rw-r--r-- | wcsmbs/wchar.h | 62 |
10 files changed, 335 insertions, 4 deletions
diff --git a/wcsmbs/Makefile b/wcsmbs/Makefile index 7a289a8dc7..4afbc4cac4 100644 --- a/wcsmbs/Makefile +++ b/wcsmbs/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1995-2000,2002,2003,2004,2005,2006 +# Copyright (C) 1995-2000,2002,2003,2004,2005,2006,2007 # Free Software Foundation, Inc. # This file is part of the GNU C Library. @@ -38,7 +38,9 @@ routines := wcscat wcschr wcscmp wcscpy wcscspn wcsdup wcslen wcsncat \ wcwidth wcswidth \ wcscoll_l wcsxfrm_l \ wcscasecmp wcsncase wcscasecmp_l wcsncase_l \ - wcsmbsload mbsrtowcs_l + wcsmbsload mbsrtowcs_l \ + isoc99_wscanf isoc99_vwscanf isoc99_fwscanf isoc99_vfwscanf \ + isoc99_swscanf isoc99_vswscanf tests := tst-wcstof wcsmbs-tst1 tst-wcsnlen tst-btowc tst-mbrtowc \ tst-wcrtomb tst-wcpncpy tst-mbsrtowcs tst-wchar-h tst-mbrtowc2 @@ -65,6 +67,14 @@ CFLAGS-wcstold_l.c = $(strtox-CFLAGS) CFLAGS-wcstof_l.c = $(strtox-CFLAGS) CFLAGS-tst-wchar-h.c = -D_FORTIFY_SOURCE=2 +CFLAGS-isoc99_wscanf.c += $(exceptions) +CFLAGS-isoc99_fwscanf.c += $(exceptions) +CFLAGS-isoc99_vwscanf.c += $(exceptions) +CFLAGS-isoc99_vfwscanf.c += $(exceptions) +ifneq (,$(filter %REENTRANT, $(defines))) +CPPFLAGS += -D_IO_MTSAFE_IO +endif + # We need to find the default version of strtold_l in stdlib. CPPFLAGS-wcstold_l.c = -I../stdlib diff --git a/wcsmbs/Versions b/wcsmbs/Versions index 6f2e72eb2a..b6dfa85a40 100644 --- a/wcsmbs/Versions +++ b/wcsmbs/Versions @@ -24,4 +24,8 @@ libc { # w* wcschrnul; wmempcpy; } + GLIBC_2.7 { + __isoc99_wscanf; __isoc99_vwscanf; __isoc99_fwscanf; __isoc99_vfwscanf; + __isoc99_swscanf; __isoc99_vswscanf; + } } diff --git a/wcsmbs/bits/wchar-ldbl.h b/wcsmbs/bits/wchar-ldbl.h index f398aecc65..80a6a684ab 100644 --- a/wcsmbs/bits/wchar-ldbl.h +++ b/wcsmbs/bits/wchar-ldbl.h @@ -21,7 +21,7 @@ # error "Never include <bits/wchar-ldbl.h> directly; use <wchar.h> instead." #endif -#if defined __USE_ISOC99 || defined __USE_UNIX98 +#if defined __USE_ISOC95 || defined __USE_UNIX98 __BEGIN_NAMESPACE_C99 __LDBL_REDIR_DECL (fwprintf); __LDBL_REDIR_DECL (wprintf); @@ -29,18 +29,33 @@ __LDBL_REDIR_DECL (swprintf); __LDBL_REDIR_DECL (vfwprintf); __LDBL_REDIR_DECL (vwprintf); __LDBL_REDIR_DECL (vswprintf); +# if defined __USE_ISOC99 && !defined __USE_GNU \ + && !defined __REDIRECT \ + && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K) +__LDBL_REDIR1_DECL (fwscanf, __nldbl___isoc99_fwscanf) +__LDBL_REDIR1_DECL (wscanf, __nldbl___isoc99_wscanf) +__LDBL_REDIR1_DECL (swscanf, __nldbl___isoc99_swscanf) +# else __LDBL_REDIR_DECL (fwscanf); __LDBL_REDIR_DECL (wscanf); __LDBL_REDIR_DECL (swscanf); +# endif __END_NAMESPACE_C99 #endif #ifdef __USE_ISOC99 __BEGIN_NAMESPACE_C99 __LDBL_REDIR1_DECL (wcstold, wcstod); +# if !defined __USE_GNU && !defined __REDIRECT \ + && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K) +__LDBL_REDIR1_DECL (vfwscanf, __nldbl___isoc99_vfwscanf) +__LDBL_REDIR1_DECL (vwscanf, __nldbl___isoc99_vwscanf) +__LDBL_REDIR1_DECL (vswscanf, __nldbl___isoc99_vswscanf) +# else __LDBL_REDIR_DECL (vfwscanf); __LDBL_REDIR_DECL (vwscanf); __LDBL_REDIR_DECL (vswscanf); +# endif __END_NAMESPACE_C99 #endif diff --git a/wcsmbs/isoc99_fwscanf.c b/wcsmbs/isoc99_fwscanf.c new file mode 100644 index 0000000000..ce12ad8f90 --- /dev/null +++ b/wcsmbs/isoc99_fwscanf.c @@ -0,0 +1,41 @@ +/* Copyright (C) 1991, 1997, 2006, 2007 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <libioP.h> +#include <stdarg.h> +#include <stdio.h> +#include <wchar.h> + +/* Read formatted input from STREAM according to the format string FORMAT. */ +/* VARARGS2 */ +int +__isoc99_fwscanf (FILE *stream, const wchar_t *format, ...) +{ + va_list arg; + int done; + + _IO_acquire_lock_clear_flags2 (stream); + stream->_flags2 |= _IO_FLAGS2_SCANF_STD; + + va_start (arg, format); + done = _IO_vfwscanf (stream, format, arg, NULL); + va_end (arg); + + _IO_release_lock (stream); + return done; +} diff --git a/wcsmbs/isoc99_swscanf.c b/wcsmbs/isoc99_swscanf.c new file mode 100644 index 0000000000..fed05eff35 --- /dev/null +++ b/wcsmbs/isoc99_swscanf.c @@ -0,0 +1,38 @@ +/* Copyright (C) 1991, 1995, 1996, 1998, 2002, 2003, 2004, 2006, 2007 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <stdarg.h> +#include <stdio.h> +#include <libioP.h> +#include <wchar.h> + +/* Read formatted input from S, according to the format string FORMAT. */ +/* VARARGS2 */ +int +__isoc99_swscanf (const wchar_t *s, const wchar_t *format, ...) +{ + va_list arg; + int done; + + va_start (arg, format); + done = __isoc99_vswscanf (s, format, arg); + va_end (arg); + + return done; +} diff --git a/wcsmbs/isoc99_vfwscanf.c b/wcsmbs/isoc99_vfwscanf.c new file mode 100644 index 0000000000..7564503e88 --- /dev/null +++ b/wcsmbs/isoc99_vfwscanf.c @@ -0,0 +1,36 @@ +/* Copyright (C) 1991, 1997, 2006, 2007 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <libioP.h> +#include <stdio.h> +#include <wchar.h> + +/* Read formatted input from STREAM according to the format string FORMAT. */ +/* VARARGS2 */ +int +__isoc99_vfwscanf (FILE *stream, const wchar_t *format, _IO_va_list args) +{ + int done; + + _IO_acquire_lock_clear_flags2 (stream); + stream->_flags2 |= _IO_FLAGS2_SCANF_STD; + done = _IO_vfwscanf (stream, format, args, NULL); + _IO_release_lock (stream); + return done; +} +libc_hidden_def (__isoc99_vfwscanf) diff --git a/wcsmbs/isoc99_vswscanf.c b/wcsmbs/isoc99_vswscanf.c new file mode 100644 index 0000000000..4d7081e43d --- /dev/null +++ b/wcsmbs/isoc99_vswscanf.c @@ -0,0 +1,49 @@ +/* Copyright (C) 1993, 1997-2003, 2006, 2007 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. + + As a special exception, if you link the code in this file with + files compiled with a GNU compiler to produce an executable, + that does not cause the resulting executable to be covered by + the GNU Lesser General Public License. This exception does not + however invalidate any other reasons why the executable file + might be covered by the GNU Lesser General Public License. + This exception applies to code released by its copyright holders + in files containing the exception. */ + +#include <libioP.h> +#include <wchar.h> +#include "../libio/strfile.h" + +int +__isoc99_vswscanf (const wchar_t *string, const wchar_t *format, + _IO_va_list args) +{ + int ret; + _IO_strfile sf; + struct _IO_wide_data wd; +#ifdef _IO_MTSAFE_IO + sf._sbf._f._lock = NULL; +#endif + _IO_no_init (&sf._sbf._f, _IO_USER_LOCK, 0, &wd, &_IO_wstr_jumps); + _IO_fwide (&sf._sbf._f, 1); + _IO_wstr_init_static (&sf._sbf._f, (wchar_t *)string, 0, NULL); + sf._sbf._f._flags2 |= _IO_FLAGS2_SCANF_STD; + ret = _IO_vfwscanf ((_IO_FILE *) &sf._sbf, format, args, NULL); + return ret; +} +libc_hidden_def (__isoc99_vswscanf) diff --git a/wcsmbs/isoc99_vwscanf.c b/wcsmbs/isoc99_vwscanf.c new file mode 100644 index 0000000000..8a0b345f05 --- /dev/null +++ b/wcsmbs/isoc99_vwscanf.c @@ -0,0 +1,35 @@ +/* Copyright (C) 1991, 1997, 2006, 2007 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <libioP.h> +#include <stdio.h> +#include <wchar.h> + +/* Read formatted input from STDIN according to the format string FORMAT. */ +/* VARARGS2 */ +int +__isoc99_vwscanf (const wchar_t *format, _IO_va_list args) +{ + int done; + + _IO_acquire_lock_clear_flags2 (stdin); + stdin->_flags2 |= _IO_FLAGS2_SCANF_STD; + done = _IO_vfwscanf (stdin, format, args, NULL); + _IO_release_lock (stdin); + return done; +} diff --git a/wcsmbs/isoc99_wscanf.c b/wcsmbs/isoc99_wscanf.c new file mode 100644 index 0000000000..581e05fefb --- /dev/null +++ b/wcsmbs/isoc99_wscanf.c @@ -0,0 +1,43 @@ +/* Copyright (C) 1991, 1995, 1996, 1997, 2002, 2004, 2006, 2007 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <stdarg.h> +#include <stdio.h> +#include <libioP.h> +#include <wchar.h> + + +/* Read formatted input from stdin according to the format string FORMAT. */ +/* VARARGS1 */ +int +__isoc99_wscanf (const wchar_t *format, ...) +{ + va_list arg; + int done; + + _IO_acquire_lock_clear_flags2 (stdin); + stdin->_flags2 |= _IO_FLAGS2_SCANF_STD; + + va_start (arg, format); + done = _IO_vfwscanf (stdin, format, arg, NULL); + va_end (arg); + + _IO_release_lock (stdin); + return done; +} diff --git a/wcsmbs/wchar.h b/wcsmbs/wchar.h index 8deaddab97..e8448c86d9 100644 --- a/wcsmbs/wchar.h +++ b/wcsmbs/wchar.h @@ -587,12 +587,42 @@ extern int swscanf (__const wchar_t *__restrict __s, __const wchar_t *__restrict __format, ...) __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */; +# 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 (fwscanf, (__FILE *__restrict __stream, + __const wchar_t *__restrict __format, ...), + __isoc99_fwscanf) + /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */; +extern int __REDIRECT (wscanf, (__const wchar_t *__restrict __format, ...), + __isoc99_wscanf) + /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */; +extern int __REDIRECT (swscanf, (__const wchar_t *__restrict __s, + __const wchar_t *__restrict __format, ...), + __isoc99_swscanf) + __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */; +# else +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; +# define fwscanf __isoc99_fwscanf +# define wscanf __isoc99_wscanf +# define swscanf __isoc99_swscanf +# endif +# endif + __END_NAMESPACE_C99 #endif /* Use ISO C95, C99 and Unix98. */ #ifdef __USE_ISOC99 __BEGIN_NAMESPACE_C99 - /* Read formatted input from S into argument list ARG. This function is a possible cancellation point and therefore not @@ -614,6 +644,36 @@ extern int vswscanf (__const wchar_t *__restrict __s, __gnuc_va_list __arg) __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */; +# if !defined __USE_GNU \ + && (!defined __LDBL_COMPAT || !defined __REDIRECT) \ + && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K) +# ifdef __REDIRECT +extern int __REDIRECT (vfwscanf, (__FILE *__restrict __s, + __const wchar_t *__restrict __format, + __gnuc_va_list __arg), __isoc99_vfwscanf) + /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */; +extern int __REDIRECT (vwscanf, (__const wchar_t *__restrict __format, + __gnuc_va_list __arg), __isoc99_vwscanf) + /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */; +extern int __REDIRECT (vswscanf, (__const wchar_t *__restrict __s, + __const wchar_t *__restrict __format, + __gnuc_va_list __arg), __isoc99_vswscanf) + __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */; +# else +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; +# define vfwscanf __isoc99_vfwscanf +# define vwscanf __isoc99_vwscanf +# define vswscanf __isoc99_vswscanf +# endif +# endif + __END_NAMESPACE_C99 #endif /* Use ISO C99. */ |