diff options
author | Junio C Hamano <gitster@pobox.com> | 2020-03-02 15:07:20 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-03-02 15:07:20 -0800 |
commit | ff41848e999fe89600ac0b669b59ad580401f451 (patch) | |
tree | bace34c637fb3dec1580d5e01820b4d9ef070e60 | |
parent | Merge branch 'es/worktree-cleanup' (diff) | |
parent | use strpbrk(3) to search for characters from a given set (diff) | |
download | tgif-ff41848e999fe89600ac0b669b59ad580401f451.tar.xz |
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
-rw-r--r-- | builtin/show-branch.c | 2 | ||||
-rw-r--r-- | compat/mingw.c | 2 | ||||
-rw-r--r-- | mailinfo.c | 3 | ||||
-rw-r--r-- | quote.c | 2 | ||||
-rw-r--r-- | t/helper/test-windows-named-pipe.c | 2 |
5 files changed, 5 insertions, 6 deletions
diff --git a/builtin/show-branch.c b/builtin/show-branch.c index 35d7f51c23..8c90cbb18f 100644 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@ -536,7 +536,7 @@ static void append_one_rev(const char *av) append_ref(av, &revkey, 0); return; } - if (strchr(av, '*') || strchr(av, '?') || strchr(av, '[')) { + if (strpbrk(av, "*?[")) { /* glob style match */ int saved_matches = ref_name_cnt; diff --git a/compat/mingw.c b/compat/mingw.c index b5230149db..d14065d60e 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -1245,7 +1245,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"); diff --git a/mailinfo.c b/mailinfo.c index cf92255515..742fa376ab 100644 --- a/mailinfo.c +++ b/mailinfo.c @@ -19,8 +19,7 @@ static void cleanup_space(struct strbuf *sb) static void get_sane_name(struct strbuf *out, struct strbuf *name, struct strbuf *email) { struct strbuf *src = name; - if (name->len < 3 || 60 < name->len || strchr(name->buf, '@') || - strchr(name->buf, '<') || strchr(name->buf, '>')) + if (name->len < 3 || 60 < name->len || strpbrk(name->buf, "@<>")) src = email; else if (name == out) return; @@ -55,7 +55,7 @@ void sq_quote_buf_pretty(struct strbuf *dst, const char *src) } for (p = src; *p; p++) { - if (!isalpha(*p) && !isdigit(*p) && !strchr(ok_punct, *p)) { + if (!isalnum(*p) && !strchr(ok_punct, *p)) { sq_quote_buf(dst, src); return; } diff --git a/t/helper/test-windows-named-pipe.c b/t/helper/test-windows-named-pipe.c index b4b752b01a..ae52183e63 100644 --- a/t/helper/test-windows-named-pipe.c +++ b/t/helper/test-windows-named-pipe.c @@ -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); |