diff options
author | Paul Pluzhnikov <ppluzhnikov@google.com> | 2015-03-09 14:41:35 -0700 |
---|---|---|
committer | Paul Pluzhnikov <ppluzhnikov@google.com> | 2015-03-09 14:41:35 -0700 |
commit | 01d032e0bb911f855963f75449e4fbe48e657292 (patch) | |
tree | 4fafb38c3a795493ca06e85057f81eb9675dcb8e /posix | |
parent | d439bc56e1047b896262941611c6be0b6a40965b (diff) | |
download | glibc-01d032e0bb911f855963f75449e4fbe48e657292.tar.gz |
Minor refactoring:
* posix/wordexp.c (CHAR_IN_SET): New macro.
(parse_param): Use it.
Diffstat (limited to 'posix')
-rw-r--r-- | posix/wordexp.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/posix/wordexp.c b/posix/wordexp.c index 36b6fff0db..f470e083ef 100644 --- a/posix/wordexp.c +++ b/posix/wordexp.c @@ -1218,6 +1218,9 @@ parse_comm (char **word, size_t *word_length, size_t *max_length, return WRDE_SYNTAX; } +#define CHAR_IN_SET(ch, char_set) \ + (memchr (char_set "", ch, sizeof (char_set) - 1) != NULL) + static int internal_function parse_param (char **word, size_t *word_length, size_t *max_length, @@ -1299,7 +1302,7 @@ parse_param (char **word, size_t *word_length, size_t *max_length, } while (isdigit(words[++*offset])); } - else if (words[*offset] != '\0' && strchr ("*@$", words[*offset]) != NULL) + else if (CHAR_IN_SET (words[*offset], "*@$")) { /* Special parameter. */ special = 1; @@ -1343,8 +1346,7 @@ parse_param (char **word, size_t *word_length, size_t *max_length, break; case ':': - if (words[1 + *offset] == '\0' - || strchr ("-=?+", words[1 + *offset]) == NULL) + if (!CHAR_IN_SET (words[1 + *offset], "-=?+")) goto syntax; colon_seen = 1; @@ -2046,6 +2048,8 @@ do_error: return error; } +#undef CHAR_IN_SET + static int internal_function parse_dollars (char **word, size_t *word_length, size_t *max_length, |