summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-12-27 10:19:19 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-12-27 10:19:19 +0000
commitcf578c75a521e1f35a9f07ca04c0cd678209c79f (patch)
tree03cf31e8d7db0d0fcdf8384278e672bf437dc423 /include
parent7779fe81082b7521e537b02cdf71f88aff3de358 (diff)
ctype: remove some trivial macros from ctype.h;
remove __tolower and __toupper (they existed only in SOME configs!); remove usages of _tolower (some of them clearly buggy) from uclibc code; add a few more -U<define> options to unifdef pass over installed headers; document it on docs/wchar_and_locale.txt text data bss dec hex filename - 514963 2727 15396 533086 8225e lib/libuClibc-0.9.30-svn.so + 514888 2727 15396 533011 82213 lib/libuClibc-0.9.30-svn.so
Diffstat (limited to 'include')
-rw-r--r--include/ctype.h176
-rw-r--r--include/xlocale.h2
2 files changed, 76 insertions, 102 deletions
diff --git a/include/ctype.h b/include/ctype.h
index d7bce2e87..6933c96c0 100644
--- a/include/ctype.h
+++ b/include/ctype.h
@@ -27,7 +27,13 @@
#include <features.h>
#include <bits/types.h>
-#ifdef __UCLIBC_HAS_CTYPE_TABLES__
+#ifndef __UCLIBC_HAS_CTYPE_TABLES__
+
+/* "Stub locale": we are permanently in C/POSIX locale.
+ * Using simple(r) ctype.h machinery in this header instead: */
+#include <bits/uClibc_ctype.h>
+
+#else
__BEGIN_DECLS
@@ -51,13 +57,14 @@ enum
_ISalnum = 1 << 11, /* Alphanumeric. */
};
+/* __ctype_XXX_t types and __UCLIBC_CTYPE_x_TBL_OFFSET constants */
#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__ */
+#else
# define __UCLIBC_CTYPE_IN_TO_DOMAIN(c) (((unsigned int)(c)) < 256)
-#endif /* __UCLIBC_HAS_CTYPE_SIGNED__ */
+#endif
/* In the thread-specific locale model (see `uselocale' in <locale.h>)
we cannot use global variables for these as was done in the past.
@@ -101,16 +108,12 @@ libc_hidden_proto(__C_ctype_tolower)
#ifdef __UCLIBC_HAS_XLOCALE__
-extern __const __ctype_mask_t **__ctype_b_loc (void)
- __attribute__ ((__const));
+const __ctype_mask_t **__ctype_b_loc(void) __attribute__ ((const));
libc_hidden_proto(__ctype_b_loc)
-extern __const __ctype_touplow_t **__ctype_tolower_loc (void)
- __attribute__ ((__const));
+const __ctype_touplow_t **__ctype_tolower_loc(void) __attribute__ ((const));
libc_hidden_proto(__ctype_tolower_loc)
-extern __const __ctype_touplow_t **__ctype_toupper_loc (void)
- __attribute__ ((__const));
+const __ctype_touplow_t **__ctype_toupper_loc(void) __attribute__ ((const));
libc_hidden_proto(__ctype_toupper_loc)
-
#define __UCLIBC_CTYPE_B (*__ctype_b_loc())
#define __UCLIBC_CTYPE_TOLOWER (*__ctype_tolower_loc())
#define __UCLIBC_CTYPE_TOUPPER (*__ctype_toupper_loc())
@@ -124,64 +127,58 @@ extern const __ctype_touplow_t *__ctype_toupper;
libc_hidden_proto(__ctype_toupper)
extern const __ctype_touplow_t *__ctype_tolower;
libc_hidden_proto(__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)] & (__ctype_mask_t) type)
#define __isascii(c) (((c) & ~0x7f) == 0) /* If C is a 7 bit value. */
#define __toascii(c) ((c) & 0x7f) /* Mask off high bits. */
#if defined _LIBC && (defined IS_IN_libc || defined NOT_IN_libc)
-/* isdigit() is really locale-invariant, so provide some small fast macros.
- * These are uClibc-specific. */
+/* These are uClibc-specific. */
#define __isdigit_char(C) (((unsigned char)((C) - '0')) <= 9)
#define __isdigit_int(C) (((unsigned int)((C) - '0')) <= 9)
#endif
-#define __exctype(name) extern int name (int) __THROW
-
__BEGIN_NAMESPACE_STD
/* 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);
+extern int isalnum(int __c) __THROW;
libc_hidden_proto(isalnum)
-__exctype (isalpha);
+extern int isalpha(int __c) __THROW;
libc_hidden_proto(isalpha)
-__exctype (iscntrl);
+extern int iscntrl(int __c) __THROW;
libc_hidden_proto(iscntrl)
-__exctype (isdigit);
+extern int isdigit(int __c) __THROW;
libc_hidden_proto(isdigit)
-__exctype (islower);
+extern int islower(int __c) __THROW;
libc_hidden_proto(islower)
-__exctype (isgraph);
+extern int isgraph(int __c) __THROW;
libc_hidden_proto(isgraph)
-__exctype (isprint);
+extern int isprint(int __c) __THROW;
libc_hidden_proto(isprint)
-__exctype (ispunct);
+extern int ispunct(int __c) __THROW;
libc_hidden_proto(ispunct)
-__exctype (isspace);
+extern int isspace(int __c) __THROW;
libc_hidden_proto(isspace)
-__exctype (isupper);
+extern int isupper(int __c) __THROW;
libc_hidden_proto(isupper)
-__exctype (isxdigit);
+extern int isxdigit(int __c) __THROW;
libc_hidden_proto(isxdigit)
/* Return the lowercase version of C. */
-extern int tolower (int __c) __THROW;
+extern int tolower(int __c) __THROW;
libc_hidden_proto(tolower)
/* Return the uppercase version of C. */
-extern int toupper (int __c) __THROW;
+extern int toupper(int __c) __THROW;
libc_hidden_proto(toupper)
__END_NAMESPACE_STD
@@ -191,7 +188,7 @@ __END_NAMESPACE_STD
#ifdef __USE_ISOC99
__BEGIN_NAMESPACE_C99
-__exctype (isblank);
+extern int isblank(int __c) __THROW;
libc_hidden_proto(isblank)
__END_NAMESPACE_C99
@@ -199,44 +196,39 @@ __END_NAMESPACE_C99
#ifdef __USE_GNU
/* Test C for a set of character classes according to MASK. */
-extern int isctype (int __c, int __mask) __THROW;
+extern int isctype(int __c, int __mask) __THROW;
#endif
#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;
+extern int isascii(int __c) __THROW;
libc_hidden_proto(isascii)
-
/* 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;
-
+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);
+extern int _toupper(int __c) __THROW;
+extern int _tolower(int __c) __THROW;
#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; }))
-
+#define __tobody(c, f, table, args) \
+(__extension__ ({ \
+ int __res; \
+ if (sizeof(c) > 1) { \
+ if (__builtin_constant_p(c)) { \
+ int __c = (c); \
+ __res = __UCLIBC_CTYPE_IN_TO_DOMAIN(__c) ? (table)[__c] : __c; \
+ } else \
+ __res = f args; \
+ } else \
+ __res = (table)[(int) (c)]; \
+ __res; \
+}))
+
+#define __isctype(c, type) ((__UCLIBC_CTYPE_B)[(int)(c)] & (__ctype_mask_t)type)
#if !defined __NO_CTYPE && !defined __cplusplus
# define isalnum(c) __isctype((c), _ISalnum)
# define isalpha(c) __isctype((c), _ISalpha)
@@ -249,7 +241,6 @@ __exctype (_tolower);
# 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
@@ -260,7 +251,6 @@ __NTH (tolower (int __c))
{
return __UCLIBC_CTYPE_IN_TO_DOMAIN(__c) ? (__UCLIBC_CTYPE_TOLOWER)[__c] : __c;
}
-
__extern_inline int
__NTH (toupper (int __c))
{
@@ -269,14 +259,13 @@ __NTH (toupper (int __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))
+# 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
@@ -284,7 +273,7 @@ __NTH (toupper (int __c))
#endif /* Not __NO_CTYPE. */
-#if defined(__USE_GNU) && defined(__UCLIBC_HAS_XLOCALE__)
+#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
@@ -302,70 +291,61 @@ __NTH (toupper (int __c))
/* 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)] & (__ctype_mask_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);
+extern int isalnum_l(int, __locale_t) __THROW;
libc_hidden_proto(isalnum_l)
-__exctype_l (isalpha_l);
+extern int isalpha_l(int, __locale_t) __THROW;
libc_hidden_proto(isalpha_l)
-__exctype_l (iscntrl_l);
+extern int iscntrl_l(int, __locale_t) __THROW;
libc_hidden_proto(iscntrl_l)
-__exctype_l (isdigit_l);
+extern int isdigit_l(int, __locale_t) __THROW;
libc_hidden_proto(isdigit_l)
-__exctype_l (islower_l);
+extern int islower_l(int, __locale_t) __THROW;
libc_hidden_proto(islower_l)
-__exctype_l (isgraph_l);
+extern int isgraph_l(int, __locale_t) __THROW;
libc_hidden_proto(isgraph_l)
-__exctype_l (isprint_l);
+extern int isprint_l(int, __locale_t) __THROW;
libc_hidden_proto(isprint_l)
-__exctype_l (ispunct_l);
+extern int ispunct_l(int, __locale_t) __THROW;
libc_hidden_proto(ispunct_l)
-__exctype_l (isspace_l);
+extern int isspace_l(int, __locale_t) __THROW;
libc_hidden_proto(isspace_l)
-__exctype_l (isupper_l);
+extern int isupper_l(int, __locale_t) __THROW;
libc_hidden_proto(isupper_l)
-__exctype_l (isxdigit_l);
+extern int isxdigit_l(int, __locale_t) __THROW;
libc_hidden_proto(isxdigit_l)
-__exctype_l (isblank_l);
+extern int isblank_l(int, __locale_t) __THROW;
libc_hidden_proto(isblank_l)
-#if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN
+# 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_l (int __c) __THROW;
libc_hidden_proto(isascii_l)
-#endif
+# endif
/* Return the lowercase version of C in locale L. */
-extern int __tolower_l (int __c, __locale_t __l) __THROW;
+// "ordinary" ctype.h has no __tolower, why we try to have it?
+// remove after 0.9.31
+//extern int __tolower_l (int __c, __locale_t __l) __THROW;
extern int tolower_l (int __c, __locale_t __l) __THROW;
libc_hidden_proto(tolower_l)
/* 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;
extern int toupper_l (int __c, __locale_t __l) __THROW;
libc_hidden_proto(toupper_l)
# 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))
+# 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 */
+# define __isctype_l(c, type, locale) ((locale)->__ctype_b[(int) (c)] & (__ctype_mask_t) type)
# ifndef __NO_CTYPE
# define __isalnum_l(c,l) __isctype_l((c), _ISalnum, (l))
# define __isalpha_l(c,l) __isctype_l((c), _ISalpha, (l))
@@ -378,7 +358,6 @@ libc_hidden_proto(toupper_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
@@ -397,7 +376,6 @@ libc_hidden_proto(toupper_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))
# if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN
@@ -411,10 +389,6 @@ libc_hidden_proto(toupper_l)
__END_DECLS
-#else /* __UCLIBC_HAS_CTYPE_TABLES__ */
-
-#include <bits/uClibc_ctype.h>
-
-#endif
+#endif /* __UCLIBC_HAS_CTYPE_TABLES__ */
#endif /* ctype.h */
diff --git a/include/xlocale.h b/include/xlocale.h
index 6f726fef9..de80f72a3 100644
--- a/include/xlocale.h
+++ b/include/xlocale.h
@@ -25,7 +25,7 @@
#ifndef __UCLIBC_HAS_XLOCALE__
#error Attempted to include xlocale.h when uClibc built without extended locale support.
-#endif /* __UCLIBC_HAS_XLOCALE__ */
+#endif
#include <bits/uClibc_locale.h>
/* #include <bits/uClibc_touplow.h> */