summaryrefslogtreecommitdiff
path: root/regexec.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2016-12-09 08:45:18 -0700
committerKarl Williamson <khw@cpan.org>2016-12-23 13:21:31 -0700
commit75219bacf5aacd315b96083de24e82cd8238e99a (patch)
treeeb54b94b3883c3515439fdc29d98eb70d3e6257f /regexec.c
parent9cbfb8abb5bb7ce49134acc57b93eb9ae475e339 (diff)
downloadperl-75219bacf5aacd315b96083de24e82cd8238e99a.tar.gz
Use fnc to force out malformed warnings
The previous commit added a function to do this task. This current commit changes the several places in the core that have here-to-fore done this in an ad-hoc (and not as reliable) manner to use the new function. A couple of messages in toke.c are left in so as to avoid changing diagnostics unnecessarily. If those messages had been created in the project after the enhanced malformation warnings were created, they would have been phrased differently. The reason some of the methods weren't so reliable, is they relied on fatalizing the warnng message. However if warnings are turned off, it never gets to the point of outputting, hence doesn't necessarily die.
Diffstat (limited to 'regexec.c')
-rw-r--r--regexec.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/regexec.c b/regexec.c
index f6f293d56e..e9c74e6ea2 100644
--- a/regexec.c
+++ b/regexec.c
@@ -9225,10 +9225,14 @@ S_reginclass(pTHX_ regexp * const prog, const regnode * const n, const U8* const
* UTF8_IS_INVARIANT() works even if not in UTF-8 */
if (! UTF8_IS_INVARIANT(c) && utf8_target) {
STRLEN c_len = 0;
- c = utf8n_to_uvchr(p, p_end - p, &c_len, ( UTF8_ALLOW_DEFAULT
- | UTF8_CHECK_ONLY));
- if (c_len == (STRLEN)-1)
- Perl_croak(aTHX_ "Malformed UTF-8 character (fatal)");
+ const U32 utf8n_flags = UTF8_ALLOW_DEFAULT;
+ c = utf8n_to_uvchr(p, p_end - p, &c_len, utf8n_flags | UTF8_CHECK_ONLY);
+ if (c_len == (STRLEN)-1) {
+ _force_out_malformed_utf8_message(p, p_end,
+ utf8n_flags,
+ 1 /* 1 means die */ );
+ NOT_REACHED; /* NOTREACHED */
+ }
if (c > 255 && OP(n) == ANYOFL && ! ANYOFL_UTF8_LOCALE_REQD(flags)) {
_CHECK_AND_OUTPUT_WIDE_LOCALE_CP_MSG(c);
}