summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-10-01 06:30:35 -0700
committerFather Chrysostomos <sprout@cpan.org>2011-10-01 06:33:49 -0700
commitba6ff154b0d807025f5294b2c3e9623fd60a6e97 (patch)
tree93f8ddbbe96480fc1a61caaa2b9599d59319d7a6
parentd78f9ffa7317e24a5eaf54a2cf107e6663784159 (diff)
downloadperl-ba6ff154b0d807025f5294b2c3e9623fd60a6e97.tar.gz
[perl #99984] Incorrect errmsg with our $::é
Having PL_parser->error_count set to non-zero when utf8_heavy.pl tries to do() one of its swashes results in ‘Compilation error’ being placed in $@ during the do, even if it was successful. This patch sets the error_count to 0 before calling SWASHNEW, to prevent that. It uses SAVEI8, to make sure it is restored on scope exit.
-rw-r--r--t/uni/lex_utf8.t9
-rw-r--r--utf8.c2
2 files changed, 10 insertions, 1 deletions
diff --git a/t/uni/lex_utf8.t b/t/uni/lex_utf8.t
index e080245d6e..368185f130 100644
--- a/t/uni/lex_utf8.t
+++ b/t/uni/lex_utf8.t
@@ -12,7 +12,7 @@ BEGIN {
use strict;
-plan (tests => 10);
+plan (tests => 11);
use charnames ':full';
use utf8;
@@ -40,6 +40,13 @@ do {
is((join "", unpack("C*", $uname_last)), "98" . "198" . "129" . "194" . "181", 'b . char above 0x100 . \N{U+00B5}');
is((join "", unpack("C*", $octal_first)), "99" . "195" . "191" . "196" . "134", 'c . \377 . char above 0x100');
is((join "", unpack("C*", $octal_last)), "99" . "196" . "134" . "195" . "191", 'c . char above 0x100 . \377');
+};
+
+{
+ local $SIG{__WARN__} = sub {};
+ eval "our $::\xe9; $\xe9";
+ unlike $@, qr/utf8_heavy/,
+ 'No utf8_heavy errors with our() syntax errors';
}
__END__
diff --git a/utf8.c b/utf8.c
index 4bab3a9b84..003e3fcadd 100644
--- a/utf8.c
+++ b/utf8.c
@@ -2050,6 +2050,8 @@ Perl_swash_init(pTHX_ const char* pkg, const char* name, SV *listsv, I32 minbits
ENTER;
SAVEHINTS();
save_re_context();
+ if (PL_parser && PL_parser->error_count)
+ SAVEI8(PL_parser->error_count), PL_parser->error_count = 0;
method = gv_fetchmeth(stash, "SWASHNEW", 8, -1);
if (!method) { /* demand load utf8 */
ENTER;