aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSimon Glass2012-12-05 08:46:35 -0600
committerTom Rini2012-12-11 14:17:34 -0600
commitb1f17bf5ff63a7e22e0299dd576c3b6cd38ae665 (patch)
treef96ee90f06bef6e031832cded766631486a88e76 /lib
parentec7381fbf6f77cc465eb06a1ab6f8a99df1e487c (diff)
downloadu-boot-b1f17bf5ff63a7e22e0299dd576c3b6cd38ae665.tar.gz
u-boot-b1f17bf5ff63a7e22e0299dd576c3b6cd38ae665.tar.xz
u-boot-b1f17bf5ff63a7e22e0299dd576c3b6cd38ae665.zip
Add strcasecmp() and strncasecmp()
strncasecmp() is present as strnicmp() but disabled. Make it available and define strcasecmp() also. There is a only a small performance penalty to having strcasecmp() call strncasecmp(), so do this instead of a standalone function, to save code space. Update the prototype in arch-specific headers as needed to avoid warnings. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/string.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/string.c b/lib/string.c
index c3ad055e2c..68f60bea12 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -21,14 +21,13 @@
21#include <malloc.h> 21#include <malloc.h>
22 22
23 23
24#if 0 /* not used - was: #ifndef __HAVE_ARCH_STRNICMP */
25/** 24/**
26 * strnicmp - Case insensitive, length-limited string comparison 25 * strncasecmp - Case insensitive, length-limited string comparison
27 * @s1: One string 26 * @s1: One string
28 * @s2: The other string 27 * @s2: The other string
29 * @len: the maximum number of characters to compare 28 * @len: the maximum number of characters to compare
30 */ 29 */
31int strnicmp(const char *s1, const char *s2, size_t len) 30int strncasecmp(const char *s1, const char *s2, size_t len)
32{ 31{
33 /* Yes, Virginia, it had better be unsigned */ 32 /* Yes, Virginia, it had better be unsigned */
34 unsigned char c1, c2; 33 unsigned char c1, c2;
@@ -52,7 +51,16 @@ int strnicmp(const char *s1, const char *s2, size_t len)
52 } 51 }
53 return (int)c1 - (int)c2; 52 return (int)c1 - (int)c2;
54} 53}
55#endif 54
55/**
56 * strcasecmp - Case insensitive string comparison
57 * @s1: One string
58 * @s2: The other string
59 */
60int strcasecmp(const char *s1, const char *s2)
61{
62 return strncasecmp(s1, s2, -1U);
63}
56 64
57char * ___strtok; 65char * ___strtok;
58 66