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
@ -1232,7 +1232,7 @@ static char *path_lookup(const char *cmd, int exe_only)
|
||||
int len = strlen(cmd);
|
||||
int isexe = len >= 4 && !strcasecmp(cmd+len-4, ".exe");
|
||||
|
||||
if (strchr(cmd, '/') || strchr(cmd, '\\'))
|
||||
if (strpbrk(cmd, "/\\"))
|
||||
return xstrdup(cmd);
|
||||
|
||||
path = mingw_getenv("PATH");
|
||||
|
Reference in New Issue
Block a user