summaryrefslogtreecommitdiff
path: root/libc/misc
diff options
context:
space:
mode:
authorManuel Novoa III <mjn3@codepoet.org>2003-09-08 20:33:10 +0000
committerManuel Novoa III <mjn3@codepoet.org>2003-09-08 20:33:10 +0000
commitf2239854568a38296d1a632321c6fee97410692b (patch)
tree24f769283ecd09756812fd69a55b53f3feceb770 /libc/misc
parentc9781f6b04ed346407c0462488d2a4c425b69230 (diff)
Add back in table-less ctype funcs for those interested in minimizing
static build sizes and not needing wchar support. Add in a SUSv3 getopt as an option for those not needing gnu getopt. Again, mainly for the static linking crowd.
Diffstat (limited to 'libc/misc')
-rw-r--r--libc/misc/ctype/Makefile9
-rw-r--r--libc/misc/ctype/ctype.c89
2 files changed, 93 insertions, 5 deletions
diff --git a/libc/misc/ctype/Makefile b/libc/misc/ctype/Makefile
index 2f1dd65f0..dc73ba7e9 100644
--- a/libc/misc/ctype/Makefile
+++ b/libc/misc/ctype/Makefile
@@ -28,10 +28,13 @@ MSRC=ctype.c
MOBJ= isalnum.o isalpha.o isascii.o iscntrl.o isdigit.o \
isgraph.o islower.o isprint.o ispunct.o isspace.o \
isupper.o isxdigit.o toascii.o tolower.o toupper.o \
- isblank.o isctype.o isxlower.o isxupper.o \
- __C_ctype_b.o __C_ctype_tolower.o __C_ctype_toupper.o \
+ isblank.o isxlower.o isxupper.o
+
+ifeq ($(UCLIBC_HAS_CTYPE_TABLES),y)
+MOBJ += __C_ctype_b.o __C_ctype_tolower.o __C_ctype_toupper.o \
__ctype_b_loc.o __ctype_tolower_loc.o __ctype_toupper_loc.o \
- __ctype_assert.o
+ __ctype_assert.o isctype.o
+endif
MOBJx= isalnum_l.o isalpha_l.o isascii_l.o iscntrl_l.o isdigit_l.o \
isgraph_l.o islower_l.o isprint_l.o ispunct_l.o isspace_l.o \
diff --git a/libc/misc/ctype/ctype.c b/libc/misc/ctype/ctype.c
index 13095015d..65debd842 100644
--- a/libc/misc/ctype/ctype.c
+++ b/libc/misc/ctype/ctype.c
@@ -42,6 +42,7 @@
#endif /* __UCLIBC_HAS_XLOCALE__ */
/**********************************************************************/
+#ifdef __UCLIBC_HAS_CTYPE_TABLES__
#ifdef __UCLIBC_HAS_CTYPE_SIGNED__
@@ -65,6 +66,7 @@
#endif /* __UCLIBC_HAS_CTYPE_SIGNED__ */
+#endif /* __UCLIBC_HAS_CTYPE_TABLES__ */
/**********************************************************************/
#ifdef __UCLIBC_MJN3_ONLY__
#ifdef L_isspace
@@ -74,6 +76,11 @@
#warning TODO: Optimize the isx*() funcs.
#endif
#endif /* __UCLIBC_MJN3_ONLY__ */
+/**********************************************************************/
+#undef PASTE2
+#define PASTE2(X,Y) X ## Y
+
+#ifdef __UCLIBC_HAS_CTYPE_TABLES__
#undef CTYPE_NAME
#undef ISCTYPE
@@ -87,8 +94,6 @@
#define ISCTYPE(C,F) __isctype( C, F )
#define CTYPE_ALIAS(NAME)
#endif
-#undef PASTE2
-#define PASTE2(X,Y) X ## Y
#undef CTYPE_BODY
@@ -135,6 +140,18 @@ int CTYPE_NAME(NAME) (int c __LOCALE_PARAM ) \
CTYPE_ALIAS(NAME)
+#else /* __UCLIBC_HAS_CTYPE_TABLES__ */
+
+#define C_MACRO(X) PASTE2(__C_is,X)(c)
+#define CTYPE_NAME(X) is ## X
+
+#define IS_FUNC_BODY(NAME) \
+int CTYPE_NAME(NAME) (int c) \
+{ \
+ return C_MACRO(NAME); \
+}
+
+#endif /* __UCLIBC_HAS_CTYPE_TABLES__ */
/**********************************************************************/
#ifdef L___ctype_assert
#ifdef __UCLIBC_HAS_CTYPE_ENFORCED__
@@ -176,6 +193,8 @@ IS_FUNC_BODY(cntrl);
/**********************************************************************/
#if defined(L_isdigit) || defined(L_isdigit_l)
+#ifdef __UCLIBC_HAS_CTYPE_TABLES__
+
/* The standards require EOF < 0. */
#if EOF >= CHAR_MIN
#define __isdigit_char_or_EOF(C) __isdigit_char((C))
@@ -197,6 +216,12 @@ int CTYPE_NAME(digit) (int C __LOCALE_PARAM)
CTYPE_ALIAS(digit)
+#else /* __UCLIBC_HAS_CTYPE_TABLES__ */
+
+IS_FUNC_BODY(digit);
+
+#endif /* __UCLIBC_HAS_CTYPE_TABLES__ */
+
#endif
/**********************************************************************/
#if defined(L_isgraph) || defined(L_isgraph_l)
@@ -243,6 +268,8 @@ IS_FUNC_BODY(xdigit);
/**********************************************************************/
#ifdef L_tolower
+#ifdef __UCLIBC_HAS_CTYPE_TABLES__
+
int tolower(int c)
{
#if defined(__UCLIBC_HAS_CTYPE_ENFORCED__)
@@ -251,6 +278,15 @@ int tolower(int c)
return __UCLIBC_CTYPE_IN_TO_DOMAIN(c) ? (__UCLIBC_CTYPE_TOLOWER)[c] : c;
}
+#else /* __UCLIBC_HAS_CTYPE_TABLES__ */
+
+int tolower(int c)
+{
+ return __C_tolower(c);
+}
+
+#endif /* __UCLIBC_HAS_CTYPE_TABLES__ */
+
#endif
/**********************************************************************/
#ifdef L_tolower_l
@@ -272,6 +308,8 @@ weak_alias(__tolower_l, tolower_l)
/**********************************************************************/
#ifdef L_toupper
+#ifdef __UCLIBC_HAS_CTYPE_TABLES__
+
int toupper(int c)
{
#if defined(__UCLIBC_HAS_CTYPE_ENFORCED__)
@@ -280,6 +318,15 @@ int toupper(int c)
return __UCLIBC_CTYPE_IN_TO_DOMAIN(c) ? (__UCLIBC_CTYPE_TOUPPER)[c] : c;
}
+#else /* __UCLIBC_HAS_CTYPE_TABLES__ */
+
+int toupper(int c)
+{
+ return __C_toupper(c);
+}
+
+#endif /* __UCLIBC_HAS_CTYPE_TABLES__ */
+
#endif
/**********************************************************************/
#ifdef L_toupper_l
@@ -301,6 +348,8 @@ weak_alias(__toupper_l, toupper_l)
/**********************************************************************/
#if defined(L_isascii) || defined(L_isascii_l)
+#ifdef __UCLIBC_HAS_CTYPE_TABLES__
+
int __XL(isascii)(int c)
{
return __isascii(c); /* locale-independent */
@@ -308,10 +357,21 @@ int __XL(isascii)(int c)
__XL_ALIAS(isascii)
+#else /* __UCLIBC_HAS_CTYPE_TABLES__ */
+
+int isascii(int c)
+{
+ return __isascii(c); /* locale-independent */
+}
+
+#endif /* __UCLIBC_HAS_CTYPE_TABLES__ */
+
#endif
/**********************************************************************/
#if defined(L_toascii) || defined(L_toascii_l)
+#ifdef __UCLIBC_HAS_CTYPE_TABLES__
+
int __XL(toascii)(int c)
{
return __toascii(c); /* locale-independent */
@@ -319,12 +379,23 @@ int __XL(toascii)(int c)
__XL_ALIAS(toascii)
+#else /* __UCLIBC_HAS_CTYPE_TABLES__ */
+
+int toascii(int c)
+{
+ return __toascii(c); /* locale-independent */
+}
+
+#endif /* __UCLIBC_HAS_CTYPE_TABLES__ */
+
#endif
/**********************************************************************/
/* old uClibc extensions */
/**********************************************************************/
#ifdef L_isxlower
+#ifdef __UCLIBC_HAS_CTYPE_TABLES__
+
int isxlower(int C)
{
#if defined(__UCLIBC_HAS_CTYPE_ENFORCED__)
@@ -341,10 +412,18 @@ int isxlower(int C)
#endif
}
+#else /* __UCLIBC_HAS_CTYPE_TABLES__ */
+
+IS_FUNC_BODY(xlower);
+
+#endif /* __UCLIBC_HAS_CTYPE_TABLES__ */
+
#endif
/**********************************************************************/
#ifdef L_isxupper
+#ifdef __UCLIBC_HAS_CTYPE_TABLES__
+
int isxupper(int C)
{
#if defined(__UCLIBC_HAS_CTYPE_ENFORCED__)
@@ -361,6 +440,12 @@ int isxupper(int C)
#endif
}
+#else /* __UCLIBC_HAS_CTYPE_TABLES__ */
+
+IS_FUNC_BODY(xupper);
+
+#endif /* __UCLIBC_HAS_CTYPE_TABLES__ */
+
#endif
/**********************************************************************/
/* glibc extensions */