regcomp.c, S_compile_runtime_code: croak using the SVf format
authorBrian Fraser <fraserbn@gmail.com>
Thu, 29 Aug 2013 14:36:12 +0000 (11:36 -0300)
committerFather Chrysostomos <sprout@cpan.org>
Tue, 10 Sep 2013 15:36:12 +0000 (08:36 -0700)
This makes error messages from code like this:

    $f = "(?{q\0foo\0 + \x{FFFF}})";
    "a" =~ /^a$f/;

Be both UTF-8 and nul clean.

regcomp.c
t/re/pat_re_eval.t
t/uni/parser.t

index 931f8fb..1dde851 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -5353,7 +5353,7 @@ S_compile_runtime_code(pTHX_ RExC_state_t * const pRExC_state,
            {
                Safefree(pRExC_state->code_blocks);
                 /* use croak_sv ? */
-               Perl_croak_nocontext("%s", SvPV_nolen_const(errsv));
+               Perl_croak_nocontext("%"SVf, SVfARG(errsv));
            }
        }
        assert(SvROK(qr_ref));
index e47aaf3..14d681a 100644 (file)
@@ -23,7 +23,7 @@ BEGIN {
 }
 
 
-plan tests => 519;  # Update this when adding/deleting tests.
+plan tests => 520;  # Update this when adding/deleting tests.
 
 run_tests() unless caller;
 
@@ -931,6 +931,11 @@ sub run_tests {
        like($@,
            qr/BEGIN failed--compilation aborted at \(eval \d+\) line \d+/,
            'syntax error');
+        
+        use utf8;
+        $code = '(?{Foo::$bar})';
+        eval { "a" =~ /^a$code/ };
+        like($@, qr/Bad name after Foo:: at \(eval \d+\) line \d+/, 'UTF8 sytax error');
     }
 
     # make sure that 'use re eval' is propagated into compiling the
index dcb96f2..b71ca88 100644 (file)
@@ -117,9 +117,7 @@ is ${"main::\345\225\217"}, undef, "..and using the encoded form doesn't";
        "...and nul-clean"
     );
 
-    TODO: {
-        local $::TODO = "Unrecognized character thrown from a re-eval not UTF8/nul clean yet";
-        
+    {
         use re 'eval';
         my $f = qq{(?{\$ネ+ 1; \x{1F42A} })};
         eval { "a" =~ /^a$f/ };