diff options
author | 2022-04-07 19:33:30 +0530 | |
---|---|---|
committer | 2022-04-07 19:33:30 +0530 | |
commit | 54d5ba67489b3fdaf437c05675eb9b1f6d085a84 (patch) | |
tree | d53df52fbfb1f440bba34799c2fcf7ff1ce75a57 /memory/wcscoll.c | |
download | fflibc-main.tar fflibc-main.tar.gz fflibc-main.tar.bz2 fflibc-main.tar.lz fflibc-main.tar.xz fflibc-main.tar.zst fflibc-main.zip |
Initial commitmain
Diffstat (limited to 'memory/wcscoll.c')
-rw-r--r-- | memory/wcscoll.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/memory/wcscoll.c b/memory/wcscoll.c new file mode 100644 index 0000000..f93bae7 --- /dev/null +++ b/memory/wcscoll.c @@ -0,0 +1,28 @@ +#include "memory.h" + +struct array_container { + wchar_t *string; + size_t lenght; +}; + +int wcscoll(wchar_t const *string1, wchar_t const *string2) +{ + wchar_t const *string[2] = {string1, string2}; + struct array_container normalized[2]; + + for (size_t i = 0; i < ((sizeof normalized) / (sizeof normalized[0])); + i++) { + normalized[i].lenght = 1 + _wcsxfrm_wrap(NULL, string[i], 0); + normalized[i].string = reallocarray( + NULL, normalized[i].lenght, sizeof *(normalized[i].string)); + _wcsxfrm_wrap(normalized[i].string, string[i], + normalized[i].lenght); + } + + int res = wcscmp(normalized[0].string, normalized[1].string); + + for (size_t i = 0; i < ((sizeof normalized) / (sizeof normalized[0])); + i++) + _free_wrap(normalized[i].string); + return res; +} |