summaryrefslogtreecommitdiff
path: root/lib/glob.c
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.c
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.c')
-rw-r--r--lib/glob.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/glob.c b/lib/glob.c
index ddab535767..4c6c31b819 100644
--- a/lib/glob.c
+++ b/lib/glob.c
@@ -903,7 +903,7 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int),
[ which we handle the same, using fnmatch. Broken unterminated
pattern bracket expressions ought to be rare enough that it is
not worth special casing them, fnmatch will do the right thing. */
- if (meta & 5)
+ if (meta & (GLOBPAT_SPECIAL | GLOBPAT_BRACKET))
{
/* The directory name contains metacharacters, so we
have to glob for the directory, and then glob for
@@ -1044,7 +1044,7 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int),
size_t old_pathc = pglob->gl_pathc;
int orig_flags = flags;
- if (meta & 2)
+ if (meta & GLOBPAT_BACKSLASH)
{
char *p = strchr (dirname, '\\'), *q;
/* We need to unescape the dirname string. It is certainly
@@ -1242,14 +1242,14 @@ glob_in_dir (const char *pattern, const char *directory, int flags,
/ sizeof init_names->name[0]);
meta = __glob_pattern_type (pattern, !(flags & GLOB_NOESCAPE));
- if (meta == 0 && (flags & (GLOB_NOCHECK|GLOB_NOMAGIC)))
+ if (meta == GLOBPAT_NONE && (flags & (GLOB_NOCHECK|GLOB_NOMAGIC)))
{
/* We need not do any tests. The PATTERN contains no meta
characters and we must not return an error therefore the
result will always contain exactly one name. */
flags |= GLOB_NOCHECK;
}
- else if (meta == 0)
+ else if (meta == GLOBPAT_NONE)
{
union
{