History

[STRING]: Move strcasecmp/strncasecmp to lib/string.c

We have several platforms using local copies of identical code.

David S. Miller committed 19 years ago

Commit ded220b1 parent 357418e17 files · +39 −151Browse files

Showing the changes to lib/string.c (1 of 17 files). Show all

Unified · Split

lib/string.c+28−0
@@ -60,6 +60,34 @@ int strnicmp(const char *s1, const char *s2, size_t len) · 59 unmodified lines
6060 EXPORT_SYMBOL(strnicmp);
6161 #endif
6262
63+#ifndef __HAVE_ARCH_STRCASECMP
64+int strcasecmp(const char *s1, const char *s2)
65+{
66+ int c1, c2;
67+
68+ do {
69+ c1 = tolower(*s1++);
70+ c2 = tolower(*s2++);
71+ } while (c1 == c2 && c1 != 0);
72+ return c1 - c2;
73+}
74+EXPORT_SYMBOL(strcasecmp);
75+#endif
76+
77+#ifndef __HAVE_ARCH_STRNCASECMP
78+int strncasecmp(const char *s1, const char *s2, size_t n)
79+{
80+ int c1, c2;
81+
82+ do {
83+ c1 = tolower(*s1++);
84+ c2 = tolower(*s2++);
85+ } while ((--n > 0) && c1 == c2 && c1 != 0);
86+ return c1 - c2;
87+}
88+EXPORT_SYMBOL(strncasecmp);
89+#endif
90+
6391 #ifndef __HAVE_ARCH_STRCPY
6492 /**
6593 * strcpy - Copy a %NUL terminated string

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t