X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=sidebyside;f=lib_generic%2Fstring.c;h=181eda614993167894f9a172d81c1b713cd30e2b;hb=0088c298f0eeb90ec001f744e9959dea83dd563a;hp=d06a645017df519f0dc5e98995bc6dec44e3a5eb;hpb=8bde7f776c77b343aca29b8c7b58464d915ac245;p=u-boot diff --git a/lib_generic/string.c b/lib_generic/string.c index d06a645017..181eda6149 100644 --- a/lib_generic/string.c +++ b/lib_generic/string.c @@ -21,7 +21,7 @@ #include -#ifndef __HAVE_ARCH_STRNICMP +#if 0 /* not used - was: #ifndef __HAVE_ARCH_STRNICMP */ /** * strnicmp - Case insensitive, length-limited string comparison * @s1: One string @@ -263,7 +263,7 @@ char * strdup(const char *s) #ifndef __HAVE_ARCH_STRSPN /** * strspn - Calculate the length of the initial substring of @s which only - * contain letters in @accept + * contain letters in @accept * @s: The string to be searched * @accept: The string to search for */ @@ -364,6 +364,34 @@ char * strsep(char **s, const char *ct) } #endif +#ifndef __HAVE_ARCH_STRSWAB +/** + * strswab - swap adjacent even and odd bytes in %NUL-terminated string + * s: address of the string + * + * returns the address of the swapped string or NULL on error. If + * string length is odd, last byte is untouched. + */ +char *strswab(const char *s) +{ + char *p, *q; + + if ((NULL == s) || ('\0' == *s)) { + return (NULL); + } + + for (p=(char *)s, q=p+1; (*p != '\0') && (*q != '\0'); p+=2, q+=2) { + char tmp; + + tmp = *p; + *p = *q; + *q = tmp; + } + + return (char *) s; +} +#endif + #ifndef __HAVE_ARCH_MEMSET /** * memset - Fill a region of memory with the given value