]> 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 d06a645017df519f0dc5e98995bc6dec44e3a5eb..e0b793abbee5106e5614f51f7876fd1e6be1d5e5 100644 (file)
@@ -21,7 +21,7 @@
 #include <malloc.h>
 
 
-#ifndef __HAVE_ARCH_STRNICMP
+#if 0 /* not used - was: #ifndef __HAVE_ARCH_STRNICMP */
 /**
  * strnicmp - Case insensitive, length-limited string comparison
  * @s1: One string
@@ -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