summaryrefslogtreecommitdiff
path: root/src/libstddjb/case_diffb.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstddjb/case_diffb.c')
-rw-r--r--src/libstddjb/case_diffb.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/libstddjb/case_diffb.c b/src/libstddjb/case_diffb.c
new file mode 100644
index 0000000..1931c0f
--- /dev/null
+++ b/src/libstddjb/case_diffb.c
@@ -0,0 +1,18 @@
+/* ISC license. */
+
+#include <skalibs/bytestr.h>
+
+int case_diffb (char const *s, unsigned int len, char const *t)
+{
+ register unsigned char x = 0, y = 0 ;
+ unsigned char const d = 'a' - 'A' ;
+
+ while (len-- && (x == y))
+ {
+ x = *s++ ;
+ if (('a' <= x) && (x <= 'z')) x -= d ;
+ y = *t++ ;
+ if (('a' <= y) && (y <= 'z')) y -= d ;
+ }
+ return (int)(x - y) ;
+}