]> git.sur5r.net Git - u-boot/blobdiff - lib_generic/string.c
POST: replace the LOGBUFF_INITIALIZED flag in gd->post_log_word (1 << 31) with the...
[u-boot] / lib_generic / string.c
index 1e1e2e33fc32e1d0fb909350dec988da47ac74af..e0b793abbee5106e5614f51f7876fd1e6be1d5e5 100644 (file)
 #include <linux/ctype.h>
 #include <malloc.h>
 
-#ifdef CONFIG_ARM
-#undef  __HAVE_ARCH_MEMCMP
-#undef  __HAVE_ARCH_MEMCPY
-#undef  __HAVE_ARCH_MEMMOVE
-#undef  __HAVE_ARCH_MEMSET
-#undef  __HAVE_ARCH_BCOPY
-#undef  __HAVE_ARCH_STRCAT
-#undef  __HAVE_ARCH_STRCHR
-#undef  __HAVE_ARCH_STRCMP
-#undef  __HAVE_ARCH_STRCPY
-#undef  __HAVE_ARCH_STRLEN
-#undef  __HAVE_ARCH_STRNCPY
-#else
-#define __HAVE_ARCH_MEMCMP
-#define __HAVE_ARCH_MEMCPY
-#define __HAVE_ARCH_MEMMOVE
-#define __HAVE_ARCH_MEMSET
-#define __HAVE_ARCH_BCOPY
-#define __HAVE_ARCH_STRCAT
-#define __HAVE_ARCH_STRCMP
-#define __HAVE_ARCH_STRCPY
-#define __HAVE_ARCH_STRLEN
-#define __HAVE_ARCH_STRNCPY
-#endif
 
-#ifndef __HAVE_ARCH_STRNICMP
+#if 0 /* not used - was: #ifndef __HAVE_ARCH_STRNICMP */
 /**
  * strnicmp - Case insensitive, length-limited string comparison
  * @s1: One string
@@ -231,8 +207,8 @@ char * strrchr(const char * s, int c)
 {
        const char *p = s + strlen(s);
        do {
-           if (*p == (char)c)
-               return (char *)p;
+          if (*p == (char)c)
+              return (char *)p;
        } while (--p >= s);
        return NULL;
 }
@@ -388,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
@@ -522,7 +526,7 @@ void * memscan(void * addr, int c, size_t size)
                p++;
                size--;
        }
-       return (void *) p;
+       return (void *) p;
 }
 #endif
 
@@ -564,7 +568,7 @@ void *memchr(const void *s, int c, size_t n)
 {
        const unsigned char *p = s;
        while (n-- != 0) {
-               if ((unsigned char)c == *p++) {
+               if ((unsigned char)c == *p++) {
                        return (void *)(p-1);
                }
        }