From 638670cd4e24cba8fdab5b7bbbe9907952397024 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 29 Nov 2001 21:53:29 +0000 Subject: (next_brace_sub): Return NULL if braces don't match, fix {{a,b},c} globbing, clean up. --- sysdeps/generic/glob.c | 40 ++++++---------------------------------- 1 file 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 */ -- cgit 1.4.1