Comment on comment.
[p5sagit/p5-mst-13.2.git] / regexec.c
index cbc8c19..52aed0a 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -145,14 +145,14 @@ S_regcppush(pTHX_ I32 parenfloor)
 }
 
 /* These are needed since we do not localize EVAL nodes: */
-#  define REGCP_SET  DEBUG_r(PerlIO_printf(Perl_debug_log,             \
+#  define REGCP_SET(cp)  DEBUG_r(PerlIO_printf(Perl_debug_log,         \
                             "  Setting an EVAL scope, savestack=%"IVdf"\n",    \
-                            (IV)PL_savestack_ix)); lastcp = PL_savestack_ix
+                            (IV)PL_savestack_ix)); cp = PL_savestack_ix
 
-#  define REGCP_UNWIND  DEBUG_r(lastcp != PL_savestack_ix ?            \
+#  define REGCP_UNWIND(cp)  DEBUG_r(cp != PL_savestack_ix ?            \
                                PerlIO_printf(Perl_debug_log,           \
                                "  Clearing an EVAL scope, savestack=%"IVdf"..%"IVdf"\n", \
-                               (IV)lastcp, (IV)PL_savestack_ix) : 0); regcpblow(lastcp)
+                               (IV)(cp), (IV)PL_savestack_ix) : 0); regcpblow(cp)
 
 STATIC char *
 S_regcppop(pTHX)
@@ -219,7 +219,7 @@ typedef struct re_cc_state
     regexp *re;
 } re_cc_state;
 
-#define regcpblow(cp) LEAVE_SCOPE(cp)
+#define regcpblow(cp) LEAVE_SCOPE(cp)  /* Ignores regcppush()ed data. */
 
 #define TRYPAREN(paren, n, input) {                            \
     if (paren) {                                               \
@@ -325,6 +325,7 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
     register I32 end_shift;
     register char *s;
     register SV *check;
+    char *strbeg;
     char *t;
     I32 ml_anch;
     char *tmp;
@@ -351,23 +352,25 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
        DEBUG_r(PerlIO_printf(Perl_debug_log, "String too short...\n"));
        goto fail;
     }
