Fix a boundary condition error in slow() and fast() in multibyte locales:

we must allow the character beginning at "p" to be converted to a wide
character for the purposes of EOL processing and word-boundary matching.
This commit is contained in:
Tim J. Robbins 2005-08-17 11:37:38 +00:00
parent 0eac054729
commit 1ee0dbee57
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=149180

View file

@ -808,10 +808,11 @@ sopno stopst;
for (;;) {
/* next character */
lastc = c;
if (p == m->endp)
if (p == m->endp) {
clen = 0;
c = OUT;
else
clen = XMBRTOWC(&c, p, stop - p, &m->mbs, BADCHAR);
} else
clen = XMBRTOWC(&c, p, m->endp - p, &m->mbs, BADCHAR);
if (EQ(st, fresh))
coldp = p;
@ -849,7 +850,7 @@ sopno stopst;
}
/* are we done? */
if (ISSET(st, stopst) || p == stop)
if (ISSET(st, stopst) || p == stop || clen > stop - p)
break; /* NOTE BREAK OUT */
/* no, we must deal with this character */
@ -917,7 +918,7 @@ sopno stopst;
c = OUT;
clen = 0;
} else
clen = XMBRTOWC(&c, p, stop - p, &m->mbs, BADCHAR);
clen = XMBRTOWC(&c, p, m->endp - p, &m->mbs, BADCHAR);
/* is there an EOL and/or BOL between lastc and c? */
flagch = '\0';
@ -955,7 +956,7 @@ sopno stopst;
/* are we done? */
if (ISSET(st, stopst))
matchp = p;
if (EQ(st, empty) || p == stop)
if (EQ(st, empty) || p == stop || clen > stop - p)
break; /* NOTE BREAK OUT */
/* no, we must deal with this character */