diff options
author | Manuel Novoa III <mjn3@codepoet.org> | 2003-08-01 20:08:59 +0000 |
---|---|---|
committer | Manuel Novoa III <mjn3@codepoet.org> | 2003-08-01 20:08:59 +0000 |
commit | 1217289737588e65b088b3535428b27c7287d699 (patch) | |
tree | 6a292ac767d219702e26a6a2111737f84a96900c /include | |
parent | 32b76c5ec3c257b7287913d0d1a96e0cbb2e9c6a (diff) |
Add a new *scanf implementation, includeing the *wscanf functions.
Should be standards compliant and with several optional features,
including support for hexadecimal float notation, locale awareness,
glibc-like locale-specific digit grouping with the `'' flag, and
positional arg support. I tested it pretty well (finding several
bugs in glibc's scanf in the process), but it is brand new so be
aware.
The *wprintf functions now support floating point output. Also, a
couple of bugs were squashed. Finally, %a/%A conversions are
now implemented.
Implement the glibc xlocale interface for thread-specific locale
support. Also add the various *_l(args, locale_t loc_arg) funcs.
NOTE!!! setlocale() is NOT threadsafe! NOTE!!!
The strto{floating point} conversion functions are now locale aware.
The also now support hexadecimal floating point notation.
Add the wcsto{floating point} conversion functions.
Fix a bug in mktime() related to dst. Note that unlike glibc's mktime,
uClibc's version always normalizes the struct tm before attempting
to determine the correct dst setting if tm_isdst == -1 on entry.
Add a stub version of the libintl functions. (untested)
Fixed a known memory leak in setlocale() related to the collation data.
Add lots of new config options (which Erik agreed to sort out :-),
including finally exposing some of the stripped down stdio configs.
Be careful with those though, as they haven't been tested in a
long time.
(temporary) GOTCHAs...
The ctype functions are currently incorrect for 8-bit locales. They
will be fixed shortly.
The ctype functions are now table-based, resulting in larger staticly
linked binaries. I'll be adding an option to use the old approach
in the stub locale configuration.
Diffstat (limited to 'include')
-rw-r--r-- | include/ctype.h | 443 | ||||
-rw-r--r-- | include/langinfo.h | 9 | ||||
-rw-r--r-- | include/libintl.h | 126 | ||||
-rw-r--r-- | include/locale.h | 97 | ||||
-rw-r--r-- | include/signal.h | 2 | ||||
-rw-r--r-- | include/stdio.h | 16 | ||||
-rw-r--r-- | include/stdlib.h | 313 | ||||
-rw-r--r-- | include/string.h | 75 | ||||
-rw-r--r-- | include/sys/cdefs.h | 48 | ||||
-rw-r--r-- | include/time.h | 90 | ||||
-rw-r--r-- | include/wchar.h | 411 | ||||
-rw-r--r-- | include/wctype.h | 108 | ||||
-rw-r--r-- | include/xlocale.h | 62 |
13 files changed, 1336 insertions, 464 deletions
diff --git a/include/ctype.h b/include/ctype.h index c6faf3d9b..23ff199e4 100644 --- a/include/ctype.h +++ b/include/ctype.h @@ -1,129 +1,382 @@ -/* Copyright (C) 2002 Manuel Novoa III +/* Copyright (C) 1991,92,93,95,96,97,98,99,2001,02 + 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. */ + +/* + * ISO C99 Standard 7.4: Character handling <ctype.h> + */ + +#ifndef _CTYPE_H +#define _CTYPE_H 1 + +#include <features.h> +#include <bits/types.h> + +__BEGIN_DECLS + +#ifndef _ISbit +/* These are all the characteristics of characters. + If there get to be more than 16 distinct characteristics, + many things must be changed that use `__uint16_t's. */ + +# define _ISbit(bit) (1 << (bit)) + +enum +{ + _ISupper = _ISbit (0), /* UPPERCASE. */ + _ISlower = _ISbit (1), /* lowercase. */ + _ISalpha = _ISbit (2), /* Alphabetic. */ + _ISdigit = _ISbit (3), /* Numeric. */ + _ISxdigit = _ISbit (4), /* Hexadecimal numeric. */ + _ISspace = _ISbit (5), /* Whitespace. */ + _ISprint = _ISbit (6), /* Printing. */ + _ISgraph = _ISbit (7), /* Graphical. */ + _ISblank = _ISbit (8), /* Blank (usually SPC and TAB). */ + _IScntrl = _ISbit (9), /* Control character. */ + _ISpunct = _ISbit (10), /* Punctuation. */ + _ISalnum = _ISbit (11) /* Alphanumeric. */ +}; +#else +#error _ISbit already defined! +#endif /* ! _ISbit */ + +#include <bits/uClibc_touplow.h> + +#ifdef __UCLIBC_HAS_CTYPE_SIGNED__ +# define __UCLIBC_CTYPE_IN_TO_DOMAIN(c) (((unsigned int)((c) + 128)) < 384) + +#else /* __UCLIBC_HAS_CTYPE_SIGNED__ */ +# define __UCLIBC_CTYPE_IN_TO_DOMAIN(c) (((unsigned int)(c)) < 256) + +#endif /* __UCLIBC_HAS_CTYPE_SIGNED__ */ + +/* In the thread-specific locale model (see `uselocale' in <locale.h>) + we cannot use global variables for these as was done in the past. + Instead, the following accessor functions return the address of + each variable, which is local to the current thread if multithreaded. + + These point into arrays of 384, so they can be indexed by any `unsigned + char' value [0,255]; by EOF (-1); or by any `signed char' value + [-128,-1). ISO C requires that the ctype functions work for `unsigned + char' values and for EOF; we also support negative `signed char' values + for broken old programs. The case conversion arrays are of `int's + rather than `unsigned char's because tolower (EOF) must be EOF, which + doesn't fit into an `unsigned char'. But today more important is that + the arrays are also used for multi-byte character sets. */ + +/* uClibc differences: + * + * When __UCLIBC_HAS_CTYPE_SIGNED is defined, * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. + * The upper and lower mapping arrays are type int16_t, so that + * they may store all char values plus EOF. The glibc reasoning + * given above for these being type int is questionable, as the + * ctype mapping functions map from the set of (unsigned) char + * and EOF back into the set. They have no awareness of multi-byte + * or wide characters. * - * This 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 - * Library General Public License for more details. + * Otherwise, * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * The ctype array is defined for -1..255. + * The upper and lower mapping arrays are defined for 0..255. + * The upper and lower mapping arrays are type unsigned char. */ -/* NOTE: It is assumed here and throughout the library that the underlying - * char encoding for the portable C character set is ASCII (host & target). */ +/* Pointers to the default C-locale data. */ +extern const __uint16_t *__C_ctype_b; +extern const __ctype_touplow_t *__C_ctype_toupper; +extern const __ctype_touplow_t *__C_ctype_tolower; -#ifndef _CTYPE_H -#define _CTYPE_H +#ifdef __UCLIBC_HAS_XLOCALE__ -#include <features.h> -#include <bits/uClibc_ctype.h> +extern __const __uint16_t **__ctype_b_loc (void) + __attribute__ ((__const)); +extern __const __ctype_touplow_t **__ctype_tolower_loc (void) + __attribute__ ((__const)); +extern __const __ctype_touplow_t **__ctype_toupper_loc (void) + __attribute__ ((__const)); -__BEGIN_DECLS +#define __UCLIBC_CTYPE_B (*__ctype_b_loc()) +#define __UCLIBC_CTYPE_TOLOWER (*__ctype_tolower_loc()) +#define __UCLIBC_CTYPE_TOUPPER (*__ctype_toupper_loc()) -extern int isalnum(int c) __THROW; -extern int isalpha(int c) __THROW; -#ifdef __USE_ISOC99 -extern int isblank(int c) __THROW; -#endif -extern int iscntrl(int c) __THROW; -extern int isdigit(int c) __THROW; -extern int isgraph(int c) __THROW; -extern int islower(int c) __THROW; -extern int isprint(int c) __THROW; -extern int ispunct(int c) __THROW; -extern int isspace(int c) __THROW; -extern int isupper(int c) __THROW; -extern int isxdigit(int c) __THROW; - -extern int tolower(int c) __THROW; -extern int toupper(int c) __THROW; +#else /* __UCLIBC_HAS_XLOCALE__ */ -#if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN -extern int isascii(int c) __THROW; -extern int toascii(int c) __THROW; -#endif +/* Pointers to the current global locale data in use. */ +extern const __uint16_t *__ctype_b; +extern const __ctype_touplow_t *__ctype_toupper; +extern const __ctype_touplow_t *__ctype_tolower; + +#define __UCLIBC_CTYPE_B (__ctype_b) +#define __UCLIBC_CTYPE_TOLOWER (__ctype_tolower) +#define __UCLIBC_CTYPE_TOUPPER (__ctype_toupper) + +#endif /* __UCLIBC_HAS_XLOCALE__ */ + +#define __isctype(c, type) \ + ((__UCLIBC_CTYPE_B)[(int) (c)] & (__uint16_t) type) + +#define __isascii(c) (((c) & ~0x7f) == 0) /* If C is a 7 bit value. */ +#define __toascii(c) ((c) & 0x7f) /* Mask off high bits. */ -/* The following are included for compatibility with older versions of - * uClibc; but now they're only visible if MISC funcctionality is requested. - * However, as they are locale-independent, the hidden macro versions are - * always present. */ #ifdef __USE_MISC -extern int isxlower(int c) __THROW; /* uClibc-specific. */ -extern int isxupper(int c) __THROW; /* uClibc-specific. */ + +/* The following are included for compatibility with older versions of + * uClibc; but now they're only visible if MISC funcctionality is requested. */ +extern int isxlower(int c) __THROW; +extern int isxupper(int c) __THROW; + +/* isdigit() is really locale-invariant, so provide some small fast macros. + * These are uClibc-specific. */ +#define __isdigit_char(C) (((unsigned char)((C) - '0')) <= 9) +#define __isdigit_int(C) (((unsigned int)((C) - '0')) <= 9) + #endif -/* Next, some ctype macros which are valid for all supported locales. */ -/* WARNING: isspace and isblank need to be reverified if more 8-bit codesets - * are added!!! But isdigit and isxdigit are always valid. */ +#define __exctype(name) extern int name (int) __THROW -#define __isspace(c) __C_isspace(c) -#define __isblank(c) __C_isblank(c) +__BEGIN_NAMESPACE_STD -#define __isdigit(c) __C_isdigit(c) -#define __isxdigit(c) __C_isxdigit(c) +/* The following names are all functions: + int isCHARACTERISTIC(int c); + which return nonzero iff C has CHARACTERISTIC. + For the meaning of the characteristic names, see the `enum' above. */ +__exctype (isalnum); +__exctype (isalpha); +__exctype (iscntrl); +__exctype (isdigit); +__exctype (islower); +__exctype (isgraph); +__exctype (isprint); +__exctype (ispunct); +__exctype (isspace); +__exctype (isupper); +__exctype (isxdigit); -/* Now some non-ansi/iso c99 macros. */ -#define __isascii(c) (((c) & ~0x7f) == 0) -#define __toascii(c) ((c) & 0x7f) -#define _toupper(c) ((c) ^ 0x20) -#define _tolower(c) ((c) | 0x20) +/* Return the lowercase version of C. */ +extern int tolower (int __c) __THROW; +/* Return the uppercase version of C. */ +extern int toupper (int __c) __THROW; -/* For compatibility with older versions of uClibc. Are these ever used? */ -#define __isxlower(c) __C_isxlower(c) /* uClibc-specific. */ -#define __isxupper(c) __C_isxupper(c) /* uClibc-specific. */ +__END_NAMESPACE_STD -/* Apparently, glibc implements things as macros if __NO_CTYPE isn't defined. - * If we don't have locale support, we'll do the same. Otherwise, we'll - * only use macros for the supported-locale-invariant cases. */ -#if 0 -/* Currently broken, since masking macros, other than getc and putc, must - * evaluate their args exactly once. Will be fixed by the next release. mjn3 */ -/* #ifndef __NO_CTYPE */ -#define isdigit(c) __isdigit(c) -#define isxdigit(c) __isxdigit(c) -#define isspace(c) __isspace(c) -#ifdef __USE_ISOC99 -#define isblank(c) __isblank(c) -#endif +/* ISO C99 introduced one new function. */ +#ifdef __USE_ISOC99 +__BEGIN_NAMESPACE_C99 -#if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN -#define isascii(c) __isascii(c) -#define toascii(c) __toascii(c) +__exctype (isblank); + +__END_NAMESPACE_C99 #endif -#ifdef __USE_MISC -#define isxlower(c) __C_isxlower(c) /* uClibc-specific. */ -#define isxupper(c) __C_isxupper(c) /* uClibc-specific. */ +#ifdef __USE_GNU +/* Test C for a set of character classes according to MASK. */ +extern int isctype (int __c, int __mask) __THROW; #endif -/* TODO - Should test for 8-bit codesets instead, but currently impossible. */ -#ifndef __UCLIBC_HAS_LOCALE__ +#if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN + +/* Return nonzero iff C is in the ASCII set + (i.e., is no more than 7 bits wide). */ +extern int isascii (int __c) __THROW; + +/* Return the part of C that is in the ASCII set + (i.e., the low-order 7 bits of C). */ +extern int toascii (int __c) __THROW; + +/* These are the same as `toupper' and `tolower' except that they do not + check the argument for being in the range of a `char'. */ +__exctype (_toupper); +__exctype (_tolower); +#endif /* Use SVID or use misc. */ + +/* This code is needed for the optimized mapping functions. */ +#define __tobody(c, f, a, args) \ + (__extension__ \ + ({ int __res; \ + if (sizeof (c) > 1) \ + { \ + if (__builtin_constant_p (c)) \ + { \ + int __c = (c); \ + __res = __UCLIBC_CTYPE_IN_TO_DOMAIN(__c) ? (a)[__c] : __c; \ + } \ + else \ + __res = f args; \ + } \ + else \ + __res = (a)[(int) (c)]; \ + __res; })) + +#if !defined __NO_CTYPE && !defined __cplusplus +# define isalnum(c) __isctype((c), _ISalnum) +# define isalpha(c) __isctype((c), _ISalpha) +# define iscntrl(c) __isctype((c), _IScntrl) +# define isdigit(c) __isctype((c), _ISdigit) +# define islower(c) __isctype((c), _ISlower) +# define isgraph(c) __isctype((c), _ISgraph) +# define isprint(c) __isctype((c), _ISprint) +# define ispunct(c) __isctype((c), _ISpunct) +# define isspace(c) __isctype((c), _ISspace) +# define isupper(c) __isctype((c), _ISupper) +# define isxdigit(c) __isctype((c), _ISxdigit) + +# ifdef __USE_ISOC99 +# define isblank(c) __isctype((c), _ISblank) +# endif + +# ifdef __USE_EXTERN_INLINES +extern __inline int +tolower (int __c) __THROW +{ + return __UCLIBC_CTYPE_IN_TO_DOMAIN(__c) ? (__UCLIBC_CTYPE_TOLOWER)[__c] : __c; +} + +extern __inline int +toupper (int __c) __THROW +{ + return __UCLIBC_CTYPE_IN_TO_DOMAIN(__c) ? (__UCLIBC_CTYPE_TOUPPER)[__c] : __c; +} +# endif + +# if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus +# define tolower(c) __tobody (c, tolower, __UCLIBC_CTYPE_TOLOWER, (c)) +# define toupper(c) __tobody (c, toupper, __UCLIBC_CTYPE_TOUPPER, (c)) +# endif /* Optimizing gcc */ + +# if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN +# define isascii(c) __isascii (c) +# define toascii(c) __toascii (c) + +# define _tolower(c) ((int) (__UCLIBC_CTYPE_TOLOWER)[(int) (c)]) +# define _toupper(c) ((int) (__UCLIBC_CTYPE_TOUPPER)[(int) (c)]) +# endif + +#endif /* Not __NO_CTYPE. */ + + +#if defined(__USE_GNU) && defined(__UCLIBC_HAS_XLOCALE__) +/* 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> + +/* These definitions are similar to the ones above but all functions + take as an argument a handle for the locale which shall be used. */ +# define __isctype_l(c, type, locale) \ + ((locale)->__ctype_b[(int) (c)] & (__uint16_t) type) + +# define __exctype_l(name) \ + extern int name (int, __locale_t) __THROW + +/* The following names are all functions: + int isCHARACTERISTIC(int c, locale_t *locale); + which return nonzero iff C has CHARACTERISTIC. + For the meaning of the characteristic names, see the `enum' above. */ +__exctype_l (isalnum_l); +__exctype_l (isalpha_l); +__exctype_l (iscntrl_l); +__exctype_l (isdigit_l); +__exctype_l (islower_l); +__exctype_l (isgraph_l); +__exctype_l (isprint_l); +__exctype_l (ispunct_l); +__exctype_l (isspace_l); +__exctype_l (isupper_l); +__exctype_l (isxdigit_l); + +__exctype_l (isblank_l); + + +/* Return the lowercase version of C in locale L. */ +extern int __tolower_l (int __c, __locale_t __l) __THROW; +extern int tolower_l (int __c, __locale_t __l) __THROW; + +/* Return the uppercase version of C. */ +extern int __toupper_l (int __c, __locale_t __l) __THROW; +extern int toupper_l (int __c, __locale_t __l) __THROW; + +# if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus +# define __tolower_l(c, locale) \ + __tobody (c, __tolower_l, (locale)->__ctype_tolower, (c, locale)) +# define __toupper_l(c, locale) \ + __tobody (c, __toupper_l, (locale)->__ctype_toupper, (c, locale)) +# define tolower_l(c, locale) __tolower_l ((c), (locale)) +# define toupper_l(c, locale) __toupper_l ((c), (locale)) +# endif /* Optimizing gcc */ + + +# ifndef __NO_CTYPE +# define __isalnum_l(c,l) __isctype_l((c), _ISalnum, (l)) +# define __isalpha_l(c,l) __isctype_l((c), _ISalpha, (l)) +# define __iscntrl_l(c,l) __isctype_l((c), _IScntrl, (l)) +# define __isdigit_l(c,l) __isctype_l((c), _ISdigit, (l)) +# define __islower_l(c,l) __isctype_l((c), _ISlower, (l)) +# define __isgraph_l(c,l) __isctype_l((c), _ISgraph, (l)) +# define __isprint_l(c,l) __isctype_l((c), _ISprint, (l)) +# define __ispunct_l(c,l) __isctype_l((c), _ISpunct, (l)) +# define __isspace_l(c,l) __isctype_l((c), _ISspace, (l)) +# define __isupper_l(c,l) __isctype_l((c), _ISupper, (l)) +# define __isxdigit_l(c,l) __isctype_l((c), _ISxdigit, (l)) + +# define __isblank_l(c,l) __isctype_l((c), _ISblank, (l)) + +# if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN +# define __isascii_l(c,l) ((l), __isascii (c)) +# define __toascii_l(c,l) ((l), __toascii (c)) +# endif + +# define isalnum_l(c,l) __isalnum_l ((c), (l)) +# define isalpha_l(c,l) __isalpha_l ((c), (l)) +# define iscntrl_l(c,l) __iscntrl_l ((c), (l)) +# define isdigit_l(c,l) __isdigit_l ((c), (l)) +# define islower_l(c,l) __islower_l ((c), (l)) +# define isgraph_l(c,l) __isgraph_l ((c), (l)) +# define isprint_l(c,l) __isprint_l ((c), (l)) +# define ispunct_l(c,l) __ispunct_l ((c), (l)) +# define isspace_l(c,l) __isspace_l ((c), (l)) +# define isupper_l(c,l) __isupper_l ((c), (l)) +# define isxdigit_l(c,l) __isxdigit_l ((c), (l)) -#define isalnum(c) __C_isalnum(c) -#define isalpha(c) __C_isalpha(c) -#define iscntrl(c) __C_iscntrl(c) -#define isgraph(c) __C_isgraph(c) -#define islower(c) __C_islower(c) -#define isprint(c) __C_isprint(c) -#define ispunct(c) __C_ispunct(c) -#define isupper(c) __C_isupper(c) +# define isblank_l(c,l) __isblank_l ((c), (l)) -#define tolower(c) __C_tolower(c) -#define toupper(c) __C_toupper(c) +# if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN +# define isascii_l(c,l) __isascii_l ((c), (l)) +# define toascii_l(c,l) __toascii_l ((c), (l)) +# endif -#endif /* __UCLIBC_HAS_LOCALE__ */ +# endif /* Not __NO_CTYPE. */ -#endif /* __NO_CTYPE */ +#endif /* Use GNU. */ __END_DECLS -#endif /* _CTYPE_H */ +#endif /* ctype.h */ diff --git a/include/langinfo.h b/include/langinfo.h index a57a871c5..a129c12ae 100644 --- a/include/langinfo.h +++ b/include/langinfo.h @@ -605,8 +605,8 @@ enum extern char *nl_langinfo (nl_item __item) __THROW; -#if 0 -/*#ifdef __USE_GNU*/ +#ifdef __UCLIBC_HAS_XLOCALE__ +#ifdef __USE_GNU /* This interface is for the extended locale model. See <locale.h> for more information. */ @@ -614,8 +614,9 @@ extern char *nl_langinfo (nl_item __item) __THROW; # include <xlocale.h> /* Just like nl_langinfo but get the information from the locale object L. */ -extern char *__nl_langinfo_l (nl_item __item, __locale_t l); -#endif /* 0 */ +extern char *nl_langinfo_l (nl_item __item, __locale_t l); +#endif +#endif __END_DECLS diff --git a/include/libintl.h b/include/libintl.h index ae1ac88e8..89db38f3b 100644 --- a/include/libintl.h +++ b/include/libintl.h @@ -1,18 +1,122 @@ -/* Message catalog support for internationalization is not currently - * provided by uClibc, and so I have added macros here to disable it. - * Sorry about that. - */ +/* Message catalogs for internationalization. + Copyright (C) 1995-1999, 2000-2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + This file is derived from the file libgettext.h in the GNU gettext package. + + 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. */ #ifndef _LIBINTL_H #define _LIBINTL_H 1 -#undef bindtextdomain -#define bindtextdomain(Domain, Directory) /* empty */ -#undef textdomain -#define textdomain(Domain) /* empty */ -#define _(Text) (Text) -#define N_(Text) (Text) +#include <features.h> + +/* We define an additional symbol to signal that we use the GNU + implementation of gettext. */ +#define __USE_GNU_GETTEXT 1 + +/* Provide information about the supported file formats. Returns the + maximum minor revision number supported for a given major revision. */ +#define __GNU_GETTEXT_SUPPORTED_REVISION(major) \ + ((major) == 0 ? 1 : -1) + +__BEGIN_DECLS + +/* Look up MSGID in the current default message catalog for the current + LC_MESSAGES locale. If not found, returns MSGID itself (the default + text). */ +extern char *gettext (__const char *__msgid) __THROW; + +/* Look up MSGID in the DOMAINNAME message catalog for the current + LC_MESSAGES locale. */ +extern char *dgettext (__const char *__domainname, __const char *__msgid) + __THROW; +extern char *__dgettext (__const char *__domainname, __const char *__msgid) + __THROW __attribute_format_arg__ (2); + +/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY + locale. */ +extern char *dcgettext (__const char *__domainname, + __const char *__msgid, int __category) __THROW; +extern char *__dcgettext (__const char *__domainname, + __const char *__msgid, int __category) + __THROW __attribute_format_arg__ (2); + + +/* Similar to `gettext' but select the plural form corresponding to the + number N. */ +extern char *ngettext (__const char *__msgid1, __const char *__msgid2, + unsigned long int __n) + __THROW __attribute_format_arg__ (1) __attribute_format_arg__ (2); + +/* Similar to `dgettext' but select the plural form corresponding to the + number N. */ +extern char *dngettext (__const char *__domainname, __const char *__msgid1, + __const char *__msgid2, unsigned long int __n) + __THROW __attribute_format_arg__ (2) __attribute_format_arg__ (3); + +/* Similar to `dcgettext' but select the plural form corresponding to the + number N. */ +extern char *dcngettext (__const char *__domainname, __const char *__msgid1, + __const char *__msgid2, unsigned long int __n, + int __category) + __THROW __attribute_format_arg__ (2) __attribute_format_arg__ (3); + + +/* Set the current default message catalog to DOMAINNAME. + If DOMAINNAME is null, return the current default. + If DOMAINNAME is "", reset to the default of "messages". */ +extern char *textdomain (__const char *__domainname) __THROW; + +/* Specify that the DOMAINNAME message catalog will be found + in DIRNAME rather than in the system locale data base. */ +extern char *bindtextdomain (__const char *__domainname, + __const char *__dirname) __THROW; + +/* Specify the character encoding in which the messages from the + DOMAINNAME message catalog will be returned. */ +extern char *bind_textdomain_codeset (__const char *__domainname, + __const char *__codeset) __THROW; + + +/* Optimized version of the function above. */ +#if defined __OPTIMIZE__ + +/* We need NULL for `gettext'. */ +# define __need_NULL +# include <stddef.h> + +/* We need LC_MESSAGES for `dgettext'. */ +# include <locale.h> + +/* These must be macros. Inlined functions are useless because the + `__builtin_constant_p' predicate in dcgettext would always return + false. */ + +# define gettext(msgid) dgettext (NULL, msgid) + +# define dgettext(domainname, msgid) \ + dcgettext (domainname, msgid, LC_MESSAGES) + +# define ngettext(msgid1, msgid2, n) dngettext (NULL, msgid1, msgid2, n) + +# define dngettext(domainname, msgid1, msgid2, n) \ + dcngettext (domainname, msgid1, msgid2, n, LC_MESSAGES) +#endif /* Optimizing. */ -#endif /* _LIBINTL_H */ +__END_DECLS +#endif /* libintl.h */ diff --git a/include/locale.h b/include/locale.h index 1101bb15a..02d33a0d4 100644 --- a/include/locale.h +++ b/include/locale.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991,92,1995-1999,2000,2001 Free Software Foundation, Inc. +/* Copyright (C) 1991,92,95-99,2000,01,02 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 @@ -39,13 +39,15 @@ __BEGIN_DECLS #define LC_COLLATE __LC_COLLATE #define LC_MONETARY __LC_MONETARY #define LC_MESSAGES __LC_MESSAGES -/* #define LC_PAPER __LC_PAPER */ -/* #define LC_NAME __LC_NAME */ -/* #define LC_ADDRESS __LC_ADDRESS */ -/* #define LC_TELEPHONE __LC_TELEPHONE */ -/* #define LC_MEASUREMENT __LC_MEASUREMENT */ -/* #define LC_IDENTIFICATION __LC_IDENTIFICATION */ -#define LC_ALL __LC_ALL +#if 0 +#define LC_PAPER __LC_PAPER +#define LC_NAME __LC_NAME +#define LC_ADDRESS __LC_ADDRESS +#define LC_TELEPHONE __LC_TELEPHONE +#define LC_MEASUREMENT __LC_MEASUREMENT +#define LC_IDENTIFICATION __LC_IDENTIFICATION +#endif +#define LC_ALL __LC_ALL /* Structure giving information about numeric and monetary notation. */ @@ -119,14 +121,18 @@ struct lconv }; +__BEGIN_NAMESPACE_STD + /* Set and/or return the current locale. */ extern char *setlocale (int __category, __const char *__locale) __THROW; /* Return the numeric/monetary information for the current locale. */ extern struct lconv *localeconv (void) __THROW; -#if 0 -/* #ifdef __USE_GNU */ +__END_NAMESPACE_STD + + +#if defined(__USE_GNU) && defined(__UCLIBC_HAS_XLOCALE__) /* 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 @@ -141,22 +147,77 @@ extern struct lconv *localeconv (void) __THROW; /* Get locale datatype definition. */ # include <xlocale.h> +typedef __locale_t locale_t; + /* Return a reference to a data structure representing a set of locale datasets. Unlike for the CATEGORY parameter for `setlocale' the - CATEGORY_MASK parameter here uses a single bit for each category. - I.e., 1 << LC_CTYPE means to load data for this category. If - BASE is non-null the appropriate category information in the BASE - record is replaced. */ -extern __locale_t __newlocale (int __category_mask, __const char *__locale, - __locale_t __base) __THROW; + CATEGORY_MASK parameter here uses a single bit for each category, + made by OR'ing together LC_*_MASK bits above. */ +extern __locale_t newlocale (int __category_mask, __const char *__locale, + __locale_t __base) __THROW; + +/* These are the bits that can be set in the CATEGORY_MASK argument to + `newlocale'. In the GNU implementation, LC_FOO_MASK has the value + of (1 << LC_FOO), but this is not a part of the interface that + callers can assume will be true. */ +# define LC_CTYPE_MASK (1 << __LC_CTYPE) +# define LC_NUMERIC_MASK (1 << __LC_NUMERIC) +# define LC_TIME_MASK (1 << __LC_TIME) +# define LC_COLLATE_MASK (1 << __LC_COLLATE) +# define LC_MONETARY_MASK (1 << __LC_MONETARY) +# define LC_MESSAGES_MASK (1 << __LC_MESSAGES) +#ifdef L_newlocale +#warning mask defines for extra locale categories +#endif /* L_newlocale - uClibc note */ +#ifdef LC_PAPER +# define LC_PAPER_MASK (1 << __LC_PAPER) +# define LC_NAME_MASK (1 << __LC_NAME) +# define LC_ADDRESS_MASK (1 << __LC_ADDRESS) +# define LC_TELEPHONE_MASK (1 << __LC_TELEPHONE) +# define LC_MEASUREMENT_MASK (1 << __LC_MEASUREMENT) +# define LC_IDENTIFICATION_MASK (1 << __LC_IDENTIFICATION) +# define LC_ALL_MASK (LC_CTYPE_MASK \ + | LC_NUMERIC_MASK \ + | LC_TIME_MASK \ + | LC_COLLATE_MASK \ + | LC_MONETARY_MASK \ + | LC_MESSAGES_MASK \ + | LC_PAPER_MASK \ + | LC_NAME_MASK \ + | LC_ADDRESS_MASK \ + | LC_TELEPHONE_MASK \ + | LC_MEASUREMENT_MASK \ + | LC_IDENTIFICATION_MASK \ + ) +#else /* LC_PAPER */ +# define LC_ALL_MASK (LC_CTYPE_MASK \ + | LC_NUMERIC_MASK \ + | LC_TIME_MASK \ + | LC_COLLATE_MASK \ + | LC_MONETARY_MASK \ + | LC_MESSAGES_MASK \ + ) +#endif /* LC_PAPER */ /* Return a duplicate of the set of locale in DATASET. All usage counters are increased if necessary. */ -extern __locale_t __duplocale (__locale_t __dataset) __THROW; +extern __locale_t duplocale (__locale_t __dataset) __THROW; /* Free the data associated with a locale dataset previously returned by a call to `setlocale_r'. */ -extern void __freelocale (__locale_t __dataset) __THROW; +extern void freelocale (__locale_t __dataset) __THROW; + +/* Switch the current thread's locale to DATASET. + If DATASET is null, instead just return the current setting. + The special value LC_GLOBAL_LOCALE is the initial setting + for all threads and can also be installed any time, meaning + the thread uses the global settings controlled by `setlocale'. */ +extern __locale_t uselocale (__locale_t __dataset) __THROW; + +/* This value can be passed to `uselocale' and may be returned by it. + Passing this value to any other function has undefined behavior. */ +# define LC_GLOBAL_LOCALE ((__locale_t) -1L) + #endif __END_DECLS diff --git a/include/signal.h b/include/signal.h index f0a24dbcf..7793cdbe1 100644 --- a/include/signal.h +++ b/include/signal.h @@ -273,10 +273,12 @@ extern int sigqueue (__pid_t __pid, int __sig, __const union sigval __val) #ifdef __USE_BSD +#ifdef __UCLIBC_HAS_SYS_SIGLIST__ /* Names of the signals. This variable exists only for compatibility. Use `strsignal' instead (see <string.h>). */ extern __const char *__const _sys_siglist[_NSIG]; extern __const char *__const sys_siglist[_NSIG]; +#endif /* __UCLIBC_HAS_SYS_SIGLIST__ */ /* Structure passed to `sigvec'. */ struct sigvec diff --git a/include/stdio.h b/include/stdio.h index 3e27707ae..b11394da7 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -355,12 +355,19 @@ extern int getchar (void) __THROW; /* The C standard explicitly says this is a macro, so we always do the optimization for it. */ +#ifdef __UCLIBC_HAS_THREADS__ +#define getc(_fp) (getc)(_fp) /* SUSv3 says getc must be threadsafe. */ +#else /* __UCLIBC_HAS_THREADS__ */ #define getc(_fp) __GETC(_fp) +#endif /* __UCLIBC_HAS_THREADS__ */ #if defined __USE_POSIX || defined __USE_MISC /* These are defined in POSIX.1:1996. */ extern int getc_unlocked (FILE *__stream) __THROW; extern int getchar_unlocked (void) __THROW; + +/* SUSv3 allows getc_unlocked to be a macro */ +#define getc_unlocked(_fp) __GETC(_fp) #endif /* Use POSIX or MISC. */ #ifdef __USE_MISC @@ -378,7 +385,11 @@ extern int putchar (int __c) __THROW; /* The C standard explicitly says this can be a macro, so we always do the optimization for it. */ +#ifdef __UCLIBC_HAS_THREADS__ +#define putc(_ch, _fp) (putc)(_ch, _fp) /* SUSv3 says putc must be threadsafe. */ +#else /* __UCLIBC_HAS_THREADS__ */ #define putc(_ch, _fp) __PUTC(_ch, _fp) +#endif /* __UCLIBC_HAS_THREADS__ */ #ifdef __USE_MISC /* Faster version when locking is not necessary. */ @@ -389,6 +400,9 @@ extern int fputc_unlocked (int __c, FILE *__stream) __THROW; /* These are defined in POSIX.1:1996. */ extern int putc_unlocked (int __c, FILE *__stream) __THROW; extern int putchar_unlocked (int __c) __THROW; + +/* SUSv3 allows putc_unlocked to be a macro */ +#define putc_unlocked(_ch, _fp) __PUTC(_ch, _fp) #endif /* Use POSIX or MISC. */ @@ -544,6 +558,7 @@ extern int ferror_unlocked (FILE *__stream) __THROW; /* Print a message describing the meaning of the value of errno. */ extern void perror (__const char *__s) __THROW; +#ifdef __UCLIBC_HAS_SYS_ERRLIST__ /* These variables normally should not be used directly. The `strerror' function provides all the needed functionality. */ #ifdef __USE_BSD @@ -555,6 +570,7 @@ extern __const char *__const sys_errlist[]; extern int _sys_nerr; extern __const char *__const _sys_errlist[]; # |