aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/string/new.c76
-rw-r--r--src/wchar/new.c72
2 files changed, 148 insertions, 0 deletions
diff --git a/src/string/new.c b/src/string/new.c
index 50b47cf..28d2b22 100644
--- a/src/string/new.c
+++ b/src/string/new.c
@@ -729,3 +729,79 @@ char* (strcnends)(const char* string, const char* desired, int stop, size_t maxl
return (memcmp)(string + (n - m), desired, m) ? NULL : (string + n);
}
+int strlowercmp(const char* a, const char* b) /* slibc */
+{
+ return strnlowercmp(a, b, SIZE_MAX);
+}
+
+int struppercmp(const char* a, const char* b) /* slibc: completeness */
+{
+ return strnuppercmp(a, b, SIZE_MAX);
+}
+
+int strnlowercmp(const char* a, const char* b, size_t length) /* slibc: completeness */
+{
+ int c1, c2;
+ for (; length--; a++, b++)
+ if (*a != *b)
+ {
+ c1 = isalpha(*a) ? tolower(*a) : (int)*a;
+ c2 = *b;
+ if ((c1 -= c2))
+ return c1;
+ }
+ else if (!*a && !*b) return 0;
+ else if (!*a) return -1;
+ else if (!*b) return +1;
+ return 0;
+}
+
+int strnuppercmp(const char* a, const char* b, size_t length) /* slibc: completeness */
+{
+ int c1, c2;
+ for (; length--; a++, b++)
+ if (*a != *b)
+ {
+ c1 = isalpha(*a) ? toupper(*a) : (int)*a;
+ c2 = *b;
+ if ((c1 -= c2))
+ return c1;
+ }
+ else if (!*a && !*b) return 0;
+ else if (!*a) return -1;
+ else if (!*b) return +1;
+ return 0;
+}
+
+int memlowercmp(const void* a, const void* b, size_t size) /* slibc: completeness */
+{
+ const signed char* s1 = a;
+ const signed char* s2 = b;
+ int c1, c2;
+ for (; size--; s1++, s2++)
+ if (*s1 != *s2)
+ {
+ c1 = isalpha(*s1) ? tolower(*s1) : (int)*s1;
+ c2 = *s2;
+ if ((c1 -= c2))
+ return c1;
+ }
+ return 0;
+}
+
+int memuppercmp(const void* a, const void* b, size_t size) /* slibc: completeness */
+{
+ const signed char* s1 = a;
+ const signed char* s2 = b;
+ int c1, c2;
+ for (; size--; s1++, s2++)
+ if (*s1 != *s2)
+ {
+ c1 = isalpha(*s1) ? toupper(*s1) : (int)*s1;
+ c2 = *s2;
+ if ((c1 -= c2))
+ return c1;
+ }
+ return 0;
+}
+
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;
+}
+