altoffset() always returned whenever it recursed, because at the end

of the processing of the recursion, "scan" would be pointing to O_CH
(or O_QUEST), which would then be interpreted as being the end character
for altoffset().

We avoid this by properly increasing scan before leaving the switch.

Without this, something like (a?b?)?cc would result in a g->moffset of
1 instead of 2.

I added a case to the soon-to-be-imported regex(3) test code to catch
this error.
This commit is contained in:
Daniel C. Sobral 2000-07-09 17:45:30 +00:00
parent b6c1a56180
commit 8f9e434f46
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=62855

View file

@ -1891,6 +1891,10 @@ int mccs;
OP(s) != OOR2)
return -1;
} while (OP(s) != O_QUEST && OP(s) != O_CH);
/* We must skip to the next position, or we'll
* leave altoffset() too early.
*/
scan++;
break;
case OANYOF:
if (mccs)