aboutsummaryrefslogtreecommitdiffstats
path: root/src/wchar
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2015-11-20 07:07:55 +0100
committerMattias Andrée <maandree@operamail.com>2015-11-20 07:07:55 +0100
commit2ccd77c0c9bde78f3811bbc9b256197515532c88 (patch)
treea811844b72fa00c61c6dd438d5bbd5d7fc115cf3 /src/wchar
parenttypo (diff)
downloadslibc-2ccd77c0c9bde78f3811bbc9b256197515532c88.tar.gz
slibc-2ccd77c0c9bde78f3811bbc9b256197515532c88.tar.bz2
slibc-2ccd77c0c9bde78f3811bbc9b256197515532c88.tar.xz
add optimised variants of *casecmp
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/wchar')
-rw-r--r--src/wchar/new.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/wchar/new.c b/src/wchar/new.c
index e1d9c52..819b133 100644
--- a/src/wchar/new.c
+++ b/src/wchar/new.c
@@ -569,3 +569,75 @@ wchar_t* (wcscnends)(const wchar_t* string, const wchar_t* desired, wchar_t stop
return (wmemcmp)(string + (n - m), desired, m) ? NULL : (string + n);
}
+int wcslowercmp(const wchar_t* a, const wchar_t* b) /* slibc: completeness */
+{
+ return wcsnlowercmp(a, b, SIZE_MAX);
+}
+
+int wcsuppercmp(const wchar_t* a, const wchar_t* b) /* slibc: completeness */
+{
+ return wcsnuppercmp(a, b, SIZE_MAX);
+}
+
+int wcsnlowercmp(const wchar_t* a, const wchar_t* b, size_t length) /* slibc: completeness */
+{
+ wchar_t c1, c2;
+ for (; length--; a++, b++)
+ if (*a != *b)
+ {
+ c1 = iswalpha(*a) ? towlower(*a) : *a;
+ c2 = *b;
+ if (c1 < c2) return -1;
+ if (c1 > c2) return +1;
+ }
+ else if (!*a && !*b) return 0;
+ else if (!*a) return -1;
+ else if (!*b) return +1;
+ return 0;
+}
+
+int wcsnuppercmp(const wchar_t* a, const wchar_t* b, size_t length) /* slibc: completeness */
+{
+ wchar_t c1, c2;
+ for (; length--; a++, b++)
+ if (*a != *b)
+ {
+ c1 = iswalpha(*a) ? towupper(*a) : *a;
+ c2 = *b;
+ if (c1 < c2) return -1;
+ if (c1 > c2) return +1;
+ }
+ else if (!*a && !*b) return 0;
+ else if (!*a) return -1;
+ else if (!*b) return +1;
+ return 0;
+}
+
+int wmemlowercmp(const wchar_t* a, const wchar_t* b, size_t size) /* slibc: completeness */
+{
+ wchar_t c1, c2;
+ for (; size--; a++, b++)
+ if (*a != *b)
+ {
+ c1 = iswalpha(*a) ? towlower(*a) : *a;
+ c2 = *b;
+ if (c1 != c2)
+ return c1 < c2 ? -1 : +1;
+ }
+ return 0;
+}
+
+int wmemuppercmp(const wchar_t* a, const wchar_t* b, size_t size) /* slibc: completeness */
+{
+ wchar_t c1, c2;
+ for (; size--; a++, b++)
+ if (*a != *b)
+ {
+ c1 = iswalpha(*a) ? towupper(*a) : *a;
+ c2 = *b;
+ if (c1 != c2)
+ return c1 < c2 ? -1 : +1;
+ }
+ return 0;
+}
+