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
8787 }
8888 return ret;
8989 }
90+
91+int 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+}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t