]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
tools lib string: Adopt prefixcmp() from perf and subcmd
authorArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 26 Apr 2017 18:49:21 +0000 (15:49 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 26 Apr 2017 18:49:21 +0000 (15:49 -0300)
Both had copies originating from git.git, move those to
tools/lib/string.c, getting both tools/lib/subcmd/ and tools/perf/ to
use it.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-uidwtticro1qhttzd2rkrkg1@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/include/linux/string.h
tools/lib/string.c
tools/lib/subcmd/help.c
tools/lib/subcmd/parse-options.c
tools/lib/subcmd/subcmd-util.h
tools/perf/util/strbuf.c
tools/perf/util/util.h

index f436d2420a18575095e66b7bfbf15b0abbe83fe8..d62b56cf8c12eedcdda935bc1180c4b4b70270b9 100644 (file)
@@ -18,4 +18,6 @@ extern size_t strlcpy(char *dest, const char *src, size_t size);
 
 char *str_error_r(int errnum, char *buf, size_t buflen);
 
+int prefixcmp(const char *str, const char *prefix);
+
 #endif /* _LINUX_STRING_H_ */
index bd239bc1d557dbde447e8128ac7cd3163dc11a04..8e678af1c6ee479eae333cf5766598db5dce5208 100644 (file)
@@ -87,3 +87,12 @@ size_t __weak strlcpy(char *dest, const char *src, size_t size)
        }
        return ret;
 }
+
+int prefixcmp(const char *str, const char *prefix)
+{
+       for (; ; str++, prefix++)
+               if (!*prefix)
+                       return 0;
+               else if (*str != *prefix)
+                       return (unsigned char)*prefix - (unsigned char)*str;
+}
index e228c3cb37160b8fd5bda5e3a7c9e76f89ea4537..ba970a73d053f3c019a318dbb7fa14b9dbab9b40 100644 (file)
@@ -1,6 +1,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <linux/string.h>
 #include <termios.h>
 #include <sys/ioctl.h>
 #include <sys/types.h>
index 6bc24025d05457098b504c3a1e9e5a1316b21817..359bfa77f39cdebac7df82876b227d1a63975c39 100644 (file)
@@ -1,4 +1,5 @@
 #include <linux/compiler.h>
+#include <linux/string.h>
 #include <linux/types.h>
 #include <stdio.h>
 #include <stdlib.h>
index fc2e45d8aaf1d04c09d53fd4db6478d60d066895..8fa5f036eff08002ee802dc6014f6689d790a80f 100644 (file)
@@ -79,13 +79,4 @@ static inline void astrcat(char **out, const char *add)
        free(tmp);
 }
 
-static inline int prefixcmp(const char *str, const char *prefix)
-{
-       for (; ; str++, prefix++)
-               if (!*prefix)
-                       return 0;
-               else if (*str != *prefix)
-                       return (unsigned char)*prefix - (unsigned char)*str;
-}
-
 #endif /* __SUBCMD_UTIL_H */
index e91b5e86f0274c0cb3d9e5c44df5d2513e2564f5..aafe908b82b5720b4487c242370ed326ec520e2c 100644 (file)
@@ -3,15 +3,6 @@
 #include <linux/kernel.h>
 #include <errno.h>
 
-int prefixcmp(const char *str, const char *prefix)
-{
-       for (; ; str++, prefix++)
-               if (!*prefix)
-                       return 0;
-               else if (*str != *prefix)
-                       return (unsigned char)*prefix - (unsigned char)*str;
-}
-
 /*
  * Used as the default ->buf value, so that people can always assume
  * buf is non NULL and ->buf is NUL terminated even for a freshly
index d620719775a8a509c90409fe83a68dd0a6a1f13f..5dfb9bb6482d3103d494a9234fef50b308b3d7ef 100644 (file)
@@ -30,8 +30,6 @@ void warning(const char *err, ...) __attribute__((format (printf, 1, 2)));
 
 void set_warning_routine(void (*routine)(const char *err, va_list params));
 
-int prefixcmp(const char *str, const char *prefix);
-
 static inline void *zalloc(size_t size)
 {
        return calloc(1, size);