aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-11-29 21:53:29 +0000
committerUlrich Drepper <drepper@redhat.com>2001-11-29 21:53:29 +0000
commit638670cd4e24cba8fdab5b7bbbe9907952397024 (patch)
treeb7cb2ed9a8da0e1214849dcc932c467aba13a602
parent647530279ee887a8770c42d798242137cac416de (diff)
downloadglibc-638670cd4e24cba8fdab5b7bbbe9907952397024.tar
glibc-638670cd4e24cba8fdab5b7bbbe9907952397024.tar.gz
glibc-638670cd4e24cba8fdab5b7bbbe9907952397024.tar.bz2
glibc-638670cd4e24cba8fdab5b7bbbe9907952397024.zip
(next_brace_sub): Return NULL if braces don't match, fix {{a,b},c} globbing, clean up.
-rw-r--r--sysdeps/generic/glob.c40
1 files changed, 6 insertions, 34 deletions
diff --git a/sysdeps/generic/glob.c b/sysdeps/generic/glob.c
index 2fedf4a068..a17a4c45df 100644
--- a/sysdeps/generic/glob.c
+++ b/sysdeps/generic/glob.c
@@ -355,42 +355,14 @@ static
inline
#endif
const char *
-next_brace_sub (begin)
- const char *begin;
+next_brace_sub (cp)
+ const char *cp;
{
unsigned int depth = 0;
- const char *cp = begin;
-
- while (1)
- {
- if (depth == 0)
- {
- if (*cp != ',' && *cp != '}' && *cp != '\0')
- {
- if (*cp == '{')
- ++depth;
- ++cp;
- continue;
- }
- }
- else
- {
- while (*cp != '\0' && (*cp != '}' || depth > 0))
- {
- if (*cp == '}')
- --depth;
- ++cp;
- }
- if (*cp == '\0')
- /* An incorrectly terminated brace expression. */
- return NULL;
-
- continue;
- }
- break;
- }
-
- return cp;
+ while (*cp != '\0' && (*cp != '}' || depth--) && (*cp != ',' || depth))
+ if (*cp++ == '{')
+ depth++;
+ return *cp != '\0' ? cp : NULL;
}
#endif /* !GLOB_ONLY_P */