The core of this function is a large switch() statement. Prior to this
commit, the default: case of it assumed that this meant that the
node-type was a zero-length node. It is safer to explicitly mention
all the cases you expect to handle, and have the default fail so that
you know sooner that you forgot to handle a situation. That is how all
other switch statements in this file are set up, and now this one is
too.
I added cases for all the node types in regcomp.c that are SIMPLE, and
hence could conceivably be handled by regrepeat(), and changed the
default: case to croak.
I considered doing an #ifdef DEBUGGING around this, but no other
switches() in the file do so, so I followed that paradigm.
}
break;
- default: /* Called on something of 0 width. */
- break; /* So match right here or not at all. */
+ case BOUND:
+ case BOUNDA:
+ case BOUNDL:
+ case BOUNDU:
+ case EOS:
+ case GPOS:
+ case KEEPS:
+ case NBOUND:
+ case NBOUNDA:
+ case NBOUNDL:
+ case NBOUNDU:
+ case OPFAIL:
+ case SBOL:
+ case SEOL:
+ /* These are all 0 width, so match right here or not at all. */
+ break;
+
+ default:
+ Perl_croak(aTHX_ "panic: regrepeat() called with unrecognized node type %d='%s'", OP(p), PL_reg_name[OP(p)]);
+ assert(0); /* NOTREACHED */
+
}
if (hardcount)