mirror of https://git.musl-libc.org/git/musl
Browse Source
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.master
61 changed files with 256 additions and 213 deletions
@ -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); |
|||
|
|||
@ -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); |
|||
|
|||
@ -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); |
|||
|
|||
@ -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); |
|||
|
|||
@ -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); |
|||
|
|||
@ -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); |
|||
|
|||
@ -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); |
|||
|
|||
@ -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); |
|||
|
|||
@ -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); |
|||
|
|||
@ -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); |
|||
|
|||
@ -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); |
|||
|
|||
@ -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); |
|||
|
|||
@ -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); |
|||
|
|||
@ -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); |
|||
|
|||
@ -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); |
|||
|
|||
@ -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); |
|||
|
|||
@ -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); |
|||
|
|||
@ -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); |
|||
|
|||
@ -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); |
|||
|
|||
@ -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); |
|||
|
|||
@ -1,6 +0,0 @@ |
|||
#include <ctype.h> |
|||
|
|||
int isalnum_l(int c, locale_t l) |
|||
{ |
|||
return isalnum(c); |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
#include <ctype.h> |
|||
|
|||
int isalpha_l(int c, locale_t l) |
|||
{ |
|||
return isalpha(c); |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
#include <ctype.h> |
|||
|
|||
int isblank_l(int c, locale_t l) |
|||
{ |
|||
return isblank(c); |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
#include <ctype.h> |
|||
|
|||
int iscntrl_l(int c, locale_t l) |
|||
{ |
|||
return iscntrl(c); |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
#include <ctype.h> |
|||
|
|||
int isdigit_l(int c, locale_t l) |
|||
{ |
|||
return isdigit(c); |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
#include <ctype.h> |
|||
|
|||
int isgraph_l(int c, locale_t l) |
|||
{ |
|||
return isgraph(c); |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
#include <ctype.h> |
|||
|
|||
int islower_l(int c, locale_t l) |
|||
{ |
|||
return islower(c); |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
#include <ctype.h> |
|||
|
|||
int isprint_l(int c, locale_t l) |
|||
{ |
|||
return isprint(c); |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
#include <ctype.h> |
|||
|
|||
int ispunct_l(int c, locale_t l) |
|||
{ |
|||
return ispunct(c); |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
#include <ctype.h> |
|||
|
|||
int isspace_l(int c, locale_t l) |
|||
{ |
|||
return isspace(c); |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
#include <ctype.h> |
|||
|
|||
int isupper_l(int c, locale_t l) |
|||
{ |
|||
return isupper(c); |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
#include <wctype.h> |
|||
|
|||
int iswalnum_l(wint_t c, locale_t l) |
|||
{ |
|||
return iswalnum(c); |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
#include <wctype.h> |
|||
|
|||
int iswalpha_l(wint_t c, locale_t l) |
|||
{ |
|||
return iswalpha(c); |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
#include <wctype.h> |
|||
|
|||
int iswblank_l(wint_t c, locale_t l) |
|||
{ |
|||
return iswblank(c); |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
#include <wctype.h> |
|||
|
|||
int iswcntrl_l(wint_t c, locale_t l) |
|||
{ |
|||
return iswcntrl(c); |
|||
} |
|||
@ -1,9 +0,0 @@ |
|||
#include <wctype.h> |
|||
#include "libc.h" |
|||
|
|||
int iswctype_l(wint_t c, wctype_t t, locale_t l) |
|||
{ |
|||
return iswctype(c, t); |
|||
} |
|||
|
|||
weak_alias(iswctype_l, __iswctype_l); |
|||
@ -1,6 +0,0 @@ |
|||
#include <wctype.h> |
|||
|
|||
int iswdigit_l(wint_t c, locale_t l) |
|||
{ |
|||
return iswdigit(c); |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
#include <wctype.h> |
|||
|
|||
int iswgraph_l(wint_t c, locale_t l) |
|||
{ |
|||
return iswgraph(c); |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
#include <wctype.h> |
|||
|
|||
int iswlower_l(wint_t c, locale_t l) |
|||
{ |
|||
return iswlower(c); |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
#include <wctype.h> |
|||
|
|||
int iswprint_l(wint_t c, locale_t l) |
|||
{ |
|||
return iswprint(c); |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
#include <wctype.h> |
|||
|
|||
int iswpunct_l(wint_t c, locale_t l) |
|||
{ |
|||
return iswpunct(c); |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
#include <wctype.h> |
|||
|
|||
int iswspace_l(wint_t c, locale_t l) |
|||
{ |
|||
return iswspace(c); |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
#include <wctype.h> |
|||
|
|||
int iswupper_l(wint_t c, locale_t l) |
|||
{ |
|||
return iswupper(c); |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
#include <wctype.h> |
|||
|
|||
int iswxdigit_l(wint_t c, locale_t l) |
|||
{ |
|||
return iswxdigit(c); |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
#include <ctype.h> |
|||
|
|||
int isxdigit_l(int c, locale_t l) |
|||
{ |
|||
return isxdigit(c); |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
#include <ctype.h> |
|||
|
|||
int tolower_l(int c, locale_t l) |
|||
{ |
|||
return tolower(c); |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
#include <ctype.h> |
|||
|
|||
int toupper_l(int c, locale_t l) |
|||
{ |
|||
return toupper(c); |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
#include <wctype.h> |
|||
|
|||
wint_t towctrans_l(wint_t c, wctrans_t t, locale_t l) |
|||
{ |
|||
return towctrans(c, t); |
|||
} |
|||
@ -1,9 +0,0 @@ |
|||
#include <wctype.h> |
|||
#include "libc.h" |
|||
|
|||
wint_t towlower_l(wint_t c, locale_t l) |
|||
{ |
|||
return towlower(c); |
|||
} |
|||
|
|||
weak_alias(towlower_l, __towlower_l); |
|||
@ -1,9 +0,0 @@ |
|||
#include <wctype.h> |
|||
#include "libc.h" |
|||
|
|||
wint_t towupper_l(wint_t c, locale_t l) |
|||
{ |
|||
return towupper(c); |
|||
} |
|||
|
|||
weak_alias(towupper_l, __towupper_l); |
|||
@ -1,6 +0,0 @@ |
|||
#include <wctype.h> |
|||
|
|||
wctrans_t wctrans_l(const char *s, locale_t l) |
|||
{ |
|||
return wctrans(s); |
|||
} |
|||
@ -1,9 +0,0 @@ |
|||
#include <wctype.h> |
|||
#include "libc.h" |
|||
|
|||
wctype_t wctype_l(const char *s, locale_t l) |
|||
{ |
|||
return wctype(s); |
|||
} |
|||
|
|||
weak_alias(wctype_l, __wctype_l); |
|||
Loading…
Reference in new issue