use strpbrk(3) to search for characters from a given set
We can check if certain characters are present in a string by calling strchr(3) on each of them, or we can pass them all to a single strpbrk(3) call. The latter is shorter, less repetitive and slightly more efficient, so let's do that instead. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
2b3c430bce
commit
2ce6d075fa
@ -19,7 +19,7 @@ int cmd__windows_named_pipe(int argc, const char **argv)
|
||||
if (argc < 2)
|
||||
goto print_usage;
|
||||
filename = argv[1];
|
||||
if (strchr(filename, '/') || strchr(filename, '\\'))
|
||||
if (strpbrk(filename, "/\\"))
|
||||
goto print_usage;
|
||||
strbuf_addf(&pathname, "//./pipe/%s", filename);
|
||||
|
||||
|
Reference in New Issue
Block a user