mirror of
git://git.musl-libc.org/musl
synced 2025-01-30 10:32:04 +00:00
add all missing wchar functions except floating point parsers
these are mostly untested and adapted directly from corresponding byte string functions and similar.
This commit is contained in:
parent
899b13cae7
commit
e0614f7cd4
@ -11,6 +11,11 @@ extern "C" {
|
|||||||
#define __NEED_wchar_t
|
#define __NEED_wchar_t
|
||||||
#define __NEED_wint_t
|
#define __NEED_wint_t
|
||||||
|
|
||||||
|
#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
|
||||||
|
|| defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE)
|
||||||
|
#define __NEED_locale_t
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE)
|
#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE)
|
||||||
#define __NEED_wctype_t
|
#define __NEED_wctype_t
|
||||||
#endif
|
#endif
|
||||||
@ -132,6 +137,16 @@ size_t wcsftime (wchar_t *, size_t, const wchar_t *, const struct tm *);
|
|||||||
FILE *open_wmemstream(wchar_t **, size_t *);
|
FILE *open_wmemstream(wchar_t **, size_t *);
|
||||||
size_t mbsnrtowcs(wchar_t *, const char **, size_t, size_t, mbstate_t *);
|
size_t mbsnrtowcs(wchar_t *, const char **, size_t, size_t, mbstate_t *);
|
||||||
size_t wcsnrtombs(char *, const wchar_t **, size_t, size_t, mbstate_t *);
|
size_t wcsnrtombs(char *, const wchar_t **, size_t, size_t, mbstate_t *);
|
||||||
|
wchar_t *wcsdup(const wchar_t *);
|
||||||
|
size_t wcsnlen (const wchar_t *, size_t);
|
||||||
|
wchar_t *wcpcpy (wchar_t *, const wchar_t *);
|
||||||
|
wchar_t *wcpncpy (wchar_t *, const wchar_t *, size_t);
|
||||||
|
int wcscasecmp(const wchar_t *, const wchar_t *);
|
||||||
|
int wcscasecmp_l(const wchar_t *, const wchar_t *, locale_t);
|
||||||
|
int wcsncasecmp(const wchar_t *, const wchar_t *, size_t);
|
||||||
|
int wcsncasecmp_l(const wchar_t *, const wchar_t *, size_t, locale_t);
|
||||||
|
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);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE)
|
#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE)
|
||||||
|
6
src/locale/wcscoll_l.c
Normal file
6
src/locale/wcscoll_l.c
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
|
int wcscoll_l(const wchar_t *l, const wchar_t *r, locale_t locale)
|
||||||
|
{
|
||||||
|
return wcscoll(l, r);
|
||||||
|
}
|
6
src/locale/wcsxfrm_l.c
Normal file
6
src/locale/wcsxfrm_l.c
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
|
size_t wcsxfrm_l(wchar_t *dest, const wchar_t *src, size_t n, locale_t locale)
|
||||||
|
{
|
||||||
|
return wcsxfrm(dest, src, n);
|
||||||
|
}
|
6
src/string/wcpcpy.c
Normal file
6
src/string/wcpcpy.c
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
|
wchar_t *wcpcpy(wchar_t *d, const wchar_t *s)
|
||||||
|
{
|
||||||
|
return wcscpy(d, s) + wcslen(s);
|
||||||
|
}
|
6
src/string/wcpncpy.c
Normal file
6
src/string/wcpncpy.c
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
|
wchar_t *wcpncpy(wchar_t *d, const wchar_t *s, size_t n)
|
||||||
|
{
|
||||||
|
return wcsncpy(d, s, n) + wcsnlen(s, n);
|
||||||
|
}
|
7
src/string/wcscasecmp.c
Normal file
7
src/string/wcscasecmp.c
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#include <wchar.h>
|
||||||
|
#include <wctype.h>
|
||||||
|
|
||||||
|
int wcscasecmp(const wchar_t *l, const wchar_t *r)
|
||||||
|
{
|
||||||
|
return wcsncasecmp(l, r, -1);
|
||||||
|
}
|
6
src/string/wcscasecmp_l.c
Normal file
6
src/string/wcscasecmp_l.c
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
|
int wcscasecmp_l(const wchar_t *l, const wchar_t *r, locale_t locale)
|
||||||
|
{
|
||||||
|
return wcscasecmp(l, r);
|
||||||
|
}
|
11
src/string/wcsdup.c
Normal file
11
src/string/wcsdup.c
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
#include "libc.h"
|
||||||
|
|
||||||
|
wchar_t *wcsdup(const wchar_t *s)
|
||||||
|
{
|
||||||
|
size_t l = wcslen(s);
|
||||||
|
wchar_t *d = malloc((l+1)*sizeof(wchar_t));
|
||||||
|
if (!d) return NULL;
|
||||||
|
return wmemcpy(d, s, l+1);
|
||||||
|
}
|
9
src/string/wcsncasecmp.c
Normal file
9
src/string/wcsncasecmp.c
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#include <wchar.h>
|
||||||
|
#include <wctype.h>
|
||||||
|
|
||||||
|
int wcsncasecmp(const wchar_t *l, const wchar_t *r, size_t n)
|
||||||
|
{
|
||||||
|
if (!n--) return 0;
|
||||||
|
for (; *l && *r && n && (*l == *r || towlower(*l) == towlower(*r)); l++, r++, n--);
|
||||||
|
return towlower(*l) - towlower(*r);
|
||||||
|
}
|
6
src/string/wcsncasecmp_l.c
Normal file
6
src/string/wcsncasecmp_l.c
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
|
int wcsncasecmp_l(const wchar_t *l, const wchar_t *r, size_t n, locale_t locale)
|
||||||
|
{
|
||||||
|
return wcsncasecmp(l, r, n);
|
||||||
|
}
|
8
src/string/wcsnlen.c
Normal file
8
src/string/wcsnlen.c
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
|
size_t wcsnlen(const wchar_t *s, size_t n)
|
||||||
|
{
|
||||||
|
const wchar_t *z = wmemchr(s, 0, n);
|
||||||
|
if (z) n = z-s;
|
||||||
|
return n;
|
||||||
|
}
|
12
src/string/wcstok.c
Normal file
12
src/string/wcstok.c
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
|
wchar_t *wcstok(wchar_t *s, const wchar_t *sep, wchar_t **p)
|
||||||
|
{
|
||||||
|
if (!s && !(s = *p)) return NULL;
|
||||||
|
s += wcsspn(s, sep);
|
||||||
|
if (!*s) return *p = 0;
|
||||||
|
*p = s + wcscspn(s, sep);
|
||||||
|
if (**p) *(*p)++ = 0;
|
||||||
|
else *p = 0;
|
||||||
|
return s;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user