diff options
| author | Simon Glass <sjg@chromium.org> | 2012-12-05 14:46:35 +0000 | 
|---|---|---|
| committer | Tom Rini <trini@ti.com> | 2012-12-11 13:17:34 -0700 | 
| commit | b1f17bf5ff63a7e22e0299dd576c3b6cd38ae665 (patch) | |
| tree | f96ee90f06bef6e031832cded766631486a88e76 /lib/string.c | |
| parent | ec7381fbf6f77cc465eb06a1ab6f8a99df1e487c (diff) | |
| download | olio-uboot-2014.01-b1f17bf5ff63a7e22e0299dd576c3b6cd38ae665.tar.xz olio-uboot-2014.01-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/string.c')
| -rw-r--r-- | lib/string.c | 16 | 
1 files changed, 12 insertions, 4 deletions
| diff --git a/lib/string.c b/lib/string.c index c3ad055e2..68f60bea1 100644 --- a/lib/string.c +++ b/lib/string.c @@ -21,14 +21,13 @@  #include <malloc.h> -#if 0 /* not used - was: #ifndef __HAVE_ARCH_STRNICMP */  /** - * strnicmp - Case insensitive, length-limited string comparison + * strncasecmp - Case insensitive, length-limited string comparison   * @s1: One string   * @s2: The other string   * @len: the maximum number of characters to compare   */ -int strnicmp(const char *s1, const char *s2, size_t len) +int strncasecmp(const char *s1, const char *s2, size_t len)  {  	/* Yes, Virginia, it had better be unsigned */  	unsigned char c1, c2; @@ -52,7 +51,16 @@ int strnicmp(const char *s1, const char *s2, size_t len)  	}  	return (int)c1 - (int)c2;  } -#endif + +/** + * strcasecmp - Case insensitive string comparison + * @s1: One string + * @s2: The other string + */ +int strcasecmp(const char *s1, const char *s2) +{ +	return strncasecmp(s1, s2, -1U); +}  char * ___strtok; |