All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] add stricmp
@ 2005-09-08 15:05 Jan Beulich
  2005-09-08 15:17 ` Christoph Hellwig
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Beulich @ 2005-09-08 15:05 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1628 bytes --]

(Note: Patch also attached because the inline version is certain to get
line wrapped.)

While strnicmp existed in the set of string support routines, stricmp
didn't, which this patch adjusts.

Signed-off-by: Jan Beulich <jbeulich@novell.com>

diff -Npru 2.6.13/include/linux/string.h
2.6.13-stricmp/include/linux/string.h
--- 2.6.13/include/linux/string.h	2005-08-29 01:41:01.000000000
+0200
+++ 2.6.13-stricmp/include/linux/string.h	2005-09-01
11:32:12.000000000 +0200
@@ -47,6 +47,9 @@ extern int strcmp(const char *,const cha
 #ifndef __HAVE_ARCH_STRNCMP
 extern int strncmp(const char *,const char *,__kernel_size_t);
 #endif
+#ifndef __HAVE_ARCH_STRICMP
+extern int stricmp(const char *, const char *);
+#endif
 #ifndef __HAVE_ARCH_STRNICMP
 extern int strnicmp(const char *, const char *, __kernel_size_t);
 #endif
diff -Npru 2.6.13/lib/string.c 2.6.13-stricmp/lib/string.c
--- 2.6.13/lib/string.c	2005-08-29 01:41:01.000000000 +0200
+++ 2.6.13-stricmp/lib/string.c	2005-09-01 11:32:13.000000000
+0200
@@ -24,6 +24,31 @@
 #include <linux/ctype.h>
 #include <linux/module.h>
 
+#ifndef __HAVE_ARCH_STRICMP
+/**
+ * stricmp - Compare two strings case-insensitively
+ * @s1: One string
+ * @s2: Another string
+ */
+int stricmp(const char *s1, const char *s2)
+{
+	unsigned char c1, c2;
+
+	for (;;) {
+		c1 = *s1++;
+		c2 = *s2++;
+		if (!c1 || !c2)
+			break;
+		if (c1 == c2)
+			continue;
+		if ((c1 = tolower(c1)) != (c2 = tolower(c2)))
+			break;
+	}
+	return (int)c1 - (int)c2;
+}
+#endif
+EXPORT_SYMBOL(stricmp);
+
 #ifndef __HAVE_ARCH_STRNICMP
 /**
  * strnicmp - Case insensitive, length-limited string comparison


[-- Attachment #2: linux-2.6.13-stricmp.patch --]
[-- Type: application/octet-stream, Size: 1627 bytes --]

(Note: Patch also attached because the inline version is certain to get
line wrapped.)

While strnicmp existed in the set of string support routines, stricmp
didn't, which this patch adjusts.

Signed-off-by: Jan Beulich <jbeulich@novell.com>

diff -Npru 2.6.13/include/linux/string.h 2.6.13-stricmp/include/linux/string.h
--- 2.6.13/include/linux/string.h	2005-08-29 01:41:01.000000000 +0200
+++ 2.6.13-stricmp/include/linux/string.h	2005-09-01 11:32:12.000000000 +0200
@@ -47,6 +47,9 @@ extern int strcmp(const char *,const cha
 #ifndef __HAVE_ARCH_STRNCMP
 extern int strncmp(const char *,const char *,__kernel_size_t);
 #endif
+#ifndef __HAVE_ARCH_STRICMP
+extern int stricmp(const char *, const char *);
+#endif
 #ifndef __HAVE_ARCH_STRNICMP
 extern int strnicmp(const char *, const char *, __kernel_size_t);
 #endif
diff -Npru 2.6.13/lib/string.c 2.6.13-stricmp/lib/string.c
--- 2.6.13/lib/string.c	2005-08-29 01:41:01.000000000 +0200
+++ 2.6.13-stricmp/lib/string.c	2005-09-01 11:32:13.000000000 +0200
@@ -24,6 +24,31 @@
 #include <linux/ctype.h>
 #include <linux/module.h>
 
+#ifndef __HAVE_ARCH_STRICMP
+/**
+ * stricmp - Compare two strings case-insensitively
+ * @s1: One string
+ * @s2: Another string
+ */
+int stricmp(const char *s1, const char *s2)
+{
+	unsigned char c1, c2;
+
+	for (;;) {
+		c1 = *s1++;
+		c2 = *s2++;
+		if (!c1 || !c2)
+			break;
+		if (c1 == c2)
+			continue;
+		if ((c1 = tolower(c1)) != (c2 = tolower(c2)))
+			break;
+	}
+	return (int)c1 - (int)c2;
+}
+#endif
+EXPORT_SYMBOL(stricmp);
+
 #ifndef __HAVE_ARCH_STRNICMP
 /**
  * strnicmp - Case insensitive, length-limited string comparison

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-09-08 16:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-08 15:05 [PATCH] add stricmp Jan Beulich
2005-09-08 15:17 ` Christoph Hellwig
2005-09-08 15:28   ` Jan Beulich
2005-09-08 15:36     ` Christoph Hellwig
2005-09-08 16:04     ` Alan Cox
2005-09-08 15:45       ` Jan Beulich
2005-09-08 16:37         ` Alan Cox
2005-09-08 16:28           ` viro

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.