]> git.saurik.com Git - apple/libc.git/blame - regex/FreeBSD/regex2.h.patch
Libc-763.13.tar.gz
[apple/libc.git] / regex / FreeBSD / regex2.h.patch
CommitLineData
1f2f436a
A
1--- regex2.h.bsdnew 2009-11-11 11:29:04.000000000 -0800
2+++ regex2.h 2009-11-11 12:18:35.000000000 -0800
3@@ -120,14 +120,23 @@ typedef struct {
224c7076
A
4 int nranges;
5 int invert;
6 int icase;
7+ int *equiv_classes;
8+ int nequiv_classes;
3d9156a7
A
9 } cset;
10
224c7076
A
11+#include "collate.h"
12+
3d9156a7 13 static int
1f2f436a
A
14-CHIN1(cset *cs, wint_t ch)
15+CHIN1(cset *cs, wint_t ch, locale_t loc)
3d9156a7
A
16 {
17 int i;
18
224c7076
A
19 assert(ch >= 0);
20+ for (i = 0; i < cs->nequiv_classes; i++)
21+ /* sadly, we can only deal with single characters from an
22+ * equivalence class */
23+ if (__collate_equiv_match(cs->equiv_classes[i], NULL, 0, ch, NULL, 0, NULL, NULL, loc) > 0)
24+ return (!cs->invert);
25 if (ch < NC)
26 return (((cs->bmp[ch >> 3] & (1 << (ch & 7))) != 0) ^
27 cs->invert);
1f2f436a 28@@ -138,24 +147,24 @@ CHIN1(cset *cs, wint_t ch)
3d9156a7
A
29 if (cs->ranges[i].min <= ch && ch <= cs->ranges[i].max)
30 return (!cs->invert);
31 for (i = 0; i < cs->ntypes; i++)
32- if (iswctype(ch, cs->types[i]))
33+ if (iswctype_l(ch, cs->types[i], loc))
34 return (!cs->invert);
35 return (cs->invert);
36 }
37
38 static __inline int
1f2f436a
A
39-CHIN(cset *cs, wint_t ch)
40+CHIN(cset *cs, wint_t ch, locale_t loc)
3d9156a7
A
41 {
42
43 assert(ch >= 0);
224c7076
A
44- if (ch < NC)
45+ if (ch < NC && cs->nequiv_classes == 0)
3d9156a7
A
46 return (((cs->bmp[ch >> 3] & (1 << (ch & 7))) != 0) ^
47 cs->invert);
48 else if (cs->icase)
49- return (CHIN1(cs, ch) || CHIN1(cs, towlower(ch)) ||
50- CHIN1(cs, towupper(ch)));
51+ return (CHIN1(cs, ch, loc) || CHIN1(cs, towlower_l(ch, loc), loc) ||
52+ CHIN1(cs, towupper_l(ch, loc), loc));
53 else
54- return (CHIN1(cs, ch));
55+ return (CHIN1(cs, ch, loc));
56 }
57
58 /*
1f2f436a 59@@ -185,8 +194,9 @@ struct re_guts {
3d9156a7
A
60 size_t nsub; /* copy of re_nsub */
61 int backrefs; /* does it use back references? */
62 sopno nplus; /* how deep does it nest +s? */
63+ locale_t loc; /* current locale */
64 };
65
66 /* misc utilities */
1f2f436a 67-#define OUT (CHAR_MIN - 1) /* a non-character value */
3d9156a7 68-#define ISWORD(c) (iswalnum((uch)(c)) || (c) == '_')
1f2f436a 69+#define OUT (CHAR_MIN - 2) /* a non-character value */
3d9156a7 70+#define ISWORD(c,l) (iswalnum_l((uch)(c), l) || (c) == '_')