regcomp.c: Better DEBUGGING builds error detection
authorKarl Williamson <public@khwilliamson.com>
Thu, 15 Aug 2013 20:55:16 +0000 (14:55 -0600)
committerKarl Williamson <public@khwilliamson.com>
Tue, 24 Sep 2013 17:36:17 +0000 (11:36 -0600)
The code had a default: catch-all in the switch statement, but the
comments indicated that it was uncertain what all was being caught.
This changes this to panic only in DEBUGGING builds so that we can find
out if there are indeed other possibilities that we haven't handled, and
which could use better handling than the default, match everything.
The two known possibilities are given separate case: statements in
preparation for handling them differently.

regcomp.c

index 2fbc1b4..dfd1cff 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -4159,7 +4159,14 @@ PerlIO_printf(Perl_debug_log, "LHS=%"UVdf" RHS=%"UVdf"\n",
                        NEXT_OFF(oscan) += NEXT_OFF(next);
                }
                continue;
-           default:                    /* REF, and CLUMP only? */
+
+           default:
+#ifdef DEBUGGING
+                Perl_croak(aTHX_ "panic: unexpected varying REx opcode %d",
+                                                                    OP(scan));
+#endif
+            case REF:
+            case CLUMP:
                if (flags & SCF_DO_SUBSTR) {
                    SCAN_COMMIT(pRExC_state,data,minlenp);      /* Cannot expect anything... */
                    data->longest = &(data->longest_float);