UTF8fARG(UTF, offset, RExC_precomp), \
UTF8fARG(UTF, RExC_end - RExC_precomp - offset, RExC_precomp + offset)
+/* Used to point after bad bytes for an error message, but avoid skipping
+ * past a nul byte. */
+#define SKIP_IF_CHAR(s) (!*(s) ? 0 : UTF ? UTF8SKIP(s) : 1)
+
/*
* Calls SAVEDESTRUCTOR_X if needed, then calls Perl_croak with the given
* arg. Show regex, up to a maximum length. If it's too long, chop and add
/*NOTREACHED*/
default:
fail_modifiers:
- RExC_parse += UTF ? UTF8SKIP(RExC_parse) : 1;
+ RExC_parse += SKIP_IF_CHAR(RExC_parse);
/* diag_listed_as: Sequence (?%s...) not recognized in regex; marked by <-- HERE in m/%s/ */
vFAIL2utf8f("Sequence (%"UTF8f"...) not recognized",
UTF8fARG(UTF, RExC_parse-seqstart, seqstart));
nextchar(pRExC_state);
return ret;
}
- RExC_parse++;
+ --RExC_parse;
+ RExC_parse += SKIP_IF_CHAR(RExC_parse);
/* diag_listed_as: Sequence (?%s...) not recognized in regex; marked by <-- HERE in m/%s/ */
vFAIL3("Sequence (%.*s...) not recognized",
RExC_parse-seqstart, seqstart);
case '?': /* (??...) */
is_logical = 1;
if (*RExC_parse != '{') {
- RExC_parse++;
+ RExC_parse += SKIP_IF_CHAR(RExC_parse);
/* diag_listed_as: Sequence (?%s...) not recognized in regex; marked by <-- HERE in m/%s/ */
vFAIL2utf8f(
"Sequence (%"UTF8f"...) not recognized",
skip_all_without_unicode_tables();
}
-plan tests => 759; # Update this when adding/deleting tests.
+plan tests => 765; # Update this when adding/deleting tests.
run_tests() unless caller;
ok(1, "did not crash");
ok($match, "[bbb...] resolved as character class, not subscript");
}
+
+ { # [perl #123755]
+ for my $pat ('(??', '(?P', '(?i-') {
+ eval qq{ qr/$pat/ };
+ ok(1, "qr/$pat/ did not crash");
+ eval qq{ qr/${pat}\x{123}/ };
+ my $e = $@;
+ like($e, qr{\x{123}},
+ "qr/${pat}x/ shows x in error even if it's a wide character");
+ }
+ }
} # End of sub run_tests
1;
(?P<n>foo)(??{ $+{n} }) snofooefoofoowaa yM $+{n} foo miniperl cannot load Tie::Hash::NamedCapture
(?P<=n>foo|bar|baz) - c - Group name must start with a non-digit word character
(?P<!n>foo|bar|baz) - c - Group name must start with a non-digit word character
-(?PX<n>foo|bar|baz) - c - Sequence (?PX<...) not recognized
+(?PX<n>foo|bar|baz) - c - Sequence (?PX...) not recognized
/(?'n'foo|bar|baz)/ snofooewa y $1 foo
/(?'n'foo|bar|baz)/ snofooewa yM $+{n} foo miniperl cannot load Tie::Hash::NamedCapture
/(?'n'foo|bar|baz)(?'m'[ew]+)/ snofooewa yM $+{n} foo miniperl cannot load Tie::Hash::NamedCapture