1 *** lib/fnmatch_loop.c.bak 2009-12-10 20:38:55.000000000 +0100
2 --- lib/fnmatch_loop.c 2009-12-11 11:55:04.000000000 +0100
7 struct patternlist *next;
10 struct patternlist **lastp = &list;
11 size_t pattern_len = STRLEN (pattern);
14 enum { ALLOCA_LIMIT = 8000 };
16 /* Parse the pattern. Store the individual parts in the list. */
18 for (startp = p = pattern + 1; ; ++p)
20 /* This is an invalid pattern. */
22 else if (*p == L_('['))
24 /* Handle brackets special. */
28 struct patternlist *next;
32 struct patternlist **lastp = &list;
33 size_t pattern_len = STRLEN (pattern);
36 + #if HAVE_ALLOCA || defined _LIBC
37 enum { ALLOCA_LIMIT = 8000 };
39 + enum { ALLOCA_LIMIT = 0 };
43 /* Parse the pattern. Store the individual parts in the list. */
45 for (startp = p = pattern + 1; ; ++p)
47 /* This is an invalid pattern. */
49 else if (*p == L_('['))
51 /* Handle brackets special. */
56 /* This is no valid pattern. */
59 else if ((*p == L_('?') || *p == L_('*') || *p == L_('+') || *p == L_('@')
60 || *p == L_('!')) && p[1] == L_('('))
64 /* This is no valid pattern. */
67 else if ((*p == L_('?') || *p == L_('*') || *p == L_('+') || *p == L_('@')
68 || *p == L_('!')) && p[1] == L_('('))
71 plensize = plen * sizeof (CHAR); \
72 newpsize = offsetof (struct patternlist, str) + plensize; \
73 if ((size_t) -1 / sizeof (CHAR) < plen \
74 ! || newpsize < offsetof (struct patternlist, str) \
75 ! || ALLOCA_LIMIT <= newpsize) \
77 ! newp = (struct patternlist *) alloca (newpsize); \
78 ! *((CHAR *) MEMPCPY (newp->str, startp, p - startp)) = L_('\0'); \
83 plensize = plen * sizeof (CHAR); \
84 newpsize = offsetof (struct patternlist, str) + plensize; \
85 if ((size_t) -1 / sizeof (CHAR) < plen \
86 ! || newpsize < offsetof (struct patternlist, str)) \
88 ! if (newpsize < ALLOCA_LIMIT) \
90 ! newp = (struct patternlist *) alloca (newpsize); \
91 ! newp->malloced = 0; \
95 ! newp = (struct patternlist *) malloc (newpsize); \
98 ! newp->malloced = 1; \
100 ! *((CHAR *) MEMPCPY (newp->str, startp, p - startp)) = L_('\0'); \
108 if (FCT (p, string, string_end, no_leading_period, flags) == 0)
115 for (rs = string; rs <= string_end; ++rs)
116 /* First match the prefix with the current pattern with the
121 if (FCT (p, string, string_end, no_leading_period, flags) == 0)
131 + struct patternlist *next;
133 for (rs = string; rs <= string_end; ++rs)
134 /* First match the prefix with the current pattern with the
138 : rs[-1] == '/' && NO_LEADING_PERIOD (flags),
139 flags & FNM_FILE_NAME
140 ? flags : flags & ~FNM_PERIOD) == 0)))
141 ! /* It worked. Signal success. */
144 ! while ((list = list->next) != NULL);
146 /* None of the patterns lead to a match. */
150 if (FCT (p, string, string_end, no_leading_period, flags) == 0)
156 ! /* I cannot believe it but 'strcat' is actually acceptable
157 ! here. Match the entire string with the prefix from the
158 ! pattern list and the rest of the pattern following the
160 ! if (FCT (STRCAT (list->str, p), string, string_end,
162 ! flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0)
163 ! /* It worked. Signal success. */
165 ! while ((list = list->next) != NULL);
167 /* None of the patterns lead to a match. */
170 : rs[-1] == '/' && NO_LEADING_PERIOD (flags),
171 flags & FNM_FILE_NAME
172 ? flags : flags & ~FNM_PERIOD) == 0)))
174 ! /* It worked. Signal success. */
180 ! if (list->malloced)
184 ! while (list != NULL);
186 /* None of the patterns lead to a match. */
190 if (FCT (p, string, string_end, no_leading_period, flags) == 0)
200 ! struct patternlist *next;
202 ! /* I cannot believe it but 'strcat' is actually acceptable
203 ! here. Match the entire string with the prefix from the
204 ! pattern list and the rest of the pattern following the
206 ! if (FCT (STRCAT (list->str, p), string, string_end,
208 ! flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0)
210 ! /* It worked. Signal success. */
216 ! if (list->malloced)
220 ! while (list != NULL);
222 /* None of the patterns lead to a match. */
226 : rs[-1] == '/' && NO_LEADING_PERIOD (flags),
227 flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD)
229 ! /* This is successful. */
233 /* None of the patterns together with the rest of the pattern
235 ! return FNM_NOMATCH;
238 assert (! "Invalid extended matching operator");
247 : rs[-1] == '/' && NO_LEADING_PERIOD (flags),
248 flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD)
251 ! /* This is successful. */
257 /* None of the patterns together with the rest of the pattern
259 ! retval = FNM_NOMATCH;
263 assert (! "Invalid extended matching operator");
270 ! while (list != NULL)
272 ! struct patternlist *next = list->next;
274 ! if (list->malloced)