]> git.saurik.com Git - apple/libc.git/blob - regex/FreeBSD/engine.c.patch
b40e6d097eb476e7815f093d71079fda93ddce81
[apple/libc.git] / regex / FreeBSD / engine.c.patch
1 --- engine.c.orig 2004-11-25 11:38:32.000000000 -0800
2 +++ engine.c 2005-04-18 16:52:09.000000000 -0700
3 @@ -270,7 +270,7 @@ int eflags;
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 @@ -331,7 +331,7 @@ int eflags;
13 NOTE("false alarm");
14 /* recycle starting later */
15 start = m->coldp + XMBRTOWC(NULL, m->coldp,
16 - m->endp - m->coldp, &m->mbs, 0);
17 + m->endp - m->coldp, &m->mbs, 0, g->loc);
18 assert(start <= stop);
19 }
20
21 @@ -409,7 +409,7 @@ sopno stopst;
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 @@ -418,7 +418,7 @@ sopno stopst;
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 @@ -479,6 +479,10 @@ sopno stopst;
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 @@ -531,6 +535,14 @@ sopno stopst;
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 @@ -585,14 +597,14 @@ sopno lev; /* PLUS nesting level */
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 @@ -600,8 +612,8 @@ sopno lev; /* PLUS nesting level */
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 @@ -625,8 +637,8 @@ sopno lev; /* PLUS nesting level */
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 @@ -635,8 +647,8 @@ sopno lev; /* PLUS nesting level */
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 @@ -807,7 +819,7 @@ sopno stopst;
116 if (p == m->endp)
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 @@ -831,12 +843,12 @@ sopno stopst;
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 @@ -861,7 +873,7 @@ sopno stopst;
142 assert(coldp != NULL);
143 m->coldp = coldp;
144 if (ISSET(st, stopst))
145 - return(p+XMBRTOWC(NULL, p, m->endp - p, &m->mbs, 0));
146 + return(p+XMBRTOWC(NULL, p, m->endp - p, &m->mbs, 0, m->g->loc));
147 else
148 return(NULL);
149 }
150 @@ -913,7 +925,7 @@ sopno stopst;
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 @@ -935,12 +947,12 @@ sopno stopst;
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 @@ -1031,7 +1043,7 @@ states aft; /* states already known re
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 */