Fix regexp bug I introduced back in July 2007. Some pathological regular expressions will now produce regexp overflow errors (safe, they just won't execute properly) again, but common regexps will now find the right matches when there is a choice to be made. This bug was causing the creation of /sys/src/9/port/systab.h to fail. After applying it and rebuilding libregexp, sed, sam, and acme, you can see that it worked by doing cd /sys/src/9/port; rc mksystab | grep SYSsys and not getting any lines. Right now you get cpu% cd /sys/src/9/port; rc mksystab | grep SYSsys [SYSR1] SYSsysr1, cpu% Russ Reference: /n/sources/patch/applied/regexp Date: Thu Jan 10 23:20:07 CET 2008 Signed-off-by: rsc@swtch.com --- /sys/src/libregexp/regexec.c Thu Jan 10 23:17:52 2008 +++ /sys/src/libregexp/regexec.c Thu Jan 10 23:17:51 2008 @@ -133,7 +133,7 @@ break; case OR: /* evaluate right choice later */ - if(_renewthread(tl, inst->right, ms, &tlp->se) == tle) + if(_renewthread(tlp, inst->right, ms, &tlp->se) == tle) return -1; /* efficiency: advance and re-evaluate */ continue; --- /sys/src/libregexp/rregexec.c Thu Jan 10 23:17:52 2008 +++ /sys/src/libregexp/rregexec.c Thu Jan 10 23:17:52 2008 @@ -125,7 +125,7 @@ break; case OR: /* evaluate right choice later */ - if(_renewthread(tl, inst->right, ms, &tlp->se) == tle) + if(_renewthread(tlp, inst->right, ms, &tlp->se) == tle) return -1; /* efficiency: advance and re-evaluate */ continue; --- /sys/src/cmd/sam/regexp.c Thu Jan 10 23:17:53 2008 +++ /sys/src/cmd/sam/regexp.c Thu Jan 10 23:17:53 2008 @@ -646,7 +646,7 @@ break; case OR: /* evaluate right choice later */ - if(addinst(tl, inst->right, &tlp->se)) + if(addinst(tlp, inst->right, &tlp->se)) if(++ntl >= NLIST) goto Overflow; /* efficiency: advance and re-evaluate */ --- /sys/src/cmd/acme/regx.c Thu Jan 10 23:17:54 2008 +++ /sys/src/cmd/acme/regx.c Thu Jan 10 23:17:54 2008 @@ -666,7 +666,7 @@ break; case OR: /* evaluate right choice later */ - if(addinst(tl, inst->right, &tlp->se)) + if(addinst(tlp, inst->right, &tlp->se)) if(++ntl >= NLIST) goto Overflow; /* efficiency: advance and re-evaluate */