summaryrefslogtreecommitdiff
path: root/patches/glibc/2.1.3/rh62-08-glibc-2.1.3-glob.patch
blob: cdd4c0be83aa7237b7fa4de94f5a598014cce9f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
2001-11-29  Jakub Jelinek  <jakub@redhat.com>

	* sysdeps/generic/glob.c (next_brace_sub): Return NULL if braces
	don't match, fix {{a,b},c} globbing, clean up.
	Patch by Flavio Veloso <flaviovs@magnux.com>.

--- libc/sysdeps/generic/glob.c.jj	Thu Aug 23 18:49:29 2001
+++ libc/sysdeps/generic/glob.c	Thu Nov 29 13:17:21 2001
@@ -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 */