summaryrefslogtreecommitdiff
path: root/src/ctype
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2014-07-02 21:16:05 -0400
committerRich Felker <dalias@aerifal.cx>2014-07-02 21:16:05 -0400
commitd89fdec51b5849ebdf8000ff1c2fb49878004f39 (patch)
tree3f417d463f914ba78c594ca44d9e9c0fb0f629e4 /src/ctype
parent0bc03091bb674ebb9fa6fe69e4aec1da3ac484f2 (diff)
downloadmusl-d89fdec51b5849ebdf8000ff1c2fb49878004f39.tar.gz
consolidate *_l ctype/wctype functions into their non-_l source files
the main practical purposes of this commit are to remove a huge amount of clutter from the src/locale directory, to cut down on the length of the $(AR) and $(LD) command lines, and to reduce the amount of space wasted by object file headers in the static libc.a. build time may also be reduced, though this has not been measured. as an additional justification, if there ever were a need for the behavior of these functions to vary by locale, it would be necessary for the non-_l versions to call the _l versions, so that linking the former without the latter would not be possible anyway.
Diffstat (limited to 'src/ctype')
-rw-r--r--src/ctype/isalnum.c8
-rw-r--r--src/ctype/isalpha.c8
-rw-r--r--src/ctype/isblank.c8
-rw-r--r--src/ctype/iscntrl.c8
-rw-r--r--src/ctype/isdigit.c8
-rw-r--r--src/ctype/isgraph.c11
-rw-r--r--src/ctype/islower.c8
-rw-r--r--src/ctype/isprint.c11
-rw-r--r--src/ctype/ispunct.c8
-rw-r--r--src/ctype/isspace.c8
-rw-r--r--src/ctype/isupper.c8
-rw-r--r--src/ctype/iswalnum.c9
-rw-r--r--src/ctype/iswalpha.c8
-rw-r--r--src/ctype/iswblank.c9
-rw-r--r--src/ctype/iswcntrl.c9
-rw-r--r--src/ctype/iswctype.c15
-rw-r--r--src/ctype/iswdigit.c9
-rw-r--r--src/ctype/iswgraph.c8
-rw-r--r--src/ctype/iswlower.c8
-rw-r--r--src/ctype/iswprint.c8
-rw-r--r--src/ctype/iswpunct.c8
-rw-r--r--src/ctype/iswspace.c9
-rw-r--r--src/ctype/iswupper.c8
-rw-r--r--src/ctype/iswxdigit.c9
-rw-r--r--src/ctype/isxdigit.c8
-rw-r--r--src/ctype/tolower.c8
-rw-r--r--src/ctype/toupper.c8
-rw-r--r--src/ctype/towctrans.c16
-rw-r--r--src/ctype/wctrans.c14
29 files changed, 256 insertions, 9 deletions
diff --git a/src/ctype/isalnum.c b/src/ctype/isalnum.c
index e3d2cf0b..2214936f 100644
--- a/src/ctype/isalnum.c
+++ b/src/ctype/isalnum.c
@@ -1,6 +1,14 @@
#include <ctype.h>
+#include "libc.h"
int isalnum(int c)
{
return isalpha(c) || isdigit(c);
}
+
+int __isalnum_l(int c, locale_t l)
+{
+ return isalnum(c);
+}
+
+weak_alias(__isalnum_l, isalnum_l);
diff --git a/src/ctype/isalpha.c b/src/ctype/isalpha.c
index 53e115c2..f155d3aa 100644
--- a/src/ctype/isalpha.c
+++ b/src/ctype/isalpha.c
@@ -1,7 +1,15 @@
#include <ctype.h>
+#include "libc.h"
#undef isalpha
int isalpha(int c)
{
return ((unsigned)c|32)-'a' < 26;
}
+
+int __isalpha_l(int c, locale_t l)
+{
+ return isalpha(c);
+}
+
+weak_alias(__isalpha_l, isalpha_l);
diff --git a/src/ctype/isblank.c b/src/ctype/isblank.c
index 957400b2..299120e9 100644
--- a/src/ctype/isblank.c
+++ b/src/ctype/isblank.c
@@ -1,6 +1,14 @@
#include <ctype.h>
+#include "libc.h"
int isblank(int c)
{
return (c == ' ' || c == '\t');
}
+
+int __isblank_l(int c, locale_t l)
+{
+ return isblank(c);
+}
+
+weak_alias(__isblank_l, isblank_l);
diff --git a/src/ctype/iscntrl.c b/src/ctype/iscntrl.c
index 92ed7f0e..cb4114a0 100644
--- a/src/ctype/iscntrl.c
+++ b/src/ctype/iscntrl.c
@@ -1,6 +1,14 @@
#include <ctype.h>
+#include "libc.h"
int iscntrl(int c)
{
return (unsigned)c < 0x20 || c == 0x7f;
}
+
+int __iscntrl_l(int c, locale_t l)
+{
+ return iscntrl(c);
+}
+
+weak_alias(__iscntrl_l, iscntrl_l);
diff --git a/src/ctype/isdigit.c b/src/ctype/isdigit.c
index 0bc82a6d..4d8a103e 100644
--- a/src/ctype/isdigit.c
+++ b/src/ctype/isdigit.c
@@ -1,7 +1,15 @@
#include <ctype.h>
+#include "libc.h"
#undef isdigit
int isdigit(int c)
{
return (unsigned)c-'0' < 10;
}
+
+int __isdigit_l(int c, locale_t l)
+{
+ return isdigit(c);
+}
+
+weak_alias(__isdigit_l, isdigit_l);
diff --git a/src/ctype/isgraph.c b/src/ctype/isgraph.c
index 98979d1e..a0aae08a 100644
--- a/src/ctype/isgraph.c
+++ b/src/ctype/isgraph.c
@@ -1,4 +1,15 @@
+#include <ctype.h>
+#include "libc.h"
+#undef isgraph
+
int isgraph(int c)
{
return (unsigned)c-0x21 < 0x5e;
}
+
+int __isgraph_l(int c, locale_t l)
+{
+ return isgraph(c);
+}
+
+weak_alias(__isgraph_l, isgraph_l);
diff --git a/src/ctype/islower.c b/src/ctype/islower.c
index d72fb212..02640213 100644
--- a/src/ctype/islower.c
+++ b/src/ctype/islower.c
@@ -1,7 +1,15 @@
#include <ctype.h>
+#include "libc.h"
#undef islower
int islower(int c)
{
return (unsigned)c-'a' < 26;
}
+
+int __islower_l(int c, locale_t l)
+{
+ return islower(c);
+}
+
+weak_alias(__islower_l, islower_l);
diff --git a/src/ctype/isprint.c b/src/ctype/isprint.c
index 504e66ed..067275fa 100644
--- a/src/ctype/isprint.c
+++ b/src/ctype/isprint.c
@@ -1,4 +1,15 @@
+#include <ctype.h>
+#include "libc.h"
+#undef isprint
+
int isprint(int c)
{
return (unsigned)c-0x20 < 0x5f;
}
+
+int __isprint_l(int c, locale_t l)
+{
+ return isprint(c);
+}
+
+weak_alias(__isprint_l, isprint_l);
diff --git a/src/ctype/ispunct.c b/src/ctype/ispunct.c
index fc455352..e772d76a 100644
--- a/src/ctype/ispunct.c
+++ b/src/ctype/ispunct.c
@@ -1,6 +1,14 @@
#include <ctype.h>
+#include "libc.h"
int ispunct(int c)
{
return isgraph(c) && !isalnum(c);
}
+
+int __ispunct_l(int c, locale_t l)
+{
+ return ispunct(c);
+}
+
+weak_alias(__ispunct_l, ispunct_l);
diff --git a/src/ctype/isspace.c b/src/ctype/isspace.c
index 8e535aa1..7dff20d0 100644
--- a/src/ctype/isspace.c
+++ b/src/ctype/isspace.c
@@ -1,6 +1,14 @@
#include <ctype.h>
+#include "libc.h"
int isspace(int c)
{
return c == ' ' || (unsigned)c-'\t' < 5;
}
+
+int __isspace_l(int c, locale_t l)
+{
+ return isspace(c);
+}
+
+weak_alias(__isspace_l, isspace_l);
diff --git a/src/ctype/isupper.c b/src/ctype/isupper.c
index f09d88c5..68c36f4a 100644
--- a/src/ctype/isupper.c
+++ b/src/ctype/isupper.c
@@ -1,7 +1,15 @@
#include <ctype.h>
+#include "libc.h"
#undef isupper
int isupper(int c)
{
return (unsigned)c-'A' < 26;
}
+
+int __isupper_l(int c, locale_t l)
+{
+ return isupper(c);
+}
+
+weak_alias(__isupper_l, isupper_l);
diff --git a/src/ctype/iswalnum.c b/src/ctype/iswalnum.c
index 35dbe02c..a6082da4 100644
--- a/src/ctype/iswalnum.c
+++ b/src/ctype/iswalnum.c
@@ -1,7 +1,14 @@
-#include <wchar.h>
#include <wctype.h>
+#include "libc.h"
int iswalnum(wint_t wc)
{
return iswdigit(wc) || iswalpha(wc);
}
+
+int __iswalnum_l(wint_t c, locale_t l)
+{
+ return iswalnum(c);
+}
+
+weak_alias(__iswalnum_l, iswalnum_l);
diff --git a/src/ctype/iswalpha.c b/src/ctype/iswalpha.c
index d558faef..00f9d81f 100644
--- a/src/ctype/iswalpha.c
+++ b/src/ctype/iswalpha.c
@@ -1,4 +1,5 @@
#include <wctype.h>
+#include "libc.h"
static const unsigned char table[] = {
#include "alpha.h"
@@ -12,3 +13,10 @@ int iswalpha(wint_t wc)
return 1;
return 0;
}
+
+int __iswalpha_l(wint_t c, locale_t l)
+{
+ return iswalpha(c);
+}
+
+weak_alias(__iswalpha_l, iswalpha_l);
diff --git a/src/ctype/iswblank.c b/src/ctype/iswblank.c
index bc6196f2..d9b33ef4 100644
--- a/src/ctype/iswblank.c
+++ b/src/ctype/iswblank.c
@@ -1,8 +1,15 @@
-#include <wchar.h>
#include <wctype.h>
#include <ctype.h>
+#include "libc.h"
int iswblank(wint_t wc)
{
return isblank(wc);
}
+
+int __iswblank_l(wint_t c, locale_t l)
+{
+ return iswblank(c);
+}
+
+weak_alias(__iswblank_l, iswblank_l);
diff --git a/src/ctype/iswcntrl.c b/src/ctype/iswcntrl.c
index 93942b08..daace82a 100644
--- a/src/ctype/iswcntrl.c
+++ b/src/ctype/iswcntrl.c
@@ -1,5 +1,5 @@
-#include <wchar.h>
#include <wctype.h>
+#include "libc.h"
int iswcntrl(wint_t wc)
{
@@ -8,3 +8,10 @@ int iswcntrl(wint_t wc)
|| (unsigned)(wc-0x2028) < 2
|| (unsigned)(wc-0xfff9) < 3;
}
+
+int __iswcntrl_l(wint_t c, locale_t l)
+{
+ return iswcntrl(c);
+}
+
+weak_alias(__iswcntrl_l, iswcntrl_l);
diff --git a/src/ctype/iswctype.c b/src/ctype/iswctype.c
index d917975b..3d9c2cc7 100644
--- a/src/ctype/iswctype.c
+++ b/src/ctype/iswctype.c
@@ -1,6 +1,6 @@
-#include <wchar.h>
#include <wctype.h>
#include <string.h>
+#include "libc.h"
#define WCTYPE_ALNUM 1
#define WCTYPE_ALPHA 2
@@ -61,3 +61,16 @@ wctype_t wctype(const char *s)
return i;
return 0;
}
+
+int __iswctype_l(wint_t c, wctype_t t, locale_t l)
+{
+ return iswctype(c, t);
+}
+
+wctype_t __wctype_l(const char *s, locale_t l)
+{
+ return wctype(s);
+}
+
+weak_alias(__iswctype_l, iswctype_l);
+weak_alias(__wctype_l, wctype_l);
diff --git a/src/ctype/iswdigit.c b/src/ctype/iswdigit.c
index 0487145f..ed9a88e7 100644
--- a/src/ctype/iswdigit.c
+++ b/src/ctype/iswdigit.c
@@ -1,5 +1,5 @@
-#include <wchar.h>
#include <wctype.h>
+#include "libc.h"
#undef iswdigit
@@ -7,3 +7,10 @@ int iswdigit(wint_t wc)
{
return (unsigned)wc-'0' < 10;
}
+
+int __iswdigit_l(wint_t c, locale_t l)
+{
+ return iswdigit(c);
+}
+
+weak_alias(__iswdigit_l, iswdigit_l);
diff --git a/src/ctype/iswgraph.c b/src/ctype/iswgraph.c
index fdc97853..0ea5ca3a 100644
--- a/src/ctype/iswgraph.c
+++ b/src/ctype/iswgraph.c
@@ -1,7 +1,15 @@
#include <wctype.h>
+#include "libc.h"
int iswgraph(wint_t wc)
{
/* ISO C defines this function as: */
return !iswspace(wc) && iswprint(wc);
}
+
+int __iswgraph_l(wint_t c, locale_t l)
+{
+ return iswgraph(c);
+}
+
+weak_alias(__iswgraph_l, iswgraph_l);
diff --git a/src/ctype/iswlower.c b/src/ctype/iswlower.c
index 438fe26a..c754fb95 100644
--- a/src/ctype/iswlower.c
+++ b/src/ctype/iswlower.c
@@ -1,6 +1,14 @@
#include <wctype.h>
+#include "libc.h"
int iswlower(wint_t wc)
{
return towupper(wc) != wc || wc == 0xdf;
}
+
+int __iswlower_l(wint_t c, locale_t l)
+{
+ return iswlower(c);
+}
+
+weak_alias(__iswlower_l, iswlower_l);
diff --git a/src/ctype/iswprint.c b/src/ctype/iswprint.c
index 333f19c2..69856e0d 100644
--- a/src/ctype/iswprint.c
+++ b/src/ctype/iswprint.c
@@ -1,4 +1,5 @@
#include <wctype.h>
+#include "libc.h"
/* Consider all legal codepoints as printable except for:
* - C0 and C1 control characters
@@ -17,3 +18,10 @@ int iswprint(wint_t wc)
return 0;
return 1;
}
+
+int __iswprint_l(wint_t c, locale_t l)
+{
+ return iswprint(c);
+}
+
+weak_alias(__iswprint_l, iswprint_l);
diff --git a/src/ctype/iswpunct.c b/src/ctype/iswpunct.c
index 16e8703b..d8801046 100644
--- a/src/ctype/iswpunct.c
+++ b/src/ctype/iswpunct.c
@@ -1,4 +1,5 @@
#include <wctype.h>
+#include "libc.h"
static const unsigned char table[] = {
#include "punct.h"
@@ -10,3 +11,10 @@ int iswpunct(wint_t wc)
return (table[table[wc>>8]*32+((wc&255)>>3)]>>(wc&7))&1;
return 0;
}
+
+int __iswpunct_l(wint_t c, locale_t l)
+{
+ return iswpunct(c);
+}
+
+weak_alias(__iswpunct_l, iswpunct_l);
diff --git a/src/ctype/iswspace.c b/src/ctype/iswspace.c
index b0c0ae18..75ae7e8e 100644
--- a/src/ctype/iswspace.c
+++ b/src/ctype/iswspace.c
@@ -1,6 +1,6 @@
#include <wchar.h>
#include <wctype.h>
-#include <ctype.h>
+#include "libc.h"
/* Our definition of whitespace is the Unicode White_Space property,
* minus non-breaking spaces (U+00A0, U+2007, and U+202F) and script-
@@ -16,3 +16,10 @@ int iswspace(wint_t wc)
};
return wc && wcschr(spaces, wc);
}
+
+int __iswspace_l(wint_t c, locale_t l)
+{
+ return iswspace(c);
+}
+
+weak_alias(__iswspace_l, iswspace_l);
diff --git a/src/ctype/iswupper.c b/src/ctype/iswupper.c
index eae59a75..6e1e029c 100644
--- a/src/ctype/iswupper.c
+++ b/src/ctype/iswupper.c
@@ -1,6 +1,14 @@
#include <wctype.h>
+#include "libc.h"
int iswupper(wint_t wc)
{
return towlower(wc) != wc;
}
+
+int __iswupper_l(wint_t c, locale_t l)
+{
+ return iswupper(c);
+}
+
+weak_alias(__iswupper_l, iswupper_l);
diff --git a/src/ctype/iswxdigit.c b/src/ctype/iswxdigit.c
index 229a469f..1e27f1f0 100644
--- a/src/ctype/iswxdigit.c
+++ b/src/ctype/iswxdigit.c
@@ -1,7 +1,14 @@
-#include <wchar.h>
#include <wctype.h>
+#include "libc.h"
int iswxdigit(wint_t wc)
{
return (unsigned)(wc-'0') < 10 || (unsigned)((wc|32)-'a') < 6;
}
+
+int __iswxdigit_l(wint_t c, locale_t l)
+{
+ return iswxdigit(c);
+}
+
+weak_alias(__iswxdigit_l, iswxdigit_l);
diff --git a/src/ctype/isxdigit.c b/src/ctype/isxdigit.c
index ae68a3dc..0e9152a7 100644
--- a/src/ctype/isxdigit.c
+++ b/src/ctype/isxdigit.c
@@ -1,6 +1,14 @@
#include <ctype.h>
+#include "libc.h"
int isxdigit(int c)
{
return isdigit(c) || ((unsigned)c|32)-'a' < 6;
}
+
+int __isxdigit_l(int c, locale_t l)
+{
+ return isxdigit(c);
+}
+
+weak_alias(__isxdigit_l, isxdigit_l);
diff --git a/src/ctype/tolower.c b/src/ctype/tolower.c
index b56f3c50..362d6b2b 100644
--- a/src/ctype/tolower.c
+++ b/src/ctype/tolower.c
@@ -1,7 +1,15 @@
#include <ctype.h>
+#include "libc.h"
int tolower(int c)
{
if (isupper(c)) return c | 32;
return c;
}
+
+int __tolower_l(int c, locale_t l)
+{
+ return tolower(c);
+}
+
+weak_alias(__tolower_l, tolower_l);
diff --git a/src/ctype/toupper.c b/src/ctype/toupper.c
index 1799f030..bbf4e06e 100644
--- a/src/ctype/toupper.c
+++ b/src/ctype/toupper.c
@@ -1,7 +1,15 @@
#include <ctype.h>
+#include "libc.h"
int toupper(int c)
{
if (islower(c)) return c & 0x5f;
return c;
}
+
+int __toupper_l(int c, locale_t l)
+{
+ return toupper(c);
+}
+
+weak_alias(__toupper_l, toupper_l);
diff --git a/src/ctype/towctrans.c b/src/ctype/towctrans.c
index 2842d690..5e0889b1 100644
--- a/src/ctype/towctrans.c
+++ b/src/ctype/towctrans.c
@@ -1,6 +1,5 @@
-#include <wchar.h>
#include <wctype.h>
-#include <stdio.h>
+#include "libc.h"
#define CASEMAP(u1,u2,l) { (u1), (l)-(u1), (u2)-(u1)+1 }
#define CASELACE(u1,u2) CASEMAP((u1),(u2),(u1)+1)
@@ -266,3 +265,16 @@ wint_t towlower(wint_t wc)
{
return __towcase(wc, 1);
}
+
+wint_t __towupper_l(wint_t c, locale_t l)
+{
+ return towupper(c);
+}
+
+wint_t __towlower_l(wint_t c, locale_t l)
+{
+ return towlower(c);
+}
+
+weak_alias(__towupper_l, towupper_l);
+weak_alias(__towlower_l, towlower_l);
diff --git a/src/ctype/wctrans.c b/src/ctype/wctrans.c
index 739869d0..b1b12654 100644
--- a/src/ctype/wctrans.c
+++ b/src/ctype/wctrans.c
@@ -1,5 +1,6 @@
#include <wctype.h>
#include <string.h>
+#include "libc.h"
wctrans_t wctrans(const char *class)
{
@@ -14,3 +15,16 @@ wint_t towctrans(wint_t wc, wctrans_t trans)
if (trans == (wctrans_t)2) return towlower(wc);
return wc;
}
+
+wctrans_t __wctrans_l(const char *s, locale_t l)
+{
+ return wctrans(s);
+}
+
+wint_t __towctrans_l(wint_t c, wctrans_t t, locale_t l)
+{
+ return towctrans(c, t);
+}
+
+weak_alias(__wctrans_l, wctrans_l);
+weak_alias(__towctrans_l, towctrans_l);