diff options
Diffstat (limited to 'wcsmbs/wchar.h')
-rw-r--r-- | wcsmbs/wchar.h | 304 |
1 files changed, 130 insertions, 174 deletions
diff --git a/wcsmbs/wchar.h b/wcsmbs/wchar.h index e4134167dc..6c94f3ebc6 100644 --- a/wcsmbs/wchar.h +++ b/wcsmbs/wchar.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-2016 Free Software Foundation, Inc. +/* Copyright (C) 1995-2018 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 @@ -21,95 +21,37 @@ */ #ifndef _WCHAR_H +#define _WCHAR_H 1 -#if !defined __need_mbstate_t && !defined __need_wint_t -# define _WCHAR_H 1 -# include <features.h> -#endif +#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION +#include <bits/libc-header-start.h> -#ifdef _WCHAR_H -/* Get FILE definition. */ -# define __need___FILE -# if defined __USE_UNIX98 || defined __USE_XOPEN2K -# define __need_FILE -# endif -# include <stdio.h> -/* Get va_list definition. */ -# define __need___va_list -# include <stdarg.h> +/* Gather machine dependent type support. */ +#include <bits/floatn.h> -# include <bits/wchar.h> +#define __need_size_t +#define __need_wchar_t +#define __need_NULL +#include <stddef.h> -/* Get size_t, wchar_t, wint_t and NULL from <stddef.h>. */ -# define __need_size_t -# define __need_wchar_t -# define __need_NULL -#endif -#if defined _WCHAR_H || defined __need_wint_t || !defined __WINT_TYPE__ -# undef __need_wint_t -# define __need_wint_t -# include <stddef.h> - -/* We try to get wint_t from <stddef.h>, but not all GCC versions define it - there. So define it ourselves if it remains undefined. */ -# ifndef _WINT_T -/* Integral type unchanged by default argument promotions that can - hold any value corresponding to members of the extended character - set, as well as at least one value that does not correspond to any - member of the extended character set. */ -# define _WINT_T -typedef unsigned int wint_t; -# else -/* Work around problems with the <stddef.h> file which doesn't put - wint_t in the std namespace. */ -# if defined __cplusplus && defined _GLIBCPP_USE_NAMESPACES \ - && defined __WINT_TYPE__ -__BEGIN_NAMESPACE_STD -typedef __WINT_TYPE__ wint_t; -__END_NAMESPACE_STD -# endif -# endif +#define __need___va_list +#include <stdarg.h> -/* Tell the caller that we provide correct C++ prototypes. */ -# if defined __cplusplus && __GNUC_PREREQ (4, 4) -# define __CORRECT_ISO_CPP_WCHAR_H_PROTO -# endif -#endif +#include <bits/wchar.h> +#include <bits/types/wint_t.h> +#include <bits/types/mbstate_t.h> +#include <bits/types/__FILE.h> -#if (defined _WCHAR_H || defined __need_mbstate_t) && !defined ____mbstate_t_defined -# define ____mbstate_t_defined 1 -/* Conversion state information. */ -typedef struct -{ - int __count; - union - { -# ifdef __WINT_TYPE__ - __WINT_TYPE__ __wch; -# else - wint_t __wch; -# endif - char __wchb[4]; - } __value; /* Value so far. */ -} __mbstate_t; +#if defined __USE_UNIX98 || defined __USE_XOPEN2K +# include <bits/types/FILE.h> +#endif +#ifdef __USE_XOPEN2K8 +# include <bits/types/locale_t.h> #endif -#undef __need_mbstate_t - - -/* The rest of the file is only used if used if __need_mbstate_t is not - defined. */ -#ifdef _WCHAR_H - -# ifndef __mbstate_t_defined -__BEGIN_NAMESPACE_C99 -/* Public type. */ -typedef __mbstate_t mbstate_t; -__END_NAMESPACE_C99 -# define __mbstate_t_defined 1 -# endif -#ifdef __USE_GNU -__USING_NAMESPACE_C99(mbstate_t) +/* Tell the caller that we provide correct C++ prototypes. */ +#if defined __cplusplus && __GNUC_PREREQ (4, 4) +# define __CORRECT_ISO_CPP_WCHAR_H_PROTO #endif #ifndef WCHAR_MIN @@ -122,27 +64,25 @@ __USING_NAMESPACE_C99(mbstate_t) # define WEOF (0xffffffffu) #endif -/* For XPG4 compliance we have to define the stuff from <wctype.h> here - as well. */ -#if defined __USE_XOPEN && !defined __USE_UNIX98 -# include <wctype.h> +/* All versions of XPG prior to the publication of ISO C99 required + the bulk of <wctype.h>'s declarations to appear in this header + (because <wctype.h> did not exist prior to C99). In POSIX.1-2001 + those declarations were marked as XSI extensions; in -2008 they + were additionally marked as obsolescent. _GNU_SOURCE mode + anticipates the removal of these declarations in the next revision + of POSIX. */ +#if (defined __USE_XOPEN && !defined __USE_GNU \ + && !(defined __USE_XOPEN2K && !defined __USE_XOPEN2KXSI)) +# include <bits/wctype-wchar.h> #endif - __BEGIN_DECLS -__BEGIN_NAMESPACE_STD /* This incomplete type is defined in <time.h> but needed here because of `wcsftime'. */ struct tm; -__END_NAMESPACE_STD -/* XXX We have to clean this up at some point. Since tm is in the std - namespace but wcsftime is in __c99 the type wouldn't be found - without inserting it in the global namespace. */ -__USING_NAMESPACE_STD(tm) -__BEGIN_NAMESPACE_STD /* Copy SRC to DEST. */ extern wchar_t *wcscpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src) @@ -168,7 +108,6 @@ extern int wcscmp (const wchar_t *__s1, const wchar_t *__s2) /* Compare N wide-characters of S1 and S2. */ extern int wcsncmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n) __THROW __attribute_pure__ __nonnull ((1, 2)); -__END_NAMESPACE_STD #ifdef __USE_XOPEN2K8 /* Compare S1 and S2, ignoring case. */ @@ -180,16 +119,13 @@ extern int wcsncasecmp (const wchar_t *__s1, const wchar_t *__s2, /* Similar to the two functions above but take the information from the provided locale and not the global locale. */ -# include <xlocale.h> - extern int wcscasecmp_l (const wchar_t *__s1, const wchar_t *__s2, - __locale_t __loc) __THROW; + locale_t __loc) __THROW; extern int wcsncasecmp_l (const wchar_t *__s1, const wchar_t *__s2, - size_t __n, __locale_t __loc) __THROW; + size_t __n, locale_t __loc) __THROW; #endif -__BEGIN_NAMESPACE_STD /* Compare S1 and S2, both interpreted as appropriate to the LC_COLLATE category of the current locale. */ extern int wcscoll (const wchar_t *__s1, const wchar_t *__s2) __THROW; @@ -198,7 +134,6 @@ extern int wcscoll (const wchar_t *__s1, const wchar_t *__s2) __THROW; `wcscoll' to the original strings. */ extern size_t wcsxfrm (wchar_t *__restrict __s1, const wchar_t *__restrict __s2, size_t __n) __THROW; -__END_NAMESPACE_STD #ifdef __USE_XOPEN2K8 /* Similar to the two functions above but take the information from @@ -207,19 +142,18 @@ __END_NAMESPACE_STD /* Compare S1 and S2, both interpreted as appropriate to the LC_COLLATE category of the given locale. */ extern int wcscoll_l (const wchar_t *__s1, const wchar_t *__s2, - __locale_t __loc) __THROW; + locale_t __loc) __THROW; /* Transform S2 into array pointed to by S1 such that if wcscmp is applied to two transformed strings the result is the as applying `wcscoll' to the original strings. */ extern size_t wcsxfrm_l (wchar_t *__s1, const wchar_t *__s2, - size_t __n, __locale_t __loc) __THROW; + size_t __n, locale_t __loc) __THROW; /* Duplicate S, returning an identical malloc'd string. */ extern wchar_t *wcsdup (const wchar_t *__s) __THROW __attribute_malloc__; #endif -__BEGIN_NAMESPACE_STD /* Find the first occurrence of WC in WCS. */ #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO extern "C++" wchar_t *wcschr (wchar_t *__wcs, wchar_t __wc) @@ -240,7 +174,6 @@ extern "C++" const wchar_t *wcsrchr (const wchar_t *__wcs, wchar_t __wc) extern wchar_t *wcsrchr (const wchar_t *__wcs, wchar_t __wc) __THROW __attribute_pure__; #endif -__END_NAMESPACE_STD #ifdef __USE_GNU /* This function is similar to `wcschr'. But it returns a pointer to @@ -249,7 +182,6 @@ extern wchar_t *wcschrnul (const wchar_t *__s, wchar_t __wc) __THROW __attribute_pure__; #endif -__BEGIN_NAMESPACE_STD /* Return the length of the initial segmet of WCS which consists entirely of wide characters not in REJECT. */ extern size_t wcscspn (const wchar_t *__wcs, const wchar_t *__reject) @@ -288,7 +220,6 @@ extern wchar_t *wcstok (wchar_t *__restrict __s, /* Return the number of wide characters in S. */ extern size_t wcslen (const wchar_t *__s) __THROW __attribute_pure__; -__END_NAMESPACE_STD #ifdef __USE_XOPEN /* Another name for `wcsstr' from XPG4. */ @@ -311,7 +242,6 @@ extern size_t wcsnlen (const wchar_t *__s, size_t __maxlen) #endif -__BEGIN_NAMESPACE_STD /* Search N wide characters of S for C. */ #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO extern "C++" wchar_t *wmemchr (wchar_t *__s, wchar_t __c, size_t __n) @@ -339,7 +269,6 @@ extern wchar_t *wmemmove (wchar_t *__s1, const wchar_t *__s2, size_t __n) /* Set N wide characters of S to C. */ extern wchar_t *wmemset (wchar_t *__s, wchar_t __c, size_t __n) __THROW; -__END_NAMESPACE_STD #ifdef __USE_GNU /* Copy N wide characters of SRC to DEST and return pointer to following @@ -350,7 +279,6 @@ extern wchar_t *wmempcpy (wchar_t *__restrict __s1, #endif -__BEGIN_NAMESPACE_STD /* Determine whether C constitutes a valid (one-byte) multibyte character. */ extern wint_t btowc (int __c) __THROW; @@ -378,7 +306,6 @@ extern size_t __mbrlen (const char *__restrict __s, size_t __n, mbstate_t *__restrict __ps) __THROW; extern size_t mbrlen (const char *__restrict __s, size_t __n, mbstate_t *__restrict __ps) __THROW; -__END_NAMESPACE_STD #ifdef __USE_EXTERN_INLINES /* Define inline function as optimization. */ @@ -405,7 +332,6 @@ __NTH (mbrlen (const char *__restrict __s, size_t __n, ? mbrtowc (NULL, __s, __n, __ps) : __mbrlen (__s, __n, NULL)); } #endif -__BEGIN_NAMESPACE_STD /* Write wide character representation of multibyte character string SRC to DST. */ extern size_t mbsrtowcs (wchar_t *__restrict __dst, @@ -417,7 +343,6 @@ extern size_t mbsrtowcs (wchar_t *__restrict __dst, extern size_t wcsrtombs (char *__restrict __dst, const wchar_t **__restrict __src, size_t __len, mbstate_t *__restrict __ps) __THROW; -__END_NAMESPACE_STD #ifdef __USE_XOPEN2K8 @@ -447,25 +372,57 @@ extern int wcswidth (const wchar_t *__s, size_t __n) __THROW; #endif /* Use X/Open. */ -__BEGIN_NAMESPACE_STD /* Convert initial portion of the wide string NPTR to `double' representation. */ extern double wcstod (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr) __THROW; -__END_NAMESPACE_STD #ifdef __USE_ISOC99 -__BEGIN_NAMESPACE_C99 /* Likewise for `float' and `long double' sizes of floating-point numbers. */ extern float wcstof (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr) __THROW; extern long double wcstold (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr) __THROW; -__END_NAMESPACE_C99 #endif /* C99 */ +/* Likewise for `_FloatN' and `_FloatNx' when support is enabled. */ + +#if __HAVE_FLOAT16 && defined __USE_GNU +extern _Float16 wcstof16 (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr) __THROW; +#endif + +#if __HAVE_FLOAT32 && defined __USE_GNU +extern _Float32 wcstof32 (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr) __THROW; +#endif + +#if __HAVE_FLOAT64 && defined __USE_GNU +extern _Float64 wcstof64 (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr) __THROW; +#endif + +#if __HAVE_FLOAT128 && defined __USE_GNU +extern _Float128 wcstof128 (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr) __THROW; +#endif + +#if __HAVE_FLOAT32X && defined __USE_GNU +extern _Float32x wcstof32x (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr) __THROW; +#endif + +#if __HAVE_FLOAT64X && defined __USE_GNU +extern _Float64x wcstof64x (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr) __THROW; +#endif + +#if __HAVE_FLOAT128X && defined __USE_GNU +extern _Float128x wcstof128x (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr) __THROW; +#endif + -__BEGIN_NAMESPACE_STD /* Convert initial portion of wide string NPTR to `long int' representation. */ extern long int wcstol (const wchar_t *__restrict __nptr, @@ -476,10 +433,8 @@ extern long int wcstol (const wchar_t *__restrict __nptr, extern unsigned long int wcstoul (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr, int __base) __THROW; -__END_NAMESPACE_STD #ifdef __USE_ISOC99 -__BEGIN_NAMESPACE_C99 /* Convert initial portion of wide string NPTR to `long long int' representation. */ __extension__ @@ -493,7 +448,6 @@ __extension__ extern unsigned long long int wcstoull (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr, int __base) __THROW; -__END_NAMESPACE_C99 #endif /* ISO C99. */ #ifdef __USE_GNU @@ -513,53 +467,81 @@ extern unsigned long long int wcstouq (const wchar_t *__restrict __nptr, #endif /* Use GNU. */ #ifdef __USE_GNU -/* The concept of one static locale per category is not very well - thought out. Many applications will need to process its data using - information from several different locales. Another application is - the implementation of the internationalization handling in the - upcoming ISO C++ standard library. To support this another set of - the functions using locale data exist which have an additional - argument. - - Attention: all these functions are *not* standardized in any form. - This is a proof-of-concept implementation. */ - -/* Structure for reentrant locale using functions. This is an - (almost) opaque type for the user level programs. */ -# include <xlocale.h> - -/* Special versions of the functions above which take the locale to - use as an additional parameter. */ +/* Parallel versions of the functions above which take the locale to + use as an additional parameter. These are GNU extensions inspired + by the POSIX.1-2008 extended locale API. */ extern long int wcstol_l (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr, int __base, - __locale_t __loc) __THROW; + locale_t __loc) __THROW; extern unsigned long int wcstoul_l (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr, - int __base, __locale_t __loc) __THROW; + int __base, locale_t __loc) __THROW; __extension__ extern long long int wcstoll_l (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr, - int __base, __locale_t __loc) __THROW; + int __base, locale_t __loc) __THROW; __extension__ extern unsigned long long int wcstoull_l (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr, - int __base, __locale_t __loc) + int __base, locale_t __loc) __THROW; extern double wcstod_l (const wchar_t *__restrict __nptr, - wchar_t **__restrict __endptr, __locale_t __loc) + wchar_t **__restrict __endptr, locale_t __loc) __THROW; extern float wcstof_l (const wchar_t *__restrict __nptr, - wchar_t **__restrict __endptr, __locale_t __loc) + wchar_t **__restrict __endptr, locale_t __loc) __THROW; extern long double wcstold_l (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr, - __locale_t __loc) __THROW; + locale_t __loc) __THROW; + +# if __HAVE_FLOAT16 +extern _Float16 wcstof16_l (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, + locale_t __loc) __THROW; +# endif + +# if __HAVE_FLOAT32 +extern _Float32 wcstof32_l (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, + locale_t __loc) __THROW; +# endif + +# if __HAVE_FLOAT64 +extern _Float64 wcstof64_l (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, + locale_t __loc) __THROW; +# endif + +# if __HAVE_FLOAT128 +extern _Float128 wcstof128_l (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, + locale_t __loc) __THROW; +# endif + +# if __HAVE_FLOAT32X +extern _Float32x wcstof32x_l (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, + locale_t __loc) __THROW; +# endif + +# if __HAVE_FLOAT64X +extern _Float64x wcstof64x_l (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, + locale_t __loc) __THROW; +# endif + +# if __HAVE_FLOAT128X +extern _Float128x wcstof128x_l (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, + locale_t __loc) __THROW; +# endif #endif /* use GNU */ @@ -574,17 +556,18 @@ extern wchar_t *wcpcpy (wchar_t *__restrict __dest, extern wchar_t *wcpncpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src, size_t __n) __THROW; +#endif /* Wide character I/O functions. */ +#if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2) /* Like OPEN_MEMSTREAM, but the stream is wide oriented and produces a wide character string. */ extern __FILE *open_wmemstream (wchar_t **__bufloc, size_t *__sizeloc) __THROW; #endif #if defined __USE_ISOC95 || defined __USE_UNIX98 -__BEGIN_NAMESPACE_STD /* Select orientation for stream. */ extern int fwide (__FILE *__fp, int __mode) __THROW; @@ -680,11 +663,9 @@ extern int __isoc99_swscanf (const wchar_t *__restrict __s, # endif # endif -__END_NAMESPACE_STD #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 @@ -736,11 +717,9 @@ extern int __isoc99_vswscanf (const wchar_t *__restrict __s, # endif # endif -__END_NAMESPACE_C99 #endif /* Use ISO C99. */ -__BEGIN_NAMESPACE_STD /* Read a character from STREAM. These functions are possible cancellation points and therefore not @@ -790,7 +769,6 @@ extern int fputws (const wchar_t *__restrict __ws, This function is a possible cancellation point and therefore not marked with __THROW. */ extern wint_t ungetwc (wint_t __wc, __FILE *__stream); -__END_NAMESPACE_STD #ifdef __USE_GNU @@ -851,37 +829,22 @@ extern int fputws_unlocked (const wchar_t *__restrict __ws, #endif -__BEGIN_NAMESPACE_C99 /* Format TP into S according to FORMAT. Write no more than MAXSIZE wide characters and return the number of wide characters written, or 0 if it would exceed MAXSIZE. */ extern size_t wcsftime (wchar_t *__restrict __s, size_t __maxsize, const wchar_t *__restrict __format, const struct tm *__restrict __tp) __THROW; -__END_NAMESPACE_C99 # ifdef __USE_GNU -# include <xlocale.h> - /* Similar to `wcsftime' but takes the information from the provided locale and not the global locale. */ extern size_t wcsftime_l (wchar_t *__restrict __s, size_t __maxsize, const wchar_t *__restrict __format, const struct tm *__restrict __tp, - __locale_t __loc) __THROW; + locale_t __loc) __THROW; # endif -/* The X/Open standard demands that most of the functions defined in - the <wctype.h> header must also appear here. This is probably - because some X/Open members wrote their implementation before the - ISO C standard was published and introduced the better solution. - We have to provide these definitions for compliance reasons but we - do this nonsense only if really necessary. */ -#if defined __USE_UNIX98 && !defined __USE_GNU -# define __need_iswxxx -# include <wctype.h> -#endif - /* Define some macros helping to catch buffer overflows. */ #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function # include <bits/wchar2.h> @@ -893,11 +856,4 @@ extern size_t wcsftime_l (wchar_t *__restrict __s, size_t __maxsize, __END_DECLS -#endif /* _WCHAR_H defined */ - #endif /* wchar.h */ - -/* Undefine all __need_* constants in case we are included to get those - constants but the whole file was already read. */ -#undef __need_mbstate_t -#undef __need_wint_t |