Skip to content

Commit ff41848

Browse files
committed
Merge branch 'rs/micro-cleanups'
Code cleanup. * rs/micro-cleanups: use strpbrk(3) to search for characters from a given set quote: use isalnum() to check for alphanumeric characters
2 parents 4cbf1a0 + 2ce6d07 commit ff41848

File tree

5 files changed

+5
-6
lines changed

5 files changed

+5
-6
lines changed

builtin/show-branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ static void append_one_rev(const char *av)
536536
append_ref(av, &revkey, 0);
537537
return;
538538
}
539-
if (strchr(av, '*') || strchr(av, '?') || strchr(av, '[')) {
539+
if (strpbrk(av, "*?[")) {
540540
/* glob style match */
541541
int saved_matches = ref_name_cnt;
542542

compat/mingw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,7 @@ static char *path_lookup(const char *cmd, int exe_only)
12451245
int len = strlen(cmd);
12461246
int isexe = len >= 4 && !strcasecmp(cmd+len-4, ".exe");
12471247

1248-
if (strchr(cmd, '/') || strchr(cmd, '\\'))
1248+
if (strpbrk(cmd, "/\\"))
12491249
return xstrdup(cmd);
12501250

12511251
path = mingw_getenv("PATH");

mailinfo.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ static void cleanup_space(struct strbuf *sb)
1919
static void get_sane_name(struct strbuf *out, struct strbuf *name, struct strbuf *email)
2020
{
2121
struct strbuf *src = name;
22-
if (name->len < 3 || 60 < name->len || strchr(name->buf, '@') ||
23-
strchr(name->buf, '<') || strchr(name->buf, '>'))
22+
if (name->len < 3 || 60 < name->len || strpbrk(name->buf, "@<>"))
2423
src = email;
2524
else if (name == out)
2625
return;

quote.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void sq_quote_buf_pretty(struct strbuf *dst, const char *src)
5555
}
5656

5757
for (p = src; *p; p++) {
58-
if (!isalpha(*p) && !isdigit(*p) && !strchr(ok_punct, *p)) {
58+
if (!isalnum(*p) && !strchr(ok_punct, *p)) {
5959
sq_quote_buf(dst, src);
6060
return;
6161
}

t/helper/test-windows-named-pipe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ int cmd__windows_named_pipe(int argc, const char **argv)
1919
if (argc < 2)
2020
goto print_usage;
2121
filename = argv[1];
22-
if (strchr(filename, '/') || strchr(filename, '\\'))
22+
if (strpbrk(filename, "/\\"))
2323
goto print_usage;
2424
strbuf_addf(&pathname, "//./pipe/%s", filename);
2525

0 commit comments

Comments
 (0)