if (minlen)
dontbother++,strend--;
tmp = (s != startpos) ? UCHARAT(s - 1) : regprev;
- tmp = (OP(c) == BOUND ? isALNUM(tmp) : isALNUM_LC(tmp));
+ tmp = ((OP(c) == BOUND ? isALNUM(tmp) : isALNUM_LC(tmp)) != 0);
while (s < strend) {
- if (tmp != (OP(c) == BOUND ? isALNUM(*s) : isALNUM_LC(*s))) {
+ if (tmp == !(OP(c) == BOUND ? isALNUM(*s) : isALNUM_LC(*s))) {
tmp = !tmp;
if (regtry(prog, s))
goto got_it;
if (minlen)
dontbother++,strend--;
tmp = (s != startpos) ? UCHARAT(s - 1) : regprev;
- tmp = (OP(c) == NBOUND ? isALNUM(tmp) : isALNUM_LC(tmp));
+ tmp = ((OP(c) == NBOUND ? isALNUM(tmp) : isALNUM_LC(tmp)) != 0);
while (s < strend) {
- if (tmp != (OP(c) == NBOUND ? isALNUM(*s) : isALNUM_LC(*s)))
+ if (tmp == !(OP(c) == NBOUND ? isALNUM(*s) : isALNUM_LC(*s)))
tmp = !tmp;
else if (regtry(prog, s))
goto got_it;
prog->subbeg = strbeg;
prog->subend = strend;
prog->exec_tainted = regtainted;
- if (!safebase && (prog->nparens || sawampersand)) {
+
+ /* make sure $`, $&, $', and $digit will work later */
+ if (!safebase && (strbeg != prog->subbase)) {
I32 i = strend - startpos + (stringarg - strbeg);
- if (safebase) { /* no need for $digit later */
- s = strbeg;
- prog->subend = s+i;
- }
- else if (strbeg != prog->subbase) {
- s = savepvn(strbeg,i); /* so $digit will work later */
- if (prog->subbase)
- Safefree(prog->subbase);
- prog->subbeg = prog->subbase = s;
- prog->subend = s+i;
- }
- else {
- prog->subbeg = s = prog->subbase;
- prog->subend = s+i;
- }
- s += (stringarg - strbeg);
+ s = savepvn(strbeg, i);
+ Safefree(prog->subbase);
+ prog->subbase = s;
+ prog->subbeg = prog->subbase;
+ prog->subend = prog->subbase + i;
+ s = prog->subbase + (stringarg - strbeg);
for (i = 0; i <= prog->nparens; i++) {
if (prog->endp[i]) {
prog->startp[i] = s + (prog->startp[i] - startpos);
s = OPERAND(scan);
ln = *s++;
/* Inline the first character, for speed. */
- if (*s != nextchar)
+ if (UCHARAT(s) != nextchar)
sayNO;
if (regeol - locinput < ln)
sayNO;
- if (ln > 1 && memcmp(s, locinput, ln) != 0)
+ if (ln > 1 && memNE(s, locinput, ln))
sayNO;
locinput += ln;
nextchar = UCHARAT(locinput);
sayNO;
if (regeol - locinput < ln)
sayNO;
- if (ln > 1 && ((OP(scan) == EXACTF)
- ? ibcmp : ibcmp_locale)(s, locinput, ln) != 0)
+ if (ln > 1 && (OP(scan) == EXACTF
+ ? ibcmp(s, locinput, ln)
+ : ibcmp_locale(s, locinput, ln)))
sayNO;
locinput += ln;
nextchar = UCHARAT(locinput);
ln = isALNUM_LC(ln);
n = isALNUM_LC(nextchar);
}
- if ((ln == n) == (OP(scan) == BOUND || OP(scan) == BOUNDL))
+ if (((!ln) == (!n)) == (OP(scan) == BOUND || OP(scan) == BOUNDL))
sayNO;
break;
case SPACEL:
if (s == regendp[n])
break;
/* Inline the first character, for speed. */
- if (*s != nextchar)
+ if (UCHARAT(s) != nextchar)
sayNO;
ln = regendp[n] - s;
if (locinput + ln > regeol)
sayNO;
- if (ln > 1 && memcmp(s, locinput, ln) != 0)
+ if (ln > 1 && memNE(s, locinput, ln))
sayNO;
locinput += ln;
nextchar = UCHARAT(locinput);
* that we can try again after backing off.
*/
+ CHECKPOINT cp;
CURCUR* cc = regcc;
n = cc->cur + 1; /* how many we know we matched */
reginput = locinput;
/* If degenerate scan matches "", assume scan done. */
- if (locinput == cc->lastloc) {
+ if (locinput == cc->lastloc && n >= cc->min) {
regcc = cc->oldcc;
ln = regcc->cur;
if (regmatch(cc->next))
if (cc->minmod) {
regcc = cc->oldcc;
ln = regcc->cur;
- if (regmatch(cc->next))
+ cp = regcppush(cc->parenfloor);
+ if (regmatch(cc->next)) {
+ regcpblow(cp);
sayYES; /* All done. */
+ }
+ regcppop();
regcc->cur = ln;
regcc = cc;
reginput = locinput;
cc->cur = n;
cc->lastloc = locinput;
- if (regmatch(cc->scan))
+ cp = regcppush(cc->parenfloor);
+ if (regmatch(cc->scan)) {
+ regcpblow(cp);
sayYES;
+ }
+ regcppop();
cc->cur = n - 1;
sayNO;
}
/* Prefer scan over next for maximal matching. */
if (n < cc->max) { /* More greed allowed? */
- regcppush(cc->parenfloor);
+ cp = regcppush(cc->parenfloor);
cc->cur = n;
cc->lastloc = locinput;
- if (regmatch(cc->scan))
+ if (regmatch(cc->scan)) {
+ regcpblow(cp);
sayYES;
+ }
regcppop(); /* Restore some previous $<digit>s? */
reginput = locinput;
}