patch-2.1.121 linux/lib/string.c
Next file: linux/mm/memory.c
Previous file: linux/kernel/panic.c
Back to the patch index
Back to the overall index
-  Lines: 35
-  Date:
Sun Sep  6 11:19:15 1998
-  Orig file: 
v2.1.120/linux/lib/string.c
-  Orig date: 
Tue Apr 23 03:24:52 1996
diff -u --recursive --new-file v2.1.120/linux/lib/string.c linux/lib/string.c
@@ -13,6 +13,34 @@
  
 #include <linux/types.h>
 #include <linux/string.h>
+#include <linux/ctype.h>
+
+#ifndef __HAVE_ARCH_STRNICMP
+int strnicmp(const char *s1, const char *s2, size_t len)
+{
+	/* Yes, Virginia, it had better be unsigned */
+	unsigned char c1, c2;
+
+	c1 = 0;	c2 = 0;
+	if (len) {
+		do {
+			c1 = *s1; c2 = *s2;
+			s1++; s2++;
+			if (!c1)
+				break;
+			if (!c2)
+				break;
+			if (c1 == c2)
+				continue;
+			c1 = tolower(c1);
+			c2 = tolower(c2);
+			if (c1 != c2)
+				break;
+		} while (--len);
+	}
+	return (int)c1 - (int)c2;
+}
+#endif
 
 char * ___strtok = NULL;
 
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov