From e5888a1ffdae813d7575f5fb02275c6bb07e5199 Mon Sep 17 00:00:00 2001 From: Taru Karttunen Date: Wed, 30 Mar 2011 15:46:40 +0300 Subject: Import sources from 2011-03-30 iso image --- sys/src/ape/lib/bsd/strncasecmp.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 sys/src/ape/lib/bsd/strncasecmp.c (limited to 'sys/src/ape/lib/bsd/strncasecmp.c') diff --git a/sys/src/ape/lib/bsd/strncasecmp.c b/sys/src/ape/lib/bsd/strncasecmp.c new file mode 100755 index 000000000..a9ddc8dee --- /dev/null +++ b/sys/src/ape/lib/bsd/strncasecmp.c @@ -0,0 +1,29 @@ +#include + +typedef unsigned char uchar; + +int +strncasecmp(char *s1, char *s2, int n) +{ + int c1, c2; + + while(*s1 && n-- > 0){ + c1 = *(uchar*)s1++; + c2 = *(uchar*)s2++; + + if(c1 == c2) + continue; + + if(c1 >= 'A' && c1 <= 'Z') + c1 -= 'A' - 'a'; + + if(c2 >= 'A' && c2 <= 'Z') + c2 -= 'A' - 'a'; + + if(c1 != c2) + return c1 - c2; + } + if(n <= 0) + return 0; + return -*s2; +} -- cgit v1.2.3