]> git.saurik.com Git - apple/libc.git/blob - regex/FreeBSD/engine.c.patch
ebf6da28b6832af69cdc5cd79a76476ef333366f
[apple/libc.git] / regex / FreeBSD / engine.c.patch
1 --- engine.c.bsdnew 2009-11-11 11:29:04.000000000 -0800
2 +++ engine.c 2009-11-11 11:30:28.000000000 -0800
3 @@ -272,7 +272,7 @@ matcher(struct re_guts *g,
4 break;
5 assert(m->coldp < m->endp);
6 m->coldp += XMBRTOWC(NULL, m->coldp,
7 - m->endp - m->coldp, &m->mbs, 0);
8 + m->endp - m->coldp, &m->mbs, 0, g->loc);
9 }
10 if (nmatch == 1 && !g->backrefs)
11 break; /* no further info needed */
12 @@ -333,7 +333,7 @@ matcher(struct re_guts *g,
13 NOTE("false alarm");
14 /* recycle starting later */
15 start = m->coldp + XMBRTOWC(NULL, m->coldp,
16 - stop - m->coldp, &m->mbs, 0);
17 + stop - m->coldp, &m->mbs, 0, g->loc);
18 assert(start <= stop);
19 }
20
21 @@ -410,7 +410,7 @@ dissect(struct match *m,
22 assert(nope);
23 break;
24 case OCHAR:
25 - sp += XMBRTOWC(NULL, sp, stop - start, &m->mbs, 0);
26 + sp += XMBRTOWC(NULL, sp, stop - start, &m->mbs, 0, m->g->loc);
27 break;
28 case OBOL:
29 case OEOL:
30 @@ -419,7 +419,7 @@ dissect(struct match *m,
31 break;
32 case OANY:
33 case OANYOF:
34 - sp += XMBRTOWC(NULL, sp, stop - start, &m->mbs, 0);
35 + sp += XMBRTOWC(NULL, sp, stop - start, &m->mbs, 0, m->g->loc);
36 break;
37 case OBACK_:
38 case O_BACK:
39 @@ -480,6 +480,10 @@ dissect(struct match *m,
40 sep = ssp;
41 ssp = oldssp;
42 }
43 + else if (tail==rest) {
44 + /* Fix for test expr 105 */
45 + ssp = oldssp;
46 + }
47 assert(sep == rest); /* must exhaust substring */
48 assert(slow(m, ssp, sep, ssub, esub) == rest);
49 dp = dissect(m, ssp, sep, ssub, esub);
50 @@ -532,6 +536,14 @@ dissect(struct match *m,
51 i = OPND(m->g->strip[ss]);
52 assert(0 < i && i <= m->g->nsub);
53 m->pmatch[i].rm_so = sp - m->offp;
54 + /* fix for T.regcomp 43: don't remember previous
55 + subexpression matches beyond the current one (i) */
56 + i++;
57 + while (i<= m->g->nsub) {
58 + m->pmatch[i].rm_so = -1;
59 + m->pmatch[i].rm_eo = -1;
60 + i++;
61 + }
62 break;
63 case ORPAREN:
64 i = OPND(m->g->strip[ss]);
65 @@ -586,14 +598,14 @@ backref(struct match *m,
66 case OCHAR:
67 if (sp == stop)
68 return(NULL);
69 - sp += XMBRTOWC(&wc, sp, stop - sp, &m->mbs, BADCHAR);
70 + sp += XMBRTOWC(&wc, sp, stop - sp, &m->mbs, BADCHAR, m->g->loc);
71 if (wc != OPND(s))
72 return(NULL);
73 break;
74 case OANY:
75 if (sp == stop)
76 return(NULL);
77 - sp += XMBRTOWC(&wc, sp, stop - sp, &m->mbs, BADCHAR);
78 + sp += XMBRTOWC(&wc, sp, stop - sp, &m->mbs, BADCHAR, m->g->loc);
79 if (wc == BADCHAR)
80 return (NULL);
81 break;
82 @@ -601,8 +613,8 @@ backref(struct match *m,
83 if (sp == stop)
84 return (NULL);
85 cs = &m->g->sets[OPND(s)];
86 - sp += XMBRTOWC(&wc, sp, stop - sp, &m->mbs, BADCHAR);
87 - if (wc == BADCHAR || !CHIN(cs, wc))
88 + sp += XMBRTOWC(&wc, sp, stop - sp, &m->mbs, BADCHAR, m->g->loc);
89 + if (wc == BADCHAR || !CHIN(cs, wc, m->g->loc))
90 return(NULL);
91 break;
92 case OBOL:
93 @@ -626,8 +638,8 @@ backref(struct match *m,
94 (sp < m->endp && *(sp-1) == '\n' &&
95 (m->g->cflags&REG_NEWLINE)) ||
96 (sp > m->beginp &&
97 - !ISWORD(*(sp-1))) ) &&
98 - (sp < m->endp && ISWORD(*sp)) )
99 + !ISWORD(*(sp-1), m->g->loc)) ) &&
100 + (sp < m->endp && ISWORD(*sp, m->g->loc)) )
101 { /* yes */ }
102 else
103 return(NULL);
104 @@ -636,8 +648,8 @@ backref(struct match *m,
105 if (( (sp == m->endp && !(m->eflags&REG_NOTEOL)) ||
106 (sp < m->endp && *sp == '\n' &&
107 (m->g->cflags&REG_NEWLINE)) ||
108 - (sp < m->endp && !ISWORD(*sp)) ) &&
109 - (sp > m->beginp && ISWORD(*(sp-1))) )
110 + (sp < m->endp && !ISWORD(*sp, m->g->loc)) ) &&
111 + (sp > m->beginp && ISWORD(*(sp-1), m->g->loc)) )
112 { /* yes */ }
113 else
114 return(NULL);
115 @@ -811,7 +823,7 @@ fast( struct match *m,
116 clen = 0;
117 c = OUT;
118 } else
119 - clen = XMBRTOWC(&c, p, m->endp - p, &m->mbs, BADCHAR);
120 + clen = XMBRTOWC(&c, p, m->endp - p, &m->mbs, BADCHAR, m->g->loc);
121 if (EQ(st, fresh))
122 coldp = p;
123
124 @@ -835,12 +847,12 @@ fast( struct match *m,
125 }
126
127 /* how about a word boundary? */
128 - if ( (flagch == BOL || (lastc != OUT && !ISWORD(lastc))) &&
129 - (c != OUT && ISWORD(c)) ) {
130 + if ( (flagch == BOL || (lastc != OUT && !ISWORD(lastc, m->g->loc))) &&
131 + (c != OUT && ISWORD(c, m->g->loc)) ) {
132 flagch = BOW;
133 }
134 - if ( (lastc != OUT && ISWORD(lastc)) &&
135 - (flagch == EOL || (c != OUT && !ISWORD(c))) ) {
136 + if ( (lastc != OUT && ISWORD(lastc, m->g->loc)) &&
137 + (flagch == EOL || (c != OUT && !ISWORD(c, m->g->loc))) ) {
138 flagch = EOW;
139 }
140 if (flagch == BOW || flagch == EOW) {
141 @@ -865,7 +877,7 @@ fast( struct match *m,
142 assert(coldp != NULL);
143 m->coldp = coldp;
144 if (ISSET(st, stopst))
145 - return(p+XMBRTOWC(NULL, p, stop - p, &m->mbs, 0));
146 + return(p+XMBRTOWC(NULL, p, stop - p, &m->mbs, 0, m->g->loc));
147 else
148 return(NULL);
149 }
150 @@ -916,7 +928,7 @@ slow( struct match *m,
151 c = OUT;
152 clen = 0;
153 } else
154 - clen = XMBRTOWC(&c, p, m->endp - p, &m->mbs, BADCHAR);
155 + clen = XMBRTOWC(&c, p, m->endp - p, &m->mbs, BADCHAR, m->g->loc);
156
157 /* is there an EOL and/or BOL between lastc and c? */
158 flagch = '\0';
159 @@ -938,12 +950,12 @@ slow( struct match *m,
160 }
161
162 /* how about a word boundary? */
163 - if ( (flagch == BOL || (lastc != OUT && !ISWORD(lastc))) &&
164 - (c != OUT && ISWORD(c)) ) {
165 + if ( (flagch == BOL || (lastc != OUT && !ISWORD(lastc, m->g->loc))) &&
166 + (c != OUT && ISWORD(c, m->g->loc)) ) {
167 flagch = BOW;
168 }
169 - if ( (lastc != OUT && ISWORD(lastc)) &&
170 - (flagch == EOL || (c != OUT && !ISWORD(c))) ) {
171 + if ( (lastc != OUT && ISWORD(lastc, m->g->loc)) &&
172 + (flagch == EOL || (c != OUT && !ISWORD(c, m->g->loc))) ) {
173 flagch = EOW;
174 }
175 if (flagch == BOW || flagch == EOW) {
176 @@ -1033,7 +1045,7 @@ step(struct re_guts *g,
177 break;
178 case OANYOF:
179 cs = &g->sets[OPND(s)];
180 - if (!NONCHAR(ch) && CHIN(cs, ch))
181 + if (!NONCHAR(ch) && CHIN(cs, ch, g->loc))
182 FWD(aft, bef, 1);
183 break;
184 case OBACK_: /* ignored here */