diff options
Diffstat (limited to 'REORG.TODO/ctype')
-rw-r--r-- | REORG.TODO/ctype/Makefile | 32 | ||||
-rw-r--r-- | REORG.TODO/ctype/Versions | 27 | ||||
-rw-r--r-- | REORG.TODO/ctype/ctype-c99.c | 26 | ||||
-rw-r--r-- | REORG.TODO/ctype/ctype-c99_l.c | 27 | ||||
-rw-r--r-- | REORG.TODO/ctype/ctype-extn.c | 51 | ||||
-rw-r--r-- | REORG.TODO/ctype/ctype-info.c | 77 | ||||
-rw-r--r-- | REORG.TODO/ctype/ctype.c | 53 | ||||
-rw-r--r-- | REORG.TODO/ctype/ctype.h | 341 | ||||
-rw-r--r-- | REORG.TODO/ctype/ctype_l.c | 51 | ||||
-rw-r--r-- | REORG.TODO/ctype/isctype.c | 28 | ||||
-rw-r--r-- | REORG.TODO/ctype/test_ctype.c | 100 |
11 files changed, 813 insertions, 0 deletions
diff --git a/REORG.TODO/ctype/Makefile b/REORG.TODO/ctype/Makefile new file mode 100644 index 0000000000..9f1da09010 --- /dev/null +++ b/REORG.TODO/ctype/Makefile @@ -0,0 +1,32 @@ +# Copyright (C) 1991-2017 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, see +# <http://www.gnu.org/licenses/>. + +# +# Sub-makefile for ctype portion of the library. +# +subdir := ctype + +include ../Makeconfig + +headers := ctype.h + +routines := ctype ctype-c99 ctype-extn ctype-c99_l ctype_l isctype +aux := ctype-info + +tests := test_ctype + +include ../Rules diff --git a/REORG.TODO/ctype/Versions b/REORG.TODO/ctype/Versions new file mode 100644 index 0000000000..84f1e2c7cb --- /dev/null +++ b/REORG.TODO/ctype/Versions @@ -0,0 +1,27 @@ +libc { + GLIBC_2.0 { + # global variables + __ctype_b; __ctype32_b; __ctype_tolower; __ctype_toupper; + _tolower; _toupper; + + # i* + isalnum; isalpha; isascii; isblank; iscntrl; isdigit; isgraph; islower; + isprint; ispunct; isspace; isupper; isxdigit; + + # t* + toascii; tolower; toupper; + } + GLIBC_2.2 { + # global variables + __ctype32_tolower; __ctype32_toupper; + } + GLIBC_2.3 { + isctype; __isctype; + + # functions used by optimized macros in ctype.h + __ctype_b_loc; __ctype_tolower_loc; __ctype_toupper_loc; + } + GLIBC_PRIVATE { + __ctype_init; + } +} diff --git a/REORG.TODO/ctype/ctype-c99.c b/REORG.TODO/ctype/ctype-c99.c new file mode 100644 index 0000000000..f55df0ca7d --- /dev/null +++ b/REORG.TODO/ctype/ctype-c99.c @@ -0,0 +1,26 @@ +/* External function version of isblank. + Copyright (C) 1991-2017 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, see + <http://www.gnu.org/licenses/>. */ + +#define __NO_CTYPE +#include <ctype.h> + +int +isblank (int c) +{ + return __isctype (c, _ISblank); +} diff --git a/REORG.TODO/ctype/ctype-c99_l.c b/REORG.TODO/ctype/ctype-c99_l.c new file mode 100644 index 0000000000..efb5a67bb5 --- /dev/null +++ b/REORG.TODO/ctype/ctype-c99_l.c @@ -0,0 +1,27 @@ +/* External function version of isblank_l. + Copyright (C) 1991-2017 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, see + <http://www.gnu.org/licenses/>. */ + +#define __NO_CTYPE +#include <ctype.h> + +int +__isblank_l (int c, __locale_t l) +{ + return __isctype_l (c, _ISblank, l); +} +weak_alias (__isblank_l, isblank_l) diff --git a/REORG.TODO/ctype/ctype-extn.c b/REORG.TODO/ctype/ctype-extn.c new file mode 100644 index 0000000000..70b794da02 --- /dev/null +++ b/REORG.TODO/ctype/ctype-extn.c @@ -0,0 +1,51 @@ +/* Copyright (C) 1991-2017 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, see + <http://www.gnu.org/licenses/>. */ + +#define __NO_CTYPE +#include <ctype.h> + +#define __ctype_tolower \ + ((int32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TOLOWER) + 128) +#define __ctype_toupper \ + ((int32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TOUPPER) + 128) + +/* Real function versions of the non-ANSI ctype functions. */ + +int +_tolower (int c) +{ + return __ctype_tolower[c]; +} +int +_toupper (int c) +{ + return __ctype_toupper[c]; +} + +int +toascii (int c) +{ + return __toascii (c); +} +weak_alias (toascii, __toascii_l) + +int +isascii (int c) +{ + return __isascii (c); +} +weak_alias (isascii, __isascii_l) diff --git a/REORG.TODO/ctype/ctype-info.c b/REORG.TODO/ctype/ctype-info.c new file mode 100644 index 0000000000..bf19e3c10e --- /dev/null +++ b/REORG.TODO/ctype/ctype-info.c @@ -0,0 +1,77 @@ +/* Copyright (C) 1991-2017 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, see + <http://www.gnu.org/licenses/>. */ + +#define CTYPE_EXTERN_INLINE /* Define real functions for accessors. */ +#include <ctype.h> +#include <locale/localeinfo.h> + +__libc_tsd_define (, const uint16_t *, CTYPE_B) +__libc_tsd_define (, const int32_t *, CTYPE_TOLOWER) +__libc_tsd_define (, const int32_t *, CTYPE_TOUPPER) + + +void +__ctype_init (void) +{ + const uint16_t **bp = __libc_tsd_address (const uint16_t *, CTYPE_B); + *bp = (const uint16_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_CLASS) + 128; + const int32_t **up = __libc_tsd_address (const int32_t *, CTYPE_TOUPPER); + *up = ((int32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TOUPPER) + 128); + const int32_t **lp = __libc_tsd_address (const int32_t *, CTYPE_TOLOWER); + *lp = ((int32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TOLOWER) + 128); +} +libc_hidden_def (__ctype_init) + + +#include <shlib-compat.h> +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3) + +/* Defined in locale/C-ctype.c. */ +extern const char _nl_C_LC_CTYPE_class[] attribute_hidden; +extern const char _nl_C_LC_CTYPE_class32[] attribute_hidden; +extern const char _nl_C_LC_CTYPE_toupper[] attribute_hidden; +extern const char _nl_C_LC_CTYPE_tolower[] attribute_hidden; +extern const char _nl_C_LC_CTYPE_class_upper[] attribute_hidden; +extern const char _nl_C_LC_CTYPE_class_lower[] attribute_hidden; +extern const char _nl_C_LC_CTYPE_class_alpha[] attribute_hidden; +extern const char _nl_C_LC_CTYPE_class_digit[] attribute_hidden; +extern const char _nl_C_LC_CTYPE_class_xdigit[] attribute_hidden; +extern const char _nl_C_LC_CTYPE_class_space[] attribute_hidden; +extern const char _nl_C_LC_CTYPE_class_print[] attribute_hidden; +extern const char _nl_C_LC_CTYPE_class_graph[] attribute_hidden; +extern const char _nl_C_LC_CTYPE_class_blank[] attribute_hidden; +extern const char _nl_C_LC_CTYPE_class_cntrl[] attribute_hidden; +extern const char _nl_C_LC_CTYPE_class_punct[] attribute_hidden; +extern const char _nl_C_LC_CTYPE_class_alnum[] attribute_hidden; + +#define b(t,x,o) (((const t *) _nl_C_LC_CTYPE_##x) + o) + +const unsigned short int *__ctype_b = b (unsigned short int, class, 128); +const __uint32_t *__ctype32_b = b (__uint32_t, class32, 0); +const __int32_t *__ctype_tolower = b (__int32_t, tolower, 128); +const __int32_t *__ctype_toupper = b (__int32_t, toupper, 128); +const __uint32_t *__ctype32_tolower = b (__uint32_t, tolower, 128); +const __uint32_t *__ctype32_toupper = b (__uint32_t, toupper, 128); + +compat_symbol (libc, __ctype_b, __ctype_b, GLIBC_2_0); +compat_symbol (libc, __ctype_tolower, __ctype_tolower, GLIBC_2_0); +compat_symbol (libc, __ctype_toupper, __ctype_toupper, GLIBC_2_0); +compat_symbol (libc, __ctype32_b, __ctype32_b, GLIBC_2_0); +compat_symbol (libc, __ctype32_tolower, __ctype32_tolower, GLIBC_2_2); +compat_symbol (libc, __ctype32_toupper, __ctype32_toupper, GLIBC_2_2); + +#endif diff --git a/REORG.TODO/ctype/ctype.c b/REORG.TODO/ctype/ctype.c new file mode 100644 index 0000000000..e341d73362 --- /dev/null +++ b/REORG.TODO/ctype/ctype.c @@ -0,0 +1,53 @@ +/* Copyright (C) 1991-2017 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, see + <http://www.gnu.org/licenses/>. */ + +#define __NO_CTYPE +#include <ctype.h> + +/* Provide real-function versions of all the ctype macros. */ + +#define func(name, type) \ + int name (int c) { return __isctype (c, type); } + +func (isalnum, _ISalnum) +func (isalpha, _ISalpha) +func (iscntrl, _IScntrl) +func (isdigit, _ISdigit) +func (islower, _ISlower) +func (isgraph, _ISgraph) +func (isprint, _ISprint) +func (ispunct, _ISpunct) +func (isspace, _ISspace) +func (isupper, _ISupper) +func (isxdigit, _ISxdigit) + +#define __ctype_tolower \ + ((int32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TOLOWER) + 128) +#define __ctype_toupper \ + ((int32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TOUPPER) + 128) + +int +tolower (int c) +{ + return c >= -128 && c < 256 ? __ctype_tolower[c] : c; +} + +int +toupper (int c) +{ + return c >= -128 && c < 256 ? __ctype_toupper[c] : c; +} diff --git a/REORG.TODO/ctype/ctype.h b/REORG.TODO/ctype/ctype.h new file mode 100644 index 0000000000..1fe89cf836 --- /dev/null +++ b/REORG.TODO/ctype/ctype.h @@ -0,0 +1,341 @@ +/* Copyright (C) 1991-2017 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, see + <http://www.gnu.org/licenses/>. */ + +/* + * 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 `unsigned short int's. + + The characteristics are stored always in network byte order (big + endian). We define the bit value interpretations here dependent on the + machine's byte order. */ + +# include <endian.h> +# if __BYTE_ORDER == __BIG_ENDIAN +# define _ISbit(bit) (1 << (bit)) +# else /* __BYTE_ORDER == __LITTLE_ENDIAN */ +# define _ISbit(bit) ((bit) < 8 ? ((1 << (bit)) << 8) : ((1 << (bit)) >> 8)) +# endif + +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. */ +}; +#endif /* ! _ISbit */ + +/* These are defined in ctype-info.c. + The declarations here must match those in localeinfo.h. + + 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. */ +extern const unsigned short int **__ctype_b_loc (void) + __THROW __attribute__ ((__const__)); +extern const __int32_t **__ctype_tolower_loc (void) + __THROW __attribute__ ((__const__)); +extern const __int32_t **__ctype_toupper_loc (void) + __THROW __attribute__ ((__const__)); + + +#ifndef __cplusplus +# define __isctype(c, type) \ + ((*__ctype_b_loc ())[(int) (c)] & (unsigned short int) type) +#elif defined __USE_EXTERN_INLINES +# define __isctype_f(type) \ + __extern_inline int \ + is##type (int __c) __THROW \ + { \ + return (*__ctype_b_loc ())[(int) (__c)] & (unsigned short int) _IS##type; \ + } +#endif + +#define __isascii(c) (((c) & ~0x7f) == 0) /* If C is a 7 bit value. */ +#define __toascii(c) ((c) & 0x7f) /* Mask off high bits. */ + +#define __exctype(name) extern int name (int) __THROW + +/* 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); + + +/* Return the lowercase version of C. */ +extern int tolower (int __c) __THROW; + +/* Return the uppercase version of C. */ +extern int toupper (int __c) __THROW; + + +/* ISO C99 introduced one new function. */ +#ifdef __USE_ISOC99 +__exctype (isblank); +#endif + +#ifdef __USE_GNU +/* Test C for a set of character classes according to MASK. */ +extern int isctype (int __c, int __mask) __THROW; +#endif + +#if 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 X/Open 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 = __c < -128 || __c > 255 ? __c : (a)[__c]; \ + } \ + else \ + __res = f args; \ + } \ + else \ + __res = (a)[(int) (c)]; \ + __res; })) + +#if !defined __NO_CTYPE +# ifdef __isctype_f +__isctype_f (alnum) +__isctype_f (alpha) +__isctype_f (cntrl) +__isctype_f (digit) +__isctype_f (lower) +__isctype_f (graph) +__isctype_f (print) +__isctype_f (punct) +__isctype_f (space) +__isctype_f (upper) +__isctype_f (xdigit) +# ifdef __USE_ISOC99 +__isctype_f (blank) +# endif +# elif defined __isctype +# 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 +# endif + +# ifdef __USE_EXTERN_INLINES +__extern_inline int +__NTH (tolower (int __c)) +{ + return __c >= -128 && __c < 256 ? (*__ctype_tolower_loc ())[__c] : __c; +} + +__extern_inline int +__NTH (toupper (int __c)) +{ + return __c >= -128 && __c < 256 ? (*__ctype_toupper_loc ())[__c] : __c; +} +# endif + +# if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus +# define tolower(c) __tobody (c, tolower, *__ctype_tolower_loc (), (c)) +# define toupper(c) __tobody (c, toupper, *__ctype_toupper_loc (), (c)) +# endif /* Optimizing gcc */ + +# if defined __USE_MISC || defined __USE_XOPEN +# define isascii(c) __isascii (c) +# define toascii(c) __toascii (c) + +# define _tolower(c) ((int) (*__ctype_tolower_loc ())[(int) (c)]) +# define _toupper(c) ((int) (*__ctype_toupper_loc ())[(int) (c)]) +# endif + +#endif /* Not __NO_CTYPE. */ + + +#ifdef __USE_XOPEN2K8 +/* 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)] & (unsigned short int) 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)) + +# ifdef __USE_MISC +# 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 isblank_l(c,l) __isblank_l ((c), (l)) + +# ifdef __USE_MISC +# define isascii_l(c,l) __isascii_l ((c), (l)) +# define toascii_l(c,l) __toascii_l ((c), (l)) +# endif + +# endif /* Not __NO_CTYPE. */ + +#endif /* Use POSIX 2008. */ + +__END_DECLS + +#endif /* ctype.h */ diff --git a/REORG.TODO/ctype/ctype_l.c b/REORG.TODO/ctype/ctype_l.c new file mode 100644 index 0000000000..a7b5f5238a --- /dev/null +++ b/REORG.TODO/ctype/ctype_l.c @@ -0,0 +1,51 @@ +/* Copyright (C) 1991-2017 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, see + <http://www.gnu.org/licenses/>. */ + +#define __NO_CTYPE +#include <ctype.h> + +/* Provide real-function versions of all the ctype macros. */ + +#define func(name, type) \ + int __##name (int c, __locale_t l) { return __isctype_l (c, type, l); } \ + weak_alias (__##name, name) + +func (isalnum_l, _ISalnum) +func (isalpha_l, _ISalpha) +func (iscntrl_l, _IScntrl) +func (isdigit_l, _ISdigit) +func (islower_l, _ISlower) +func (isgraph_l, _ISgraph) +func (isprint_l, _ISprint) +func (ispunct_l, _ISpunct) +func (isspace_l, _ISspace) +func (isupper_l, _ISupper) +func (isxdigit_l, _ISxdigit) + +int +(__tolower_l) (int c, __locale_t l) +{ + return l->__ctype_tolower[c]; +} +weak_alias (__tolower_l, tolower_l) + +int +(__toupper_l) (int c, __locale_t l) +{ + return l->__ctype_toupper[c]; +} +weak_alias (__toupper_l, toupper_l) diff --git a/REORG.TODO/ctype/isctype.c b/REORG.TODO/ctype/isctype.c new file mode 100644 index 0000000000..0e81f9465a --- /dev/null +++ b/REORG.TODO/ctype/isctype.c @@ -0,0 +1,28 @@ +/* Copyright (C) 2002-2017 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, see + <http://www.gnu.org/licenses/>. */ + +#include <ctype.h> + +#undef __isctype + +int +__isctype (int ch, int mask) +{ + return (((uint16_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_CLASS) + 128) + [(int) (ch)] & mask); +} +weak_alias (__isctype, isctype) diff --git a/REORG.TODO/ctype/test_ctype.c b/REORG.TODO/ctype/test_ctype.c new file mode 100644 index 0000000000..c113969995 --- /dev/null +++ b/REORG.TODO/ctype/test_ctype.c @@ -0,0 +1,100 @@ +/* Copyright (C) 1991-2017 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, see + <http://www.gnu.org/licenses/>. */ + +#include <limits.h> +#include <ctype.h> +#include <stdio.h> +#include <stdlib.h> + +#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#define XOR(e,f) (((e) && !(f)) || (!(e) && (f))) + +#ifdef __GNUC__ +__inline +#endif +static void +print_char (unsigned char c) +{ + printf("%d/", (int) c); + if (isgraph(c)) + printf("'%c'", c); + else + printf("'\\%.3o'", c); +} + +int +main (int argc, char **argv) +{ + unsigned short int c; + int lose = 0; + +#define TRYEM do { \ + TRY (isascii); \ + TRY (isalnum); \ + TRY (isalpha); \ + TRY (iscntrl); \ + TRY (isdigit); \ + TRY (isgraph); \ + TRY (islower); \ + TRY (isprint); \ + TRY (ispunct); \ + TRY (isspace); \ + TRY (isupper); \ + TRY (isxdigit); \ + TRY (isblank); \ + } while (0) + + for (c = 0; c <= UCHAR_MAX; ++c) + { + print_char (c); + + if (XOR (islower (c), ISLOWER (c)) || toupper (c) != TOUPPER (c)) + { + fputs (" BOGUS", stdout); + ++lose; + } + +#define TRY(isfoo) if (isfoo (c)) fputs (" " #isfoo, stdout) + TRYEM; +#undef TRY + + fputs("; lower = ", stdout); + print_char(tolower(c)); + fputs("; upper = ", stdout); + print_char(toupper(c)); + putchar('\n'); + } + + fputs ("EOF", stdout); + if (tolower (EOF) != EOF) + { + ++lose; + printf (" tolower BOGUS %d;", tolower (EOF)); + } + if (toupper (EOF) != EOF) + { + ++lose; + printf (" toupper BOGUS %d;", toupper (EOF)); + } + +#define TRY(isfoo) if (isfoo (EOF)) fputs (" " #isfoo, stdout), ++lose + TRYEM; +#undef TRY + + return lose ? EXIT_FAILURE : EXIT_SUCCESS; +} |