+    strbeg = (sv && SvPOK(sv)) ? strend - SvCUR(sv) : strpos;
     check = prog->check_substr;
     if (prog->reganch & ROPT_ANCH) {   /* Match at beg-of-str or after \n */
        ml_anch = !( (prog->reganch & ROPT_ANCH_SINGLE)
                     || ( (prog->reganch & ROPT_ANCH_BOL)
                          && !PL_multiline ) ); /* Check after \n? */
 
-       if ((prog->check_offset_min == prog->check_offset_max) && !ml_anch) {
+       if (!ml_anch) {
+         if ( !(prog->reganch & ROPT_ANCH_GPOS) /* Checked by the caller */
+              /* SvCUR is not set on references: SvRV and SvPVX overlap */
+              && sv && !SvROK(sv)
+              && (strpos != strbeg)) {
+             DEBUG_r(PerlIO_printf(Perl_debug_log, "Not at start...\n"));
+             goto fail;
+         }
+         if (prog->check_offset_min == prog->check_offset_max) {
            /* Substring at constant offset from beg-of-str... */
            I32 slen;
 
-           if ( !(prog->reganch & ROPT_ANCH_GPOS) /* Checked by the caller */
-                /* SvCUR is not set on references: SvRV and SvPVX overlap */
-                && sv && !SvROK(sv)
-                && (strpos + SvCUR(sv) != strend)) {
-               DEBUG_r(PerlIO_printf(Perl_debug_log, "Not at start...\n"));
-               goto fail;
-           }
            PL_regeol = strend;                 /* Used in HOP() */
            s = HOPc(strpos, prog->check_offset_min);
            if (SvTAIL(check)) {
@@ -393,6 +396,7 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
                         && memNE(SvPVX(check), s, slen)))
                goto report_neq;
            goto success_at_start;
+         }
        }
        /* Match is anchored, but substr is not anchored wrt beg-of-str. */
        s = strpos;
@@ -426,7 +430,6 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
     /* Find a possible match in the region s..strend by looking for
        the "check" substring in the region corrected by start/end_shift. */
     if (flags & REXEC_SCREAM) {
-       char *strbeg = SvPVX(sv);       /* XXXX Assume PV_force() on SCREAM! */
        I32 p = -1;                     /* Internal iterator of scream. */
        I32 *pp = data ? data->scream_pos : &p;
 
@@ -668,7 +671,7 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
        /* Even in this situation we may use MBOL flag if strpos is offset
           wrt the start of the string. */
        if (ml_anch && sv && !SvROK(sv) /* See prev comment on SvROK */
-           && (strpos + SvCUR(sv) != strend) && strpos[-1] != '\n'
+           && (strpos != strbeg) && strpos[-1] != '\n'
            /* May be due to an implicit anchor of m{.*foo}  */
            && !(prog->reganch & ROPT_IMPLICIT))
        {
@@ -719,7 +722,7 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
                ? s + (prog->minlen? cl_l : 0)
                : (prog->float_substr ? check_at - start_shift + cl_l
                                      : strend) ;
-       char *startpos = sv && SvPOK(sv) ? strend - SvCUR(sv) : s;
+       char *startpos = strbeg;
 
        t = s;
        if (prog->reganch & ROPT_UTF8) {        
@@ -914,8 +917,15 @@ S_find_byclass(pTHX_ regexp * prog, regnode *c, char *s, char *strend, char *sta
            PL_reg_flags |= RF_tainted;
            /* FALL THROUGH */
        case BOUNDUTF8:
-           tmp = (I32)(s != startpos) ? utf8_to_uv(reghop((U8*)s, -1), 0) : '\n';
-           tmp = ((OP(c) == BOUNDUTF8 ? isALNUM_uni(tmp) : isALNUM_LC_uni(tmp)) != 0);
+           if (s == startpos)
+               tmp = '\n';
+           else {
+               U8 *r = reghop((U8*)s, -1);
+
+               tmp = (I32)utf8_to_uv(r, s - (char*)r, 0, 0);
+           }
+           tmp = ((OP(c) == BOUNDUTF8 ?
+                   isALNUM_uni(tmp) : isALNUM_LC_uni(tmp)) != 0);
            while (s < strend) {
                if (tmp == !(OP(c) == BOUNDUTF8 ?
                             swash_fetch(PL_utf8_alnum, (U8*)s) :
@@ -950,8 +960,15 @@ S_find_byclass(pTHX_ regexp * prog, regnode *c, char *s, char *strend, char *sta
            PL_reg_flags |= RF_tainted;
            /* FALL THROUGH */
        case NBOUNDUTF8:
-           tmp = (I32)(s != startpos) ? utf8_to_uv(reghop((U8*)s, -1), 0) : '\n';
-           tmp = ((OP(c) == NBOUNDUTF8 ? isALNUM_uni(tmp) : isALNUM_LC_uni(tmp)) != 0);
+           if (s == startpos)
+               tmp = '\n';
+           else {
+               U8 *r = reghop((U8*)s, -1);
+
+               tmp = (I32)utf8_to_uv(r, s - (char*)r, 0, 0);
+           }
+           tmp = ((OP(c) == NBOUNDUTF8 ?
+                   isALNUM_uni(tmp) : isALNUM_LC_uni(tmp)) != 0);
            while (s < strend) {
                if (tmp == !(OP(c) == NBOUNDUTF8 ?
                             swash_fetch(PL_utf8_alnum, (U8*)s) :
@@ -1699,6 +1716,9 @@ S_regtry(pTHX_ regexp *prog, char *startpos)
     register I32 *ep;
     CHECKPOINT lastcp;
 
+#ifdef DEBUGGING
+    PL_regindent = 0;  /* XXXX Not good when matches are reenterable... */
+#endif
     if ((prog->reganch & ROPT_EVAL_SEEN) && !PL_reg_eval_set) {
        MAGIC *mg;
 
@@ -1770,7 +1790,8 @@ S_regtry(pTHX_ regexp *prog, char *startpos)
 
     /* XXXX What this code is doing here?!!!  There should be no need
        to do this again and again, PL_reglastparen should take care of
-       this!  */
+       this!  --ilya*/
+    /* Tests pat.t#187 and split.t#{13,14} seem to depend on this. --jhi */
     sp = prog->startp;
     ep = prog->endp;
     if (prog->nparens) {
@@ -1779,15 +1800,45 @@ S_regtry(pTHX_ regexp *prog, char *startpos)
            *++ep = -1;
        }
     }
-    REGCP_SET;
+    REGCP_SET(lastcp);
     if (regmatch(prog->program + 1)) {
        prog->endp[0] = PL_reginput - PL_bostr;
        return 1;
     }
-    REGCP_UNWIND;
+    REGCP_UNWIND(lastcp);
     return 0;
 }
 
+#define RE_UNWIND_BRANCH       1
+#define RE_UNWIND_BRANCHJ      2
+
+union re_unwind_t;
+
+typedef struct {               /* XX: makes sense to enlarge it... */
+    I32 type;
+    I32 prev;
+    CHECKPOINT lastcp;
+} re_unwind_generic_t;
+
+typedef struct {
+    I32 type;
+    I32 prev;
+    CHECKPOINT lastcp;
+    I32 lastparen;
+    regnode *next;
+    char *locinput;
+    I32 nextchr;
+#ifdef DEBUGGING
+    int regindent;
+#endif
+} re_unwind_branch_t;
+
+typedef union re_unwind_t {
+    I32 type;
+    re_unwind_generic_t generic;
+    re_unwind_branch_t branch;
+} re_unwind_t;
+
 /*
  - regmatch - main matching routine
  *
@@ -1817,6 +1868,9 @@ S_regmatch(pTHX_ regnode *prog)
     register char *locinput = PL_reginput;
     register I32 c1, c2, paren;        /* case fold search, parenth */
     int minmod = 0, sw = 0, logical = 0;
+    I32 unwind = 0;
+    I32 firstcp = PL_savestack_ix;
+
 #ifdef DEBUGGING
     PL_regindent++;
 #endif
@@ -1826,7 +1880,7 @@ S_regmatch(pTHX_ regnode *prog)
     scan = prog;
     while (scan != NULL) {
 #define sayNO_L (logical ? (logical = 0, sw = 0, goto cont) : sayNO)
-#ifdef DEBUGGING
+#if 1
 #  define sayYES goto yes
 #  define sayNO goto no
 #  define sayYES_FINAL goto yes_final
@@ -1995,9 +2049,10 @@ S_regmatch(pTHX_ regnode *prog)
                while (s < e) {
                    if (l >= PL_regeol)
                        sayNO;
-                   if (utf8_to_uv((U8*)s, 0) != (c1 ?
-                                                 toLOWER_utf8((U8*)l) :
-                                                 toLOWER_LC_utf8((U8*)l)))
+                   if (utf8_to_uv((U8*)s, e - s, 0, 0) !=
+                       (c1 ?
+                        toLOWER_utf8((U8*)l) :
+                        toLOWER_LC_utf8((U8*)l)))
                    {
                        sayNO;
                    }
@@ -2132,8 +2187,13 @@ S_regmatch(pTHX_ regnode *prog)
        case BOUNDUTF8:
        case NBOUNDUTF8:
            /* was last char in word? */
-           ln = (locinput != PL_regbol)
-               ? utf8_to_uv(reghop((U8*)locinput, -1), 0) : PL_regprev;
+           if (locinput == PL_regbol)
+               ln = PL_regprev;
+           else {
+               U8 *r = reghop((U8*)locinput, -1);
+
+               ln = utf8_to_uv(r, s - (char*)r, 0, 0);
+           }
            if (OP(scan) == BOUNDUTF8 || OP(scan) == NBOUNDUTF8) {
                ln = isALNUM_uni(ln);
                n = swash_fetch(PL_utf8_alnum, (U8*)locinput);
@@ -2431,7 +2491,7 @@ S_regmatch(pTHX_ regnode *prog)
                    PL_regcc = 0;
                    
                    cp = regcppush(0);  /* Save *all* the positions. */
-                   REGCP_SET;
+                   REGCP_SET(lastcp);
                    cache_re(re);
                    state.ss = PL_savestack_ix;
                    *PL_reglastparen = 0;
@@ -2461,7 +2521,7 @@ S_regmatch(pTHX_ regnode *prog)
                        sayYES;
                    }
                    ReREFCNT_dec(re);
-                   REGCP_UNWIND;
+                   REGCP_UNWIND(lastcp);
                    regcppop();
                    PL_reg_call_cc = state.prev;
                    PL_regcc = state.cc;
@@ -2588,12 +2648,18 @@ S_regmatch(pTHX_ regnode *prog)
        case CURLYX: {
                CURCUR cc;
                CHECKPOINT cp = PL_savestack_ix;
+               /* No need to save/restore up to this paren */
+               I32 parenfloor = scan->flags;
 
                if (OP(PREVOPER(next)) == NOTHING) /* LONGJMP */
                    next += ARG(next);
                cc.oldcc = PL_regcc;
                PL_regcc = &cc;
-               cc.parenfloor = *PL_reglastparen;
+               /* XXXX Probably it is better to teach regpush to support
+                  parenfloor > PL_regsize... */
+               if (parenfloor > *PL_reglastparen)
+                   parenfloor = *PL_reglastparen; /* Pessimization... */
+               cc.parenfloor = parenfloor;
                cc.cur = -1;
                cc.min = ARG1(scan);
                cc.max  = ARG2(scan);
@@ -2716,12 +2782,12 @@ S_regmatch(pTHX_ regnode *prog)
                    if (PL_regcc)
                        ln = PL_regcc->cur;
                    cp = regcppush(cc->parenfloor);
-                   REGCP_SET;
+                   REGCP_SET(lastcp);
                    if (regmatch(cc->next)) {
                        regcpblow(cp);
                        sayYES; /* All done. */
                    }
-                   REGCP_UNWIND;
+                   REGCP_UNWIND(lastcp);
                    regcppop();
                    if (PL_regcc)
                        PL_regcc->cur = ln;
@@ -2748,12 +2814,12 @@ S_regmatch(pTHX_ regnode *prog)
                    cc->cur = n;
                    cc->lastloc = locinput;
                    cp = regcppush(cc->parenfloor);
-                   REGCP_SET;
+                   REGCP_SET(lastcp);
                    if (regmatch(cc->scan)) {
                        regcpblow(cp);
                        sayYES;
                    }
-                   REGCP_UNWIND;
+                   REGCP_UNWIND(lastcp);
                    regcppop();
                    cc->cur = n - 1;
                    cc->lastloc = lastloc;
@@ -2766,12 +2832,12 @@ S_regmatch(pTHX_ regnode *prog)
                    cp = regcppush(cc->parenfloor);
                    cc->cur = n;
                    cc->lastloc = locinput;
-                   REGCP_SET;
+                   REGCP_SET(lastcp);
                    if (regmatch(cc->scan)) {
                        regcpblow(cp);
                        sayYES;
                    }
-                   REGCP_UNWIND;
+                   REGCP_UNWIND(lastcp);
                    regcppop();         /* Restore some previous $<digit>s? */
                    PL_reginput = locinput;
                    DEBUG_r(
@@ -2817,30 +2883,30 @@ S_regmatch(pTHX_ regnode *prog)
                if (OP(next) != c1)     /* No choice. */
                    next = inner;       /* Avoid recursion. */
                else {
-                   int lastparen = *PL_reglastparen;
+                   I32 lastparen = *PL_reglastparen;
+                   I32 unwind1;
+                   re_unwind_branch_t *uw;
+
+                   /* Put unwinding data on stack */
+                   unwind1 = SSNEWt(1,re_unwind_branch_t);
+                   uw = SSPTRt(unwind1,re_unwind_branch_t);
+                   uw->prev = unwind;
+                   unwind = unwind1;
+                   uw->type = ((c1 == BRANCH)
+                               ? RE_UNWIND_BRANCH
+                               : RE_UNWIND_BRANCHJ);
+                   uw->lastparen = lastparen;
+                   uw->next = next;
+                   uw->locinput = locinput;
+                   uw->nextchr = nextchr;
+#ifdef DEBUGGING
+                   uw->regindent = ++PL_regindent;
+#endif
 
-                   REGCP_SET;
-                   do {
-                       PL_reginput = locinput;
-                       if (regmatch(inner))
-                           sayYES;
-                       REGCP_UNWIND;
-                       for (n = *PL_reglastparen; n > lastparen; n--)
-                           PL_regendp[n] = -1;
-                       *PL_reglastparen = n;
-                       scan = next;
-                       /*SUPPRESS 560*/
-                       if ((n = (c1 == BRANCH ? NEXT_OFF(next) : ARG(next))))
-                           next += n;
-                       else
-                           next = NULL;
-                       inner = NEXTOPER(scan);
-                       if (c1 == BRANCHJ) {
-                           inner = NEXTOPER(inner);
-                       }
-                   } while (scan != NULL && OP(scan) == c1);
-                   sayNO;
-                   /* NOTREACHED */
+                   REGCP_SET(uw->lastcp);
+
+                   /* Now go into the first branch */
+                   next = inner;
                }
            }
            break;
@@ -2890,7 +2956,7 @@ S_regmatch(pTHX_ regnode *prog)
                }
                else
                    c1 = c2 = -1000;
-               REGCP_SET;
+               REGCP_SET(lastcp);
                /* This may be improved if l == 0.  */
                while (n >= ln || (n == REG_INFTY && ln > 0 && l)) { /* ln overflow ? */
                    /* If it could work, try it. */
@@ -2909,7 +2975,7 @@ S_regmatch(pTHX_ regnode *prog)
                        }
                        if (regmatch(next))
                            sayYES;
-                       REGCP_UNWIND;
+                       REGCP_UNWIND(lastcp);
                    }
                    /* Couldn't or didn't -- move forward. */
                    PL_reginput = locinput;
@@ -2949,7 +3015,7 @@ S_regmatch(pTHX_ regnode *prog)
                    else
                        c1 = c2 = -1000;
                }
-               REGCP_SET;
+               REGCP_SET(lastcp);
                while (n >= ln) {
                    /* If it could work, try it. */
                    if (c1 == -1000 ||
@@ -2971,7 +3037,7 @@ S_regmatch(pTHX_ regnode *prog)
                        }
                        if (regmatch(next))
                            sayYES;
-                       REGCP_UNWIND;
+                       REGCP_UNWIND(lastcp);
                    }
                    /* Couldn't or didn't -- back up. */
                    n--;
@@ -3032,7 +3098,7 @@ S_regmatch(pTHX_ regnode *prog)
                if (ln && regrepeat(scan, ln) < ln)
                    sayNO;
                locinput = PL_reginput;
-               REGCP_SET;
+               REGCP_SET(lastcp);
                if (c1 != -1000) {
                    char *e = locinput + n - ln; /* Should not check after this */
                    char *old = locinput;
@@ -3062,7 +3128,7 @@ S_regmatch(pTHX_ regnode *prog)
                        /* PL_reginput == locinput now */
                        TRYPAREN(paren, ln, locinput);
                        PL_reginput = locinput; /* Could be reset... */
-                       REGCP_UNWIND;
+                       REGCP_UNWIND(lastcp);
                        /* Couldn't or didn't -- move forward. */
                        old = locinput++;
                    }
@@ -3075,7 +3141,7 @@ S_regmatch(pTHX_ regnode *prog)
                        UCHARAT(PL_reginput) == c2)
                    {
                        TRYPAREN(paren, n, PL_reginput);
-                       REGCP_UNWIND;
+                       REGCP_UNWIND(lastcp);
                    }
                    /* Couldn't or didn't -- move forward. */
                    PL_reginput = locinput;
@@ -3100,7 +3166,7 @@ S_regmatch(pTHX_ regnode *prog)
                    if (UCHARAT(PL_reginput - 1) == '\n' && OP(next) != EOS)
                        ln--;
                }
-               REGCP_SET;
+               REGCP_SET(lastcp);
                if (paren) {
                    while (n >= ln) {
                        /* If it could work, try it. */
@@ -3109,7 +3175,7 @@ S_regmatch(pTHX_ regnode *prog)
                            UCHARAT(PL_reginput) == c2)
                            {
                                TRYPAREN(paren, n, PL_reginput);
-                               REGCP_UNWIND;
+                               REGCP_UNWIND(lastcp);
                            }
                        /* Couldn't or didn't -- back up. */
                        n--;
@@ -3124,7 +3190,7 @@ S_regmatch(pTHX_ regnode *prog)
                            UCHARAT(PL_reginput) == c2)
                            {
                                TRYPAREN(paren, n, PL_reginput);
-                               REGCP_UNWIND;
+                               REGCP_UNWIND(lastcp);
                            }
                        /* Couldn't or didn't -- back up. */
                        n--;
@@ -3142,7 +3208,7 @@ S_regmatch(pTHX_ regnode *prog)
                CHECKPOINT cp, lastcp;
                
                cp = regcppush(0);      /* Save *all* the positions. */
-               REGCP_SET;
+               REGCP_SET(lastcp);
                regcp_set_to(PL_reg_call_cc->ss); /* Restore parens of
                                                    the caller. */
                PL_reginput = locinput; /* Make position available to
@@ -3155,7 +3221,7 @@ S_regmatch(pTHX_ regnode *prog)
                    regcpblow(cp);
                    sayYES;
                }
-               REGCP_UNWIND;
+               REGCP_UNWIND(lastcp);
                regcppop();
                PL_reg_call_cc = cur_call_cc;
                PL_regcc = cctmp;
@@ -3262,6 +3328,7 @@ S_regmatch(pTHX_ regnode *prog)
                          PTR2UV(scan), OP(scan));
            Perl_croak(aTHX_ "regexp memory corruption");
        }
+      reenter:
        scan = next;
     }
 
@@ -3287,6 +3354,11 @@ yes:
 #ifdef DEBUGGING
     PL_regindent--;
 #endif
+
+#if 0                                  /* Breaks $^R */
+    if (unwind)
+       regcpblow(firstcp);
+#endif
     return 1;
 
 no:
@@ -3298,6 +3370,55 @@ no:
     goto do_no;
 no_final:
 do_no:
+    if (unwind) {
+       re_unwind_t *uw = SSPTRt(unwind,re_unwind_t);
+
+       switch (uw->type) {
+       case RE_UNWIND_BRANCH:
+       case RE_UNWIND_BRANCHJ:
+       {
+           re_unwind_branch_t *uwb = &(uw->branch);
+           I32 lastparen = uwb->lastparen;
+           
+           REGCP_UNWIND(uwb->lastcp);
+           for (n = *PL_reglastparen; n > lastparen; n--)
+               PL_regendp[n] = -1;
+           *PL_reglastparen = n;
+           scan = next = uwb->next;
+           if ( !scan || 
+                OP(scan) != (uwb->type == RE_UNWIND_BRANCH 
+                             ? BRANCH : BRANCHJ) ) {           /* Failure */
+               unwind = uwb->prev;
+#ifdef DEBUGGING
+               PL_regindent--;
+#endif
+               goto do_no;
+           }
+           /* Have more choice yet.  Reuse the same uwb.  */
+           /*SUPPRESS 560*/
+           if ((n = (uwb->type == RE_UNWIND_BRANCH
+                     ? NEXT_OFF(next) : ARG(next))))
+               next += n;
+           else
+               next = NULL;    /* XXXX Needn't unwinding in this case... */
+           uwb->next = next;
+           next = NEXTOPER(scan);
+           if (uwb->type == RE_UNWIND_BRANCHJ)
+               next = NEXTOPER(next);
+           locinput = uwb->locinput;
+           nextchr = uwb->nextchr;
+#ifdef DEBUGGING
+           PL_regindent = uwb->regindent;
+#endif
+
+           goto reenter;
+       }
+       /* NOT REACHED */
+       default:
+           Perl_croak(aTHX_ "regexp unwind memory corruption");
+       }
+       /* NOT REACHED */
+    }
 #ifdef DEBUGGING
     PL_regindent--;
 #endif
@@ -3625,7 +3746,11 @@ S_reginclass(pTHX_ register regnode *p, register I32 c)
            (ANYOF_CLASS_TEST(p, ANYOF_UPPER)   &&  isUPPER_LC(c))  ||
            (ANYOF_CLASS_TEST(p, ANYOF_NUPPER)  && !isUPPER_LC(c))  ||
            (ANYOF_CLASS_TEST(p, ANYOF_XDIGIT)  &&  isXDIGIT(c))    ||
-           (ANYOF_CLASS_TEST(p, ANYOF_NXDIGIT) && !isXDIGIT(c))
+           (ANYOF_CLASS_TEST(p, ANYOF_NXDIGIT) && !isXDIGIT(c))    ||
+           (ANYOF_CLASS_TEST(p, ANYOF_PSXSPC)  &&  isPSXSPC(c))    ||
+           (ANYOF_CLASS_TEST(p, ANYOF_NPSXSPC) && !isPSXSPC(c))    ||
+           (ANYOF_CLASS_TEST(p, ANYOF_BLANK)   &&  isBLANK(c))    ||
+           (ANYOF_CLASS_TEST(p, ANYOF_NBLANK)  && !isBLANK(c))
            ) /* How's that for a conditional? */
        {
            match = TRUE;
@@ -3731,4 +3856,3 @@ restore_pos(pTHXo_ void *arg)
        PL_curpm = PL_reg_oldcurpm;
     }  
 }
-