aboutsummaryrefslogtreecommitdiffstats
path: root/src/wchar
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2015-09-02 20:00:18 +0200
committerMattias Andrée <maandree@operamail.com>2015-09-02 20:00:18 +0200
commitcec10062d823eb05697eb956235d4ec66ee65e92 (patch)
treec734f21528637a27c20e2ed3a6576c6a0ca5a149 /src/wchar
parentfix some warnings and errors (diff)
downloadslibc-cec10062d823eb05697eb956235d4ec66ee65e92.tar.gz
slibc-cec10062d823eb05697eb956235d4ec66ee65e92.tar.bz2
slibc-cec10062d823eb05697eb956235d4ec66ee65e92.tar.xz
add memcasecmp and wmemcasecmp
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/wchar')
-rw-r--r--src/wchar/wcscmp.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/wchar/wcscmp.c b/src/wchar/wcscmp.c
index aa3cdf3..ddbd228 100644
--- a/src/wchar/wcscmp.c
+++ b/src/wchar/wcscmp.c
@@ -42,6 +42,30 @@ int wmemcmp(const wchar_t* a, const wchar_t* b, size_t size)
/**
+ * Compare two memory segments alphabetically in a case insensitive manner.
+ *
+ * @param a A negative value is returned if this is the lesser.
+ * @param b A positive value is returned if this is the lesser.
+ * @param size The size of the segments.
+ * @return Zero is returned if `a` and `b` are equal, otherwise,
+ * see the specifications for `a` and `b`.
+ */
+int wmemcasecmp(const wchar_t* a, const wchar_t* b, size_t size)
+{
+ wchar_t c1, c2;
+ for (; size--; a++, b++)
+ if (*a != *b);
+ {
+ c1 = iswalpha(*a) ? towlower(*a) : *a;
+ c2 = iswalpha(*b) ? towlower(*b) : *b;
+ if (c1 != c2)
+ return c1 < c2 ? -1 : +1;
+ }
+ return 0;
+}
+
+
+/**
* Compare two strings alphabetically in a case sensitive manner.
*
* @param a A negative value is returned if this is the lesser.