aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/string.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/lib/string.c b/lib/string.c
index f3c6ff596414..3181e267a033 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -27,14 +27,14 @@
27#include <linux/bug.h> 27#include <linux/bug.h>
28#include <linux/errno.h> 28#include <linux/errno.h>
29 29
30#ifndef __HAVE_ARCH_STRNICMP 30#ifndef __HAVE_ARCH_STRNCASECMP
31/** 31/**
32 * strnicmp - Case insensitive, length-limited string comparison 32 * strncasecmp - Case insensitive, length-limited string comparison
33 * @s1: One string 33 * @s1: One string
34 * @s2: The other string 34 * @s2: The other string
35 * @len: the maximum number of characters to compare 35 * @len: the maximum number of characters to compare
36 */ 36 */
37int strnicmp(const char *s1, const char *s2, size_t len) 37int strncasecmp(const char *s1, const char *s2, size_t len)
38{ 38{
39 /* Yes, Virginia, it had better be unsigned */ 39 /* Yes, Virginia, it had better be unsigned */
40 unsigned char c1, c2; 40 unsigned char c1, c2;
@@ -56,6 +56,13 @@ int strnicmp(const char *s1, const char *s2, size_t len)
56 } while (--len); 56 } while (--len);
57 return (int)c1 - (int)c2; 57 return (int)c1 - (int)c2;
58} 58}
59EXPORT_SYMBOL(strncasecmp);
60#endif
61#ifndef __HAVE_ARCH_STRNICMP
62int strnicmp(const char *s1, const char *s2, size_t len)
63{
64 return strncasecmp(s1, s2, len);
65}
59EXPORT_SYMBOL(strnicmp); 66EXPORT_SYMBOL(strnicmp);
60#endif 67#endif
61 68
@@ -73,20 +80,6 @@ int strcasecmp(const char *s1, const char *s2)
73EXPORT_SYMBOL(strcasecmp); 80EXPORT_SYMBOL(strcasecmp);
74#endif 81#endif
75 82
76#ifndef __HAVE_ARCH_STRNCASECMP
77int strncasecmp(const char *s1, const char *s2, size_t n)
78{
79 int c1, c2;
80
81 do {
82 c1 = tolower(*s1++);
83 c2 = tolower(*s2++);
84 } while ((--n > 0) && c1 == c2 && c1 != 0);
85 return c1 - c2;
86}
87EXPORT_SYMBOL(strncasecmp);
88#endif
89
90#ifndef __HAVE_ARCH_STRCPY 83#ifndef __HAVE_ARCH_STRCPY
91/** 84/**
92 * strcpy - Copy a %NUL terminated string 85 * strcpy - Copy a %NUL terminated string