Explorar o código

LibC: Primitively implement wcsxfrm

The `wcsxfrm` function copies a wide character string into a buffer,
such that comparing the new string against any similarly pre-processed
string with `wcscmp` produces the same result as if the original strings
were compared with `wcscoll`.

Our current `wcscoll` implementation is simply an alias for `wcscmp`, so
`wcsxfrm` needs to perform no actions other than copying the string.
Daniel Bertalan %!s(int64=3) %!d(string=hai) anos
pai
achega
95c32fdf19
Modificáronse 2 ficheiros con 7 adicións e 0 borrados
  1. 6 0
      Userland/Libraries/LibC/wchar.cpp
  2. 1 0
      Userland/Libraries/LibC/wchar.h

+ 6 - 0
Userland/Libraries/LibC/wchar.cpp

@@ -331,6 +331,12 @@ int wcscoll(const wchar_t* ws1, const wchar_t* ws2)
     return wcscmp(ws1, ws2);
     return wcscmp(ws1, ws2);
 }
 }
 
 
+size_t wcsxfrm(wchar_t* dest, const wchar_t* src, size_t n)
+{
+    // TODO: This needs to be changed when wcscoll is not just doing wcscmp
+    return wcslcpy(dest, src, n);
+}
+
 int wctob(wint_t c)
 int wctob(wint_t c)
 {
 {
     if (c > 0x7f)
     if (c > 0x7f)

+ 1 - 0
Userland/Libraries/LibC/wchar.h

@@ -44,6 +44,7 @@ size_t mbrtowc(wchar_t*, const char*, size_t, mbstate_t*);
 size_t mbrlen(const char*, size_t, mbstate_t*);
 size_t mbrlen(const char*, size_t, mbstate_t*);
 size_t wcrtomb(char*, wchar_t, mbstate_t*);
 size_t wcrtomb(char*, wchar_t, mbstate_t*);
 int wcscoll(const wchar_t*, const wchar_t*);
 int wcscoll(const wchar_t*, const wchar_t*);
+size_t wcsxfrm(wchar_t*, const wchar_t*, size_t);
 int wctob(wint_t);
 int wctob(wint_t);
 int mbsinit(const mbstate_t*);
 int mbsinit(const mbstate_t*);
 wchar_t* wcspbrk(const wchar_t*, const wchar_t*);
 wchar_t* wcspbrk(const wchar_t*, const wchar_t*);