]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Minor refactoring:
authorPaul Pluzhnikov <ppluzhnikov@google.com>
Mon, 9 Mar 2015 21:41:35 +0000 (14:41 -0700)
committerPaul Pluzhnikov <ppluzhnikov@google.com>
Mon, 9 Mar 2015 21:41:35 +0000 (14:41 -0700)
* posix/wordexp.c (CHAR_IN_SET): New macro.
(parse_param): Use it.

ChangeLog
posix/wordexp.c

index d8dfbc1c7ff196a929adfab3f7f6b16ec38eae30..b6467fd4ee42545245e57c9d85f0a9aa46a18082 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-03-09  Paul Pluzhnikov  <ppluzhnikov@google.com>
+
+       * posix/wordexp.c (CHAR_IN_SET): New macro.
+       (parse_param): Use it.
+
 2015-03-09  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>
 
        * sysdeps/powerpc/fpu/libm-test-ulps: update.
index 36b6fff0dbf5111af519410e73f9328b8cdd1b27..f470e083efac1835e3ccbab00e3ca889ad14138b 100644 (file)
@@ -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,