Move the longjmp() that implements REQUIRE_UTF8 up to Perl_re_op_compile().
authorNicholas Clark <nick@ccl4.org>
Sat, 19 Jan 2013 10:06:10 +0000 (11:06 +0100)
committerNicholas Clark <nick@ccl4.org>
Tue, 19 Mar 2013 10:53:19 +0000 (11:53 +0100)
With longjmp() and setjmp() now in the same function (and all tests passing),
it becomes easy to replace the pair with a goto. Still evil, but "the lesser
of two evils".

regcomp.c

index fe225e0..190eb2e 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -255,7 +255,6 @@ typedef struct RExC_state_t {
 /* If not already in utf8, do a longjmp back to the beginning */
 #define UTF8_LONGJMP 42 /* Choose a value not likely to ever conflict */
 #define REQUIRE_UTF8   STMT_START {                                       \
-                                     if (! UTF) JMPENV_JUMP(UTF8_LONGJMP); \
                                      if (!UTF) {                           \
                                          *flagp = RESTART_UTF8;            \
                                          return NULL;                      \
@@ -5774,6 +5773,8 @@ Perl_re_op_compile(pTHX_ SV ** const patternp, int pat_count,
        SvLEN_set(code_blocksv, 1); /*sufficient to make sv_clear free it*/
     }
     if (reg(pRExC_state, 0, &flags,1) == NULL) {
+        if (flags & RESTART_UTF8)
+            JMPENV_JUMP(UTF8_LONGJMP);
         Perl_croak(aTHX_ "panic: reg returned NULL to re_op_compile for sizing pass, flags=%#X", flags);
     }
     if (code_blocksv)