|
Message-Id: <1318260629.591757.21186@legion> Date: Mon, 10 Oct 2011 16:12:59 +0200 From: Arvid Ephraim Picciani <arvid.picciani@...ia.com> To: <musl@...ts.openwall.com> Subject: [PATCH 2/2] Implement quite some more _l functions as wrapper around the non _l This is partially a hack, as the locale will be ignored. It is to be seen how much effect this actually has in real life use. --- include/stdlib.h | 14 ++++++++++++++ include/string.h | 11 +++++++++++ include/time.h | 7 +++++++ include/wchar.h | 23 +++++++++++++++++++++++ include/xlocale.h | 1 + src/ctype/iswalnum_l.c | 7 +++++++ src/ctype/iswalpha_l.c | 7 +++++++ src/ctype/iswblank_l.c | 7 +++++++ src/ctype/iswcntrl_l.c | 7 +++++++ src/ctype/iswdigit_l.c | 7 +++++++ src/ctype/iswgraph_l.c | 7 +++++++ src/ctype/iswlower_l.c | 7 +++++++ src/ctype/iswprint_l.c | 7 +++++++ src/ctype/iswpunct_l.c | 7 +++++++ src/ctype/iswspace_l.c | 7 +++++++ src/ctype/iswupper_l.c | 7 +++++++ src/ctype/iswxdigit_l.c | 7 +++++++ src/ctype/towctrans.c | 10 ++++++++++ src/locale/wcscoll_l.c | 7 +++++++ src/locale/wcsxfrm_l.c | 7 +++++++ src/stdlib/strtol_l.c | 6 ++++++ src/stdlib/strtold_l.c | 7 +++++++ src/stdlib/strtoll_l.c | 6 ++++++ src/stdlib/strtoul_l.c | 6 ++++++ src/stdlib/strtoull_l.c | 6 ++++++ src/string/strcoll_l.c | 7 +++++++ src/string/strxfrm_l.c | 7 +++++++ src/time/strftime_l.c | 7 +++++++ 28 files changed, 216 insertions(+), 0 deletions(-) create mode 100644 include/xlocale.h create mode 100644 src/ctype/iswalnum_l.c create mode 100644 src/ctype/iswalpha_l.c create mode 100644 src/ctype/iswblank_l.c create mode 100644 src/ctype/iswcntrl_l.c create mode 100644 src/ctype/iswdigit_l.c create mode 100644 src/ctype/iswgraph_l.c create mode 100644 src/ctype/iswlower_l.c create mode 100644 src/ctype/iswprint_l.c create mode 100644 src/ctype/iswpunct_l.c create mode 100644 src/ctype/iswspace_l.c create mode 100644 src/ctype/iswupper_l.c create mode 100644 src/ctype/iswxdigit_l.c create mode 100644 src/locale/wcscoll_l.c create mode 100644 src/locale/wcsxfrm_l.c create mode 100644 src/stdlib/strtol_l.c create mode 100644 src/stdlib/strtold_l.c create mode 100644 src/stdlib/strtoll_l.c create mode 100644 src/stdlib/strtoul_l.c create mode 100644 src/stdlib/strtoull_l.c create mode 100644 src/string/strcoll_l.c create mode 100644 src/string/strxfrm_l.c create mode 100644 src/time/strftime_l.c diff --git a/include/stdlib.h b/include/stdlib.h index 43225dd..056fc04 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -137,6 +137,20 @@ int ptsname_r(int, char *, size_t); #endif +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) + +#define __NEED_locale_t +#include <bits/alltypes.h> + +long strtol_l (const char *, char **, int, locale_t); +unsigned long strtoul_l (const char *, char **, int, locale_t); +long long strtoll_l (const char *, char **, int, locale_t); +unsigned long long strtoull_l (const char *, char **, int, locale_t); +long double strtold_l (const char *, char **, locale_t); +#endif + + #ifdef __cplusplus } #endif diff --git a/include/string.h b/include/string.h index a5b5a51..bce3770 100644 --- a/include/string.h +++ b/include/string.h @@ -79,6 +79,17 @@ void *memrchr(const void *, int, size_t); void *mempcpy(void *, const void *, size_t); #endif + +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) + +#define __NEED_locale_t +#include <bits/alltypes.h> +int strcoll_l (const char *, const char *, locale_t); +size_t strxfrm_l (char *, const char *, size_t, locale_t); +#endif + + #ifdef __cplusplus } #endif diff --git a/include/time.h b/include/time.h index 557c8f4..dd5d6e5 100644 --- a/include/time.h +++ b/include/time.h @@ -104,6 +104,13 @@ extern int getdate_err; struct tm *getdate (const char *); #endif +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) + +#define __NEED_locale_t +#include <bits/alltypes.h> +size_t strftime_l (char *, size_t, const char *, const struct tm *, locale_t); +#endif #ifdef __cplusplus } diff --git a/include/wchar.h b/include/wchar.h index 87e244a..df7e08a 100644 --- a/include/wchar.h +++ b/include/wchar.h @@ -157,6 +157,29 @@ wctype_t wctype(const char *); #define iswdigit(a) ((unsigned)(a)-'0' < 10) #endif +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) + +#define __NEED_locale_t +#include <bits/alltypes.h> +int wcscoll_l(const wchar_t *, const wchar_t *, locale_t); +size_t wcsxfrm_l (wchar_t *, const wchar_t *, size_t n, locale_t); +int iswalnum_l (wint_t, locale_t); +int iswalpha_l (wint_t, locale_t); +int iswblank_l (wint_t, locale_t); +int iswcntrl_l (wint_t, locale_t); +int iswdigit_l (wint_t, locale_t); +int iswgraph_l (wint_t, locale_t); +int iswlower_l (wint_t, locale_t); +int iswprint_l (wint_t, locale_t); +int iswpunct_l (wint_t, locale_t); +int iswspace_l (wint_t, locale_t); +int iswupper_l (wint_t, locale_t); +int iswxdigit_l (wint_t, locale_t); +wint_t towlower_l (wint_t, locale_t); +wint_t towupper_l (wint_t, locale_t); +#endif + #ifdef __cplusplus } #endif diff --git a/include/xlocale.h b/include/xlocale.h new file mode 100644 index 0000000..6088bbe --- /dev/null +++ b/include/xlocale.h @@ -0,0 +1 @@ +#include "locale.h" diff --git a/src/ctype/iswalnum_l.c b/src/ctype/iswalnum_l.c new file mode 100644 index 0000000..a84bb8d --- /dev/null +++ b/src/ctype/iswalnum_l.c @@ -0,0 +1,7 @@ +#include "wchar.h" +#include "wctype.h" + +int iswalnum_l (wint_t c, locale_t l) +{ + return iswalnum(c); +} diff --git a/src/ctype/iswalpha_l.c b/src/ctype/iswalpha_l.c new file mode 100644 index 0000000..b98dffa --- /dev/null +++ b/src/ctype/iswalpha_l.c @@ -0,0 +1,7 @@ +#include "wchar.h" +#include "wctype.h" + +int iswalpha_l (wint_t c, locale_t l) +{ + return iswalpha(c); +} diff --git a/src/ctype/iswblank_l.c b/src/ctype/iswblank_l.c new file mode 100644 index 0000000..203bf31 --- /dev/null +++ b/src/ctype/iswblank_l.c @@ -0,0 +1,7 @@ +#include "wchar.h" +#include "wctype.h" + +int iswblank_l (wint_t c, locale_t l) +{ + return iswblank(c); +} diff --git a/src/ctype/iswcntrl_l.c b/src/ctype/iswcntrl_l.c new file mode 100644 index 0000000..e246064 --- /dev/null +++ b/src/ctype/iswcntrl_l.c @@ -0,0 +1,7 @@ +#include "wchar.h" +#include "wctype.h" + +int iswcntrl_l (wint_t c, locale_t l) +{ + return iswcntrl(c); +} diff --git a/src/ctype/iswdigit_l.c b/src/ctype/iswdigit_l.c new file mode 100644 index 0000000..ee49bb3 --- /dev/null +++ b/src/ctype/iswdigit_l.c @@ -0,0 +1,7 @@ +#include "wchar.h" +#include "wctype.h" + +int iswdigit_l (wint_t c, locale_t l) +{ + return iswdigit(c); +} diff --git a/src/ctype/iswgraph_l.c b/src/ctype/iswgraph_l.c new file mode 100644 index 0000000..44cf970 --- /dev/null +++ b/src/ctype/iswgraph_l.c @@ -0,0 +1,7 @@ +#include "wchar.h" +#include "wctype.h" + +int iswgraph_l (wint_t c, locale_t l) +{ + return iswgraph(c); +} diff --git a/src/ctype/iswlower_l.c b/src/ctype/iswlower_l.c new file mode 100644 index 0000000..67c4c52 --- /dev/null +++ b/src/ctype/iswlower_l.c @@ -0,0 +1,7 @@ +#include "wchar.h" +#include "wctype.h" + +int iswlower_l (wint_t c, locale_t l) +{ + return iswlower(c); +} diff --git a/src/ctype/iswprint_l.c b/src/ctype/iswprint_l.c new file mode 100644 index 0000000..89b39df --- /dev/null +++ b/src/ctype/iswprint_l.c @@ -0,0 +1,7 @@ +#include "wchar.h" +#include "wctype.h" + +int iswprint_l (wint_t c, locale_t l) +{ + return iswprint(c); +} diff --git a/src/ctype/iswpunct_l.c b/src/ctype/iswpunct_l.c new file mode 100644 index 0000000..48a9cfc --- /dev/null +++ b/src/ctype/iswpunct_l.c @@ -0,0 +1,7 @@ +#include "wchar.h" +#include "wctype.h" + +int iswpunct_l (wint_t c, locale_t l) +{ + return iswpunct(c); +} diff --git a/src/ctype/iswspace_l.c b/src/ctype/iswspace_l.c new file mode 100644 index 0000000..216af23 --- /dev/null +++ b/src/ctype/iswspace_l.c @@ -0,0 +1,7 @@ +#include "wchar.h" +#include "wctype.h" + +int iswspace_l (wint_t c, locale_t l) +{ + return iswspace(c); +} diff --git a/src/ctype/iswupper_l.c b/src/ctype/iswupper_l.c new file mode 100644 index 0000000..5982136 --- /dev/null +++ b/src/ctype/iswupper_l.c @@ -0,0 +1,7 @@ +#include "wchar.h" +#include "wctype.h" + +int iswupper_l (wint_t c, locale_t l) +{ + return iswupper(c); +} diff --git a/src/ctype/iswxdigit_l.c b/src/ctype/iswxdigit_l.c new file mode 100644 index 0000000..4aac280 --- /dev/null +++ b/src/ctype/iswxdigit_l.c @@ -0,0 +1,7 @@ +#include "wchar.h" +#include "wctype.h" + +int iswxdigit_l (wint_t c, locale_t l) +{ + return iswxdigit(c); +} diff --git a/src/ctype/towctrans.c b/src/ctype/towctrans.c index 0b1eed0..8d98657 100644 --- a/src/ctype/towctrans.c +++ b/src/ctype/towctrans.c @@ -244,3 +244,13 @@ wint_t towlower(wint_t wc) { return __towcase(wc, 1); } + +wint_t towupper_l(wint_t wc, locale_t l) +{ + return __towcase(wc, 0); +} + +wint_t towlower_l(wint_t wc, locale_t l) +{ + return __towcase(wc, 1); +} diff --git a/src/locale/wcscoll_l.c b/src/locale/wcscoll_l.c new file mode 100644 index 0000000..2c70881 --- /dev/null +++ b/src/locale/wcscoll_l.c @@ -0,0 +1,7 @@ +#include <wchar.h> + +int wcscoll_l(const wchar_t *n, const wchar_t *r, locale_t l) +{ + return wcscmp(n, r); +} + diff --git a/src/locale/wcsxfrm_l.c b/src/locale/wcsxfrm_l.c new file mode 100644 index 0000000..f8a89b2 --- /dev/null +++ b/src/locale/wcsxfrm_l.c @@ -0,0 +1,7 @@ +#include "wchar.h" +#include "wctype.h" + +size_t wcsxfrm_l(wchar_t *dest, const wchar_t *src, size_t n, locale_t l) +{ + return wcsxfrm(dest, src, n); +} diff --git a/src/stdlib/strtol_l.c b/src/stdlib/strtol_l.c new file mode 100644 index 0000000..ce6c9b1 --- /dev/null +++ b/src/stdlib/strtol_l.c @@ -0,0 +1,6 @@ +#include <stdlib.h> + +long strtol_l (const char *n, char **end, int base, locale_t l) +{ + return strtol(n, end, base); +} diff --git a/src/stdlib/strtold_l.c b/src/stdlib/strtold_l.c new file mode 100644 index 0000000..4aabb7f --- /dev/null +++ b/src/stdlib/strtold_l.c @@ -0,0 +1,7 @@ +#include <stdlib.h> + +long double strtold_l (const char *n, char **end, locale_t l) +{ + return strtold(n, end); +} + diff --git a/src/stdlib/strtoll_l.c b/src/stdlib/strtoll_l.c new file mode 100644 index 0000000..0dbe6bc --- /dev/null +++ b/src/stdlib/strtoll_l.c @@ -0,0 +1,6 @@ +#include <stdlib.h> + +long long strtoll_l(const char *n, char **end, int base, locale_t l) +{ + return strtoll(n, end, base); +} diff --git a/src/stdlib/strtoul_l.c b/src/stdlib/strtoul_l.c new file mode 100644 index 0000000..34dafc0 --- /dev/null +++ b/src/stdlib/strtoul_l.c @@ -0,0 +1,6 @@ +#include <stdlib.h> + +unsigned long strtoul_l(const char *n, char **end, int base, locale_t l) +{ + return strtoul(n, end, base); +} diff --git a/src/stdlib/strtoull_l.c b/src/stdlib/strtoull_l.c new file mode 100644 index 0000000..de9ffd2 --- /dev/null +++ b/src/stdlib/strtoull_l.c @@ -0,0 +1,6 @@ +#include <stdlib.h> + +unsigned long long strtoull_l(const char *n, char **end, int base, locale_t l) +{ + return strtoull(n, end, base); +} diff --git a/src/string/strcoll_l.c b/src/string/strcoll_l.c new file mode 100644 index 0000000..b36a088 --- /dev/null +++ b/src/string/strcoll_l.c @@ -0,0 +1,7 @@ +#include <string.h> + +int strcoll_l(const char *s1, const char *s2, locale_t l) +{ + return strcoll(s1, s2); +} + diff --git a/src/string/strxfrm_l.c b/src/string/strxfrm_l.c new file mode 100644 index 0000000..b48b1bc --- /dev/null +++ b/src/string/strxfrm_l.c @@ -0,0 +1,7 @@ +#include <string.h> + +size_t strxfrm_l(char *dest, const char *src, size_t n, locale_t l) +{ + return strxfrm(dest, src, n); +} + diff --git a/src/time/strftime_l.c b/src/time/strftime_l.c new file mode 100644 index 0000000..8225142 --- /dev/null +++ b/src/time/strftime_l.c @@ -0,0 +1,7 @@ +#include "time.h" + +size_t strftime_l(char *s, size_t max, const char *format, const struct tm *tm, locale_t l) +{ + return strftime(s, max, format, tm); +} + -- 1.7.7
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.