Imported from ../bash-2.05b.tar.gz.
[platform/upstream/bash.git] / lib / glob / sm_loop.c
1 /* Copyright (C) 1991-2002 Free Software Foundation, Inc.
2
3    This file is part of GNU Bash, the Bourne Again SHell.
4    
5    Bash is free software; you can redistribute it and/or modify it under
6    the terms of the GNU General Public License as published by the Free
7    Software Foundation; either version 2, or (at your option) any later
8    version.
9               
10    Bash is distributed in the hope that it will be useful, but WITHOUT ANY
11    WARRANTY; without even the implied warranty of MERCHANTABILITY or
12    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13    for more details.
14                          
15    You should have received a copy of the GNU General Public License along
16    with Bash; see the file COPYING.  If not, write to the Free Software
17    Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
18
19 static int FCT __P((CHAR *, CHAR *, int));
20 static int GMATCH __P((CHAR *, CHAR *, CHAR *, CHAR *, int));
21 static CHAR *PARSE_COLLSYM __P((CHAR *, INT *));
22 static CHAR *BRACKMATCH __P((CHAR *, U_CHAR, int));
23 static int EXTMATCH __P((INT, CHAR *, CHAR *, CHAR *, CHAR *, int));
24 static CHAR *PATSCAN __P((CHAR *, CHAR *, INT));
25
26 static int
27 FCT (pattern, string, flags)
28      CHAR *pattern;
29      CHAR *string;
30      int flags;
31 {
32   CHAR *se, *pe;
33
34   if (string == 0 || pattern == 0)
35     return FNM_NOMATCH;
36
37   se = string + STRLEN ((XCHAR *)string);
38   pe = pattern + STRLEN ((XCHAR *)pattern);
39
40   return (GMATCH (string, se, pattern, pe, flags));
41 }
42
43 /* Match STRING against the filename pattern PATTERN, returning zero if
44    it matches, FNM_NOMATCH if not.  */
45 static int
46 GMATCH (string, se, pattern, pe, flags)
47      CHAR *string, *se;
48      CHAR *pattern, *pe;
49      int flags;
50 {
51   CHAR *p, *n;          /* pattern, string */
52   INT c;                /* current pattern character - XXX U_CHAR? */
53   INT sc;               /* current string character - XXX U_CHAR? */
54
55   p = pattern;
56   n = string;
57
58   if (string == 0 || pattern == 0)
59     return FNM_NOMATCH;
60
61 #if DEBUG_MATCHING
62 fprintf(stderr, "gmatch: string = %s; se = %s\n", string, se);
63 fprintf(stderr, "gmatch: pattern = %s; pe = %s\n", pattern, pe);
64 #endif
65
66   while (p < pe)
67     {
68       c = *p++;
69       c = FOLD (c);
70
71       sc = n < se ? *n : '\0';
72
73 #ifdef EXTENDED_GLOB
74       /* EXTMATCH () will handle recursively calling GMATCH, so we can
75          just return what EXTMATCH() returns. */
76       if ((flags & FNM_EXTMATCH) && *p == L('(') &&
77           (c == L('+') || c == L('*') || c == L('?') || c == L('@') || c == L('!'))) /* ) */
78         {
79           int lflags;
80           /* If we're not matching the start of the string, we're not
81              concerned about the special cases for matching `.' */
82           lflags = (n == string) ? flags : (flags & ~FNM_PERIOD);
83           return (EXTMATCH (c, n, se, p, pe, lflags));
84         }
85 #endif /* EXTENDED_GLOB */
86
87       switch (c)
88         {
89         case L('?'):            /* Match single character */
90           if (sc == '\0')
91             return FNM_NOMATCH;
92           else if ((flags & FNM_PATHNAME) && sc == L('/'))
93             /* If we are matching a pathname, `?' can never match a `/'. */
94             return FNM_NOMATCH;
95           else if ((flags & FNM_PERIOD) && sc == L('.') &&
96                    (n == string || ((flags & FNM_PATHNAME) && n[-1] == L('/'))))
97             /* `?' cannot match a `.' if it is the first character of the
98                string or if it is the first character following a slash and
99                we are matching a pathname. */
100             return FNM_NOMATCH;
101           break;
102
103         case L('\\'):           /* backslash escape removes special meaning */
104           if (p == pe)
105             return FNM_NOMATCH;
106
107           if ((flags & FNM_NOESCAPE) == 0)
108             {
109               c = *p++;
110               /* A trailing `\' cannot match. */
111               if (p > pe)
112                 return FNM_NOMATCH;
113               c = FOLD (c);
114             }
115           if (FOLD (sc) != (U_CHAR)c)
116             return FNM_NOMATCH;
117           break;
118
119         case '*':               /* Match zero or more characters */
120           if (p == pe)
121             return 0;
122           
123           if ((flags & FNM_PERIOD) && sc == L('.') &&
124               (n == string || ((flags & FNM_PATHNAME) && n[-1] == L('/'))))
125             /* `*' cannot match a `.' if it is the first character of the
126                string or if it is the first character following a slash and
127                we are matching a pathname. */
128             return FNM_NOMATCH;
129
130           /* Collapse multiple consecutive `*' and `?', but make sure that
131              one character of the string is consumed for each `?'. */
132           for (c = *p++; (c == L('?') || c == L('*')); c = *p++)
133             {
134               if ((flags & FNM_PATHNAME) && sc == L('/'))
135                 /* A slash does not match a wildcard under FNM_PATHNAME. */
136                 return FNM_NOMATCH;
137               else if (c == L('?'))
138                 {
139                   if (sc == L('\0'))
140                     return FNM_NOMATCH;
141                   /* One character of the string is consumed in matching
142                      this ? wildcard, so *??? won't match if there are
143                      fewer than three characters. */
144                   n++;
145                   sc = n < se ? *n : '\0';
146                 }
147
148 #ifdef EXTENDED_GLOB
149               /* Handle ******(patlist) */
150               if ((flags & FNM_EXTMATCH) && c == L('*') && *p == L('('))  /*)*/
151                 {
152                   CHAR *newn;
153                   /* We need to check whether or not the extended glob
154                      pattern matches the remainder of the string.
155                      If it does, we match the entire pattern. */
156                   for (newn = n; newn < se; ++newn)
157                     {
158                       if (EXTMATCH (c, newn, se, p, pe, flags) == 0)
159                         return (0);
160                     }
161                   /* We didn't match the extended glob pattern, but
162                      that's OK, since we can match 0 or more occurrences.
163                      We need to skip the glob pattern and see if we
164                      match the rest of the string. */
165                   newn = PATSCAN (p + 1, pe, 0);
166                   /* If NEWN is 0, we have an ill-formed pattern. */
167                   p = newn ? newn : pe;
168                 }
169 #endif
170               if (p == pe)
171                 break;
172             }
173
174           /* If we've hit the end of the pattern and the last character of
175              the pattern was handled by the loop above, we've succeeded.
176              Otherwise, we need to match that last character. */
177           if (p == pe && (c == L('?') || c == L('*')))
178             return (0);
179
180           /* General case, use recursion. */
181           {
182             U_CHAR c1;
183
184             c1 = ((flags & FNM_NOESCAPE) == 0 && c == L('\\')) ? *p : c;
185             c1 = FOLD (c1);
186             for (--p; n < se; ++n)
187               {
188                 /* Only call strmatch if the first character indicates a
189                    possible match.  We can check the first character if
190                    we're not doing an extended glob match. */
191                 if ((flags & FNM_EXTMATCH) == 0 && c != L('[') && FOLD (*n) != c1) /*]*/
192                   continue;
193
194                 /* If we're doing an extended glob match and the pattern is not
195                    one of the extended glob patterns, we can check the first
196                    character. */
197                 if ((flags & FNM_EXTMATCH) && p[1] != L('(') && /*)*/
198                     STRCHR (L("?*+@!"), *p) == 0 && c != L('[') && FOLD (*n) != c1) /*]*/
199                   continue;
200
201                 /* Otherwise, we just recurse. */
202                 if (GMATCH (n, se, p, pe, flags & ~FNM_PERIOD) == 0)
203                   return (0);
204               }
205             return FNM_NOMATCH;
206           }
207
208         case L('['):
209           {
210             if (sc == L('\0') || n == se)
211               return FNM_NOMATCH;
212
213             /* A character class cannot match a `.' if it is the first
214                character of the string or if it is the first character
215                following a slash and we are matching a pathname. */
216             if ((flags & FNM_PERIOD) && sc == L('.') &&
217                 (n == string || ((flags & FNM_PATHNAME) && n[-1] == L('/'))))
218               return (FNM_NOMATCH);
219
220             p = BRACKMATCH (p, sc, flags);
221             if (p == 0)
222               return FNM_NOMATCH;
223           }
224           break;
225
226         default:
227           if ((U_CHAR)c != FOLD (sc))
228             return (FNM_NOMATCH);
229         }
230
231       ++n;
232     }
233
234   if (n == se)
235     return (0);
236
237   if ((flags & FNM_LEADING_DIR) && *n == L('/'))
238     /* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz".  */
239     return 0;
240           
241   return (FNM_NOMATCH);
242 }
243
244 /* Parse a bracket expression collating symbol ([.sym.]) starting at P, find
245    the value of the symbol, and move P past the collating symbol expression.
246    The value is returned in *VP, if VP is not null. */
247 static CHAR *
248 PARSE_COLLSYM (p, vp)
249      CHAR *p;
250      INT *vp;
251 {
252   register int pc;
253   INT val;
254
255   p++;                          /* move past the `.' */
256           
257   for (pc = 0; p[pc]; pc++)
258     if (p[pc] == L('.') && p[pc+1] == L(']'))
259       break;
260    val = COLLSYM (p, pc);
261    if (vp)
262      *vp = val;
263    return (p + pc + 2);
264 }
265
266 /* Use prototype definition here because of type promotion. */
267 static CHAR *
268 #if defined (PROTOTYPES)
269 BRACKMATCH (CHAR *p, U_CHAR test, int flags)
270 #else
271 BRACKMATCH (p, test, flags)
272      CHAR *p;
273      U_CHAR test;
274      int flags;
275 #endif
276 {
277   register CHAR cstart, cend, c;
278   register int not;    /* Nonzero if the sense of the character class is inverted.  */
279   int brcnt;
280   INT pc;
281   CHAR *savep;
282
283   test = FOLD (test);
284
285   savep = p;
286
287   /* POSIX.2 3.13.1 says that an exclamation mark (`!') shall replace the
288      circumflex (`^') in its role in a `nonmatching list'.  A bracket
289      expression starting with an unquoted circumflex character produces
290      unspecified results.  This implementation treats the two identically. */
291   if (not = (*p == L('!') || *p == L('^')))
292     ++p;
293
294   c = *p++;
295   for (;;)
296     {
297       /* Initialize cstart and cend in case `-' is the last
298          character of the pattern. */
299       cstart = cend = c;
300
301       /* POSIX.2 equivalence class:  [=c=].  See POSIX.2 2.8.3.2.  Find
302          the end of the equivalence class, move the pattern pointer past
303          it, and check for equivalence.  XXX - this handles only
304          single-character equivalence classes, which is wrong, or at
305          least incomplete. */
306       if (c == L('[') && *p == L('=') && p[2] == L('=') && p[3] == L(']'))
307         {
308           pc = FOLD (p[1]);
309           p += 4;
310           if (COLLEQUIV (test, pc))
311             {
312 /*[*/         /* Move past the closing `]', since the first thing we do at
313                  the `matched:' label is back p up one. */
314               p++;
315               goto matched;
316             }
317           else
318             {
319               c = *p++;
320               if (c == L('\0'))
321                 return ((test == L('[')) ? savep : (CHAR *)0); /*]*/
322               c = FOLD (c);
323               continue;
324             }
325         }
326
327       /* POSIX.2 character class expression.  See POSIX.2 2.8.3.2. */
328       if (c == L('[') && *p == L(':'))
329         {
330           CHAR *close, *ccname;
331
332           pc = 0;       /* make sure invalid char classes don't match. */
333           /* Find end of character class name */
334           for (close = p + 1; *close != '\0'; close++)
335             if (*close == L(':') && *(close+1) == L(']'))
336               break;
337
338           if (*close != L('\0'))
339             {
340               ccname = (CHAR *)malloc ((close - p) * sizeof (CHAR));
341               if (ccname == 0)
342                 pc = 0;
343               else
344                 {
345                   bcopy (p + 1, ccname, (close - p - 1) * sizeof (CHAR));
346                   *(ccname + (close - p - 1)) = L('\0');
347                   pc = IS_CCLASS (test, ccname);
348                 }
349               if (pc == -1)
350                 pc = 0;
351               else
352                 p = close + 2;
353
354               free (ccname);
355             }
356             
357           if (pc)
358             {
359 /*[*/         /* Move past the closing `]', since the first thing we do at
360                  the `matched:' label is back p up one. */
361               p++;
362               goto matched;
363             }
364           else
365             {
366               /* continue the loop here, since this expression can't be
367                  the first part of a range expression. */
368               c = *p++;
369               if (c == L('\0'))
370                 return ((test == L('[')) ? savep : (CHAR *)0);
371               else if (c == L(']'))
372                 break;
373               c = FOLD (c);
374               continue;
375             }
376         }
377  
378       /* POSIX.2 collating symbols.  See POSIX.2 2.8.3.2.  Find the end of
379          the symbol name, make sure it is terminated by `.]', translate
380          the name to a character using the external table, and do the
381          comparison. */
382       if (c == L('[') && *p == L('.'))
383         {
384           p = PARSE_COLLSYM (p, &pc);
385           /* An invalid collating symbol cannot be the first point of a
386              range.  If it is, we set cstart to one greater than `test',
387              so any comparisons later will fail. */
388           cstart = (pc == INVALID) ? test + 1 : pc;
389         }
390
391       if (!(flags & FNM_NOESCAPE) && c == L('\\'))
392         {
393           if (*p == '\0')
394             return (CHAR *)0;
395           cstart = cend = *p++;
396         }
397
398       cstart = cend = FOLD (cstart);
399
400       /* POSIX.2 2.8.3.1.2 says: `An expression containing a `[' that
401          is not preceded by a backslash and is not part of a bracket
402          expression produces undefined results.'  This implementation
403          treats the `[' as just a character to be matched if there is
404          not a closing `]'. */
405       if (c == L('\0'))
406         return ((test == L('[')) ? savep : (CHAR *)0);
407
408       c = *p++;
409       c = FOLD (c);
410
411       if ((flags & FNM_PATHNAME) && c == L('/'))
412         /* [/] can never match when matching a pathname.  */
413         return (CHAR *)0;
414
415       /* This introduces a range, unless the `-' is the last
416          character of the class.  Find the end of the range
417          and move past it. */
418       if (c == L('-') && *p != L(']'))
419         {
420           cend = *p++;
421           if (!(flags & FNM_NOESCAPE) && cend == L('\\'))
422             cend = *p++;
423           if (cend == L('\0'))
424             return (CHAR *)0;
425           if (cend == L('[') && *p == L('.'))
426             {
427               p = PARSE_COLLSYM (p, &pc);
428               /* An invalid collating symbol cannot be the second part of a
429                  range expression.  If we get one, we set cend to one fewer
430                  than the test character to make sure the range test fails. */
431               cend = (pc == INVALID) ? test - 1 : pc;
432             }
433           cend = FOLD (cend);
434
435           c = *p++;
436
437           /* POSIX.2 2.8.3.2:  ``The ending range point shall collate
438              equal to or higher than the starting range point; otherwise
439              the expression shall be treated as invalid.''  Note that this
440              applies to only the range expression; the rest of the bracket
441              expression is still checked for matches. */
442           if (RANGECMP (cstart, cend) > 0)
443             {
444               if (c == L(']'))
445                 break;
446               c = FOLD (c);
447               continue;
448             }
449         }
450
451       if (RANGECMP (test, cstart) >= 0 && RANGECMP (test, cend) <= 0)
452         goto matched;
453
454       if (c == L(']'))
455         break;
456     }
457   /* No match. */
458   return (!not ? (CHAR *)0 : p);
459
460 matched:
461   /* Skip the rest of the [...] that already matched.  */
462   c = *--p;
463   brcnt = 1;
464   while (brcnt > 0)
465     {
466       /* A `[' without a matching `]' is just another character to match. */
467       if (c == L('\0'))
468         return ((test == L('[')) ? savep : (CHAR *)0);
469
470       c = *p++;
471       if (c == L('[') && (*p == L('=') || *p == L(':') || *p == L('.')))
472         brcnt++;
473       else if (c == L(']'))
474         brcnt--;
475       else if (!(flags & FNM_NOESCAPE) && c == L('\\'))
476         {
477           if (*p == '\0')
478             return (CHAR *)0;
479           /* XXX 1003.2d11 is unclear if this is right. */
480           ++p;
481         }
482     }
483   return (not ? (CHAR *)0 : p);
484 }
485
486 #if defined (EXTENDED_GLOB)
487 /* ksh-like extended pattern matching:
488
489         [?*+@!](pat-list)
490
491    where pat-list is a list of one or patterns separated by `|'.  Operation
492    is as follows:
493
494         ?(patlist)      match zero or one of the given patterns
495         *(patlist)      match zero or more of the given patterns
496         +(patlist)      match one or more of the given patterns
497         @(patlist)      match exactly one of the given patterns
498         !(patlist)      match anything except one of the given patterns
499 */
500
501 /* Scan a pattern starting at STRING and ending at END, keeping track of
502    embedded () and [].  If DELIM is 0, we scan until a matching `)'
503    because we're scanning a `patlist'.  Otherwise, we scan until we see
504    DELIM.  In all cases, we never scan past END.  The return value is the
505    first character after the matching DELIM. */
506 static CHAR *
507 PATSCAN (string, end, delim)
508      CHAR *string, *end;
509      INT delim;
510 {
511   int pnest, bnest;
512   INT cchar;
513   CHAR *s, c, *bfirst;
514
515   pnest = bnest = 0;
516   cchar = 0;
517   bfirst = NULL;
518
519   for (s = string; c = *s; s++)
520     {
521       if (s >= end)
522         return (s);
523       switch (c)
524         {
525         case L('\0'):
526           return ((CHAR *)NULL);
527
528         /* `[' is not special inside a bracket expression, but it may
529            introduce one of the special POSIX bracket expressions
530            ([.SYM.], [=c=], [: ... :]) that needs special handling. */
531         case L('['):
532           if (bnest == 0)
533             {
534               bfirst = s + 1;
535               if (*bfirst == L('!') || *bfirst == L('^'))
536                 bfirst++;
537               bnest++;
538             }
539           else if (s[1] == L(':') || s[1] == L('.') || s[1] == L('='))
540             cchar = s[1];
541           break;
542
543         /* `]' is not special if it's the first char (after a leading `!'
544            or `^') in a bracket expression or if it's part of one of the
545            special POSIX bracket expressions ([.SYM.], [=c=], [: ... :]) */
546         case L(']'):
547           if (bnest)
548             {
549               if (cchar && s[-1] == cchar)
550                 cchar = 0;
551               else if (s != bfirst)
552                 {
553                   bnest--;
554                   bfirst = 0;
555                 }
556             }
557           break;
558
559         case L('('):
560           if (bnest == 0)
561             pnest++;
562           break;
563
564         case L(')'):
565           if (bnest == 0 && pnest-- <= 0)
566             return ++s;
567           break;
568
569         case L('|'):
570           if (bnest == 0 && pnest == 0 && delim == L('|'))
571             return ++s;
572           break;
573         }
574     }
575
576   return (NULL);
577 }
578
579 /* Return 0 if dequoted pattern matches S in the current locale. */
580 static int
581 STRCOMPARE (p, pe, s, se)
582      CHAR *p, *pe, *s, *se;
583 {
584   int ret;
585   CHAR c1, c2;
586
587   c1 = *pe;
588   c2 = *se;
589
590   *pe = *se = '\0';
591 #if HAVE_MULTIBYTE || defined (HAVE_STRCOLL)
592   ret = STRCOLL ((XCHAR *)p, (XCHAR *)s);
593 #else
594   ret = STRCMP ((XCHAR *)p, (XCHAR *)s);
595 #endif
596
597   *pe = c1;
598   *se = c2;
599
600   return (ret == 0 ? ret : FNM_NOMATCH);
601 }
602
603 /* Match a ksh extended pattern specifier.  Return FNM_NOMATCH on failure or
604    0 on success.  This is handed the entire rest of the pattern and string
605    the first time an extended pattern specifier is encountered, so it calls
606    gmatch recursively. */
607 static int
608 EXTMATCH (xc, s, se, p, pe, flags)
609      INT xc;            /* select which operation */
610      CHAR *s, *se;
611      CHAR *p, *pe;
612      int flags;
613 {
614   CHAR *prest;                  /* pointer to rest of pattern */
615   CHAR *psub;                   /* pointer to sub-pattern */
616   CHAR *pnext;                  /* pointer to next sub-pattern */
617   CHAR *srest;                  /* pointer to rest of string */
618   int m1, m2;
619
620 #if DEBUG_MATCHING
621 fprintf(stderr, "extmatch: xc = %c\n", xc);
622 fprintf(stderr, "extmatch: s = %s; se = %s\n", s, se);
623 fprintf(stderr, "extmatch: p = %s; pe = %s\n", p, pe);
624 #endif
625
626   prest = PATSCAN (p + (*p == L('(')), pe, 0); /* ) */
627   if (prest == 0)
628     /* If PREST is 0, we failed to scan a valid pattern.  In this
629        case, we just want to compare the two as strings. */
630     return (STRCOMPARE (p - 1, pe, s, se));
631
632   switch (xc)
633     {
634     case L('+'):                /* match one or more occurrences */
635     case L('*'):                /* match zero or more occurrences */
636       /* If we can get away with no matches, don't even bother.  Just
637          call GMATCH on the rest of the pattern and return success if
638          it succeeds. */
639       if (xc == L('*') && (GMATCH (s, se, prest, pe, flags) == 0))
640         return 0;
641
642       /* OK, we have to do this the hard way.  First, we make sure one of
643          the subpatterns matches, then we try to match the rest of the
644          string. */
645       for (psub = p + 1; ; psub = pnext)
646         {
647           pnext = PATSCAN (psub, pe, L('|'));
648           for (srest = s; srest <= se; srest++)
649             {
650               /* Match this substring (S -> SREST) against this
651                  subpattern (psub -> pnext - 1) */
652               m1 = GMATCH (s, srest, psub, pnext - 1, flags) == 0;
653               /* OK, we matched a subpattern, so make sure the rest of the
654                  string matches the rest of the pattern.  Also handle
655                  multiple matches of the pattern. */
656               if (m1)
657                 m2 = (GMATCH (srest, se, prest, pe, flags) == 0) ||
658                       (s != srest && GMATCH (srest, se, p - 1, pe, flags) == 0);
659               if (m1 && m2)
660                 return (0);
661             }
662           if (pnext == prest)
663             break;
664         }
665       return (FNM_NOMATCH);
666
667     case L('?'):                /* match zero or one of the patterns */
668     case L('@'):                /* match exactly one of the patterns */
669       /* If we can get away with no matches, don't even bother.  Just
670          call gmatch on the rest of the pattern and return success if
671          it succeeds. */
672       if (xc == L('?') && (GMATCH (s, se, prest, pe, flags) == 0))
673         return 0;
674
675       /* OK, we have to do this the hard way.  First, we see if one of
676          the subpatterns matches, then, if it does, we try to match the
677          rest of the string. */
678       for (psub = p + 1; ; psub = pnext)
679         {
680           pnext = PATSCAN (psub, pe, L('|'));
681           srest = (prest == pe) ? se : s;
682           for ( ; srest <= se; srest++)
683             {
684               if (GMATCH (s, srest, psub, pnext - 1, flags) == 0 &&
685                   GMATCH (srest, se, prest, pe, flags) == 0)
686                 return (0);
687             }
688           if (pnext == prest)
689             break;
690         }
691       return (FNM_NOMATCH);
692
693     case '!':           /* match anything *except* one of the patterns */
694       for (srest = s; srest <= se; srest++)
695         {
696           m1 = 0;
697           for (psub = p + 1; ; psub = pnext)
698             {
699               pnext = PATSCAN (psub, pe, L('|'));
700               /* If one of the patterns matches, just bail immediately. */
701               if (m1 = (GMATCH (s, srest, psub, pnext - 1, flags) == 0))
702                 break;
703               if (pnext == prest)
704                 break;
705             }
706           if (m1 == 0 && GMATCH (srest, se, prest, pe, flags) == 0)
707             return (0);
708         }
709       return (FNM_NOMATCH);
710     }
711
712   return (FNM_NOMATCH);
713 }
714 #endif /* EXTENDED_GLOB */
715
716 #undef IS_CCLASS
717 #undef FOLD
718 #undef CHAR
719 #undef U_CHAR
720 #undef XCHAR
721 #undef INT
722 #undef INVALID
723 #undef FCT
724 #undef GMATCH
725 #undef COLLSYM
726 #undef PARSE_COLLSYM
727 #undef PATSCAN
728 #undef STRCOMPARE
729 #undef EXTMATCH
730 #undef BRACKMATCH
731 #undef STRCHR
732 #undef STRCOLL
733 #undef STRLEN
734 #undef STRCMP
735 #undef COLLEQUIV
736 #undef RANGECMP
737 #undef L