summaryrefslogtreecommitdiff
path: root/lib/glob_internal.h
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2017-09-05 21:14:51 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2017-09-05 21:15:55 -0700
commit8ffefc19a6d30f3979a13fa9d37007aeaca40fdf (patch)
tree605abfeafae44f78792f8a40b5532306cfdbb63e /lib/glob_internal.h
parentef5de27602b0dfe288e21e925e2b8a09babdb41d (diff)
downloadgnulib-8ffefc19a6d30f3979a13fa9d37007aeaca40fdf.tar.gz
glob: Use enum for __glob_pattern_type result
From a patch proposed by Adhemerval Zanella in: https://sourceware.org/ml/libc-alpha/2017-09/msg00212.html * lib/glob_internal.h (GLOBPAT_NONE, GLOBPAT_SPECIAL) (GLOBPAT_BACKSLASH, GLOBPAT_BRACKET): New constants. * lib/glob_internal.h (__glob_pattern_type): * lib/glob.c (glob): * lib/glob_pattern_p.c (__glob_pattern_p): Use them.
Diffstat (limited to 'lib/glob_internal.h')
-rw-r--r--lib/glob_internal.h18
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/glob_internal.h b/lib/glob_internal.h
index 12c93660b7..d118b3533d 100644
--- a/lib/glob_internal.h
+++ b/lib/glob_internal.h
@@ -19,35 +19,43 @@
#ifndef GLOB_INTERNAL_H
# define GLOB_INTERNAL_H
+enum
+{
+ GLOBPAT_NONE = 0x0,
+ GLOBPAT_SPECIAL = 0x1,
+ GLOBPAT_BACKSLASH = 0x2,
+ GLOBPAT_BRACKET = 0x4
+};
+
static inline int
__glob_pattern_type (const char *pattern, int quote)
{
const char *p;
- int ret = 0;
+ int ret = GLOBPAT_NONE;
for (p = pattern; *p != '\0'; ++p)
switch (*p)
{
case '?':
case '*':
- return 1;
+ return GLOBPAT_SPECIAL;
case '\\':
if (quote)
{
if (p[1] != '\0')
++p;
- ret |= 2;
+ ret |= GLOBPAT_BACKSLASH;
}
break;
case '[':
- ret |= 4;
+ ret |= GLOBPAT_BRACKET;
break;
case ']':
if (ret & 4)
- return 1;
+ return GLOBPAT_SPECIAL;
break;
}