Commit 96395cbbc7e94cbbe4f76cf64cf122fabc19123d
1 parent
3caeafce53
tools lib string: Adopt prefixcmp() from perf and subcmd
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>
Showing 7 changed files with 13 additions and 20 deletions Side-by-side Diff
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
... | ... | @@ -79,14 +79,5 @@ |
79 | 79 | free(tmp); |
80 | 80 | } |
81 | 81 | |
82 | -static inline int prefixcmp(const char *str, const char *prefix) | |
83 | -{ | |
84 | - for (; ; str++, prefix++) | |
85 | - if (!*prefix) | |
86 | - return 0; | |
87 | - else if (*str != *prefix) | |
88 | - return (unsigned char)*prefix - (unsigned char)*str; | |
89 | -} | |
90 | - | |
91 | 82 | #endif /* __SUBCMD_UTIL_H */ |
tools/perf/util/strbuf.c
... | ... | @@ -3,15 +3,6 @@ |
3 | 3 | #include <linux/kernel.h> |
4 | 4 | #include <errno.h> |
5 | 5 | |
6 | -int prefixcmp(const char *str, const char *prefix) | |
7 | -{ | |
8 | - for (; ; str++, prefix++) | |
9 | - if (!*prefix) | |
10 | - return 0; | |
11 | - else if (*str != *prefix) | |
12 | - return (unsigned char)*prefix - (unsigned char)*str; | |
13 | -} | |
14 | - | |
15 | 6 | /* |
16 | 7 | * Used as the default ->buf value, so that people can always assume |
17 | 8 | * buf is non NULL and ->buf is NUL terminated even for a freshly |
tools/perf/util/util.h