diff options
| author | Arnaldo Carvalho de Melo <[email protected]> | 2017-04-26 18:49:21 +0000 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <[email protected]> | 2017-04-26 18:49:21 +0000 |
| commit | 96395cbbc7e94cbbe4f76cf64cf122fabc19123d (patch) | |
| tree | c0cf51cd06c2b98bf45ef786f88c9b662c6645e8 /tools/lib/string.c | |
| parent | perf units: Move parse_tag_value() to units.[ch] (diff) | |
| download | kernel-96395cbbc7e94cbbe4f76cf64cf122fabc19123d.tar.gz kernel-96395cbbc7e94cbbe4f76cf64cf122fabc19123d.zip | |
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 <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Josh Poimboeuf <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Wang Nan <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
Diffstat (limited to 'tools/lib/string.c')
| -rw-r--r-- | tools/lib/string.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tools/lib/string.c b/tools/lib/string.c index bd239bc1d557..8e678af1c6ee 100644 --- a/tools/lib/string.c +++ b/tools/lib/string.c @@ -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; +} |
