History

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.

Arnaldo Carvalho de Melo committed 9 years ago

Commit 96395cb1 parent 3caeafc7 files · +13 −20Browse files

Showing the changes to tools/lib/string.c (1 of 7 files). Show all

Unified · Split

tools/lib/string.c+9−0
@@ -87,3 +87,12 @@ size_t __weak strlcpy(char *dest, const char *src, size_t size) · 86 unmodified lines
87 }87 }
88 return ret;88 return ret;
89}89}
90
91int prefixcmp(const char *str, const char *prefix)
92{
93 for (; ; str++, prefix++)
94 if (!*prefix)
95 return 0;
96 else if (*str != *prefix)
97 return (unsigned char)*prefix - (unsigned char)*str;
98}