From a15a3d9b600adf7d9dd78193d608361f302b0370 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Sat, 21 May 2016 12:22:33 -0700 Subject: [PATCH] Disable ${^ENCODING} ${^ENCODING} is disabled and tests are modified to account. --- cpan/Encode/t/enc_data.t | 4 ++++ cpan/Encode/t/enc_module.t | 4 ++++ cpan/Encode/t/encoding.t | 4 ++++ cpan/Encode/t/jperl.t | 4 ++++ gv.c | 3 --- mg.c | 36 ++---------------------------------- pod/perldiag.pod | 5 +++++ t/lib/warnings/gv | 10 ++++++++++ t/lib/warnings/mg | 4 ++-- t/op/concat2.t | 2 +- t/op/magic.t | 13 ++++++++----- t/uni/chomp.t | 46 +++++++++++----------------------------------- t/uni/greek.t | 4 +--- t/uni/latin2.t | 4 +--- t/uni/tr_7jis.t | 4 +--- t/uni/tr_sjis.t | 4 +--- t/uni/tr_utf8.t | 6 +----- 17 files changed, 60 insertions(+), 97 deletions(-) diff --git a/cpan/Encode/t/enc_data.t b/cpan/Encode/t/enc_data.t index a0caf65..b401595 100644 --- a/cpan/Encode/t/enc_data.t +++ b/cpan/Encode/t/enc_data.t @@ -14,6 +14,10 @@ BEGIN { print "1..0 # encoding pragma does not support EBCDIC platforms\n"; exit(0); } + if ("$]" >= 5.025) { + print "1..0 # encoding pragma not supported in Perl 5.26\n"; + exit(0); + } if ($] <= 5.008 and !$Config{perl_patchlevel}){ print "1..0 # Skip: Perl 5.8.1 or later required\n"; exit 0; diff --git a/cpan/Encode/t/enc_module.t b/cpan/Encode/t/enc_module.t index 05fc6c2..3004ed2 100644 --- a/cpan/Encode/t/enc_module.t +++ b/cpan/Encode/t/enc_module.t @@ -18,6 +18,10 @@ BEGIN { print "1..0 # encoding pragma does not support EBCDIC platforms\n"; exit(0); } + if ("$]" >= 5.025) { + print "1..0 # encoding pragma not supported in Perl 5.26\n"; + exit(0); + } } use lib qw(t ext/Encode/t ../ext/Encode/t); # latter 2 for perl core use Mod_EUCJP; diff --git a/cpan/Encode/t/encoding.t b/cpan/Encode/t/encoding.t index 21f9e47..18d1921 100644 --- a/cpan/Encode/t/encoding.t +++ b/cpan/Encode/t/encoding.t @@ -12,6 +12,10 @@ BEGIN { print "1..0 # encoding pragma does not support EBCDIC platforms\n"; exit(0); } + if ("$]" >= 5.025) { + print "1..0 # encoding pragma not supported in Perl 5.26\n"; + exit(0); + } } print "1..33\n"; diff --git a/cpan/Encode/t/jperl.t b/cpan/Encode/t/jperl.t index 3abe86b..5f437ff 100644 --- a/cpan/Encode/t/jperl.t +++ b/cpan/Encode/t/jperl.t @@ -17,6 +17,10 @@ BEGIN { print "1..0 # Skip: EBCDIC\n"; exit 0; } + if ("$]" >= 5.025) { + print "1..0 # encoding pragma not supported in Perl 5.26\n"; + exit(0); + } $| = 1; } diff --git a/gv.c b/gv.c index dff611e..4d5a071 100644 --- a/gv.c +++ b/gv.c @@ -1921,9 +1921,6 @@ S_gv_magicalize(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, goto magicalize; break; case '\005': /* $^ENCODING */ - if (*name2 == '_') { - name2++; - } if (strEQ(name2, "NCODING")) goto magicalize; break; diff --git a/mg.c b/mg.c index 4321a40..a89916d 100644 --- a/mg.c +++ b/mg.c @@ -856,8 +856,6 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg) case '\005': /* ^E */ if (nextchar != '\0') { if (strEQ(remaining, "NCODING")) - sv_setsv(sv, _get_encoding()); - else if (strEQ(remaining, "_NCODING")) sv_setsv(sv, NULL); break; } @@ -2733,41 +2731,11 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) #endif } else { - unsigned int offset = 1; - bool lex = FALSE; - - /* It may be the shadow variable ${E_NCODING} which has lexical - * scope. See comments at Perl__get_encoding in this file */ - if (*(mg->mg_ptr + 1) == '_') { - if (CopSTASH(PL_curcop) != get_hv("encoding::",0)) - Perl_croak_no_modify(); - lex = TRUE; - offset++; - } - if (strEQ(mg->mg_ptr + offset, "NCODING")) { - if (lex) { /* Use the shadow global */ - SvREFCNT_dec(PL_lex_encoding); - if (SvOK(sv) || SvGMAGICAL(sv)) { - PL_lex_encoding = newSVsv(sv); - } - else { - PL_lex_encoding = NULL; - } - } - else { /* Use the regular global */ - SvREFCNT_dec(PL_encoding); - if (SvOK(sv) || SvGMAGICAL(sv)) { + if (strEQ(mg->mg_ptr + 1, "NCODING") && SvOK(sv)) if (PL_localizing != 2) { Perl_ck_warner_d(aTHX_ packWARN(WARN_DEPRECATED), - "Setting ${^ENCODING} is deprecated"); + "${^ENCODING} is no longer supported"); } - PL_encoding = newSVsv(sv); - } - else { - PL_encoding = NULL; - } - } - } } break; case '\006': /* ^F */ diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 4164baf..fb502bb 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -2086,6 +2086,11 @@ unlikely to be what you want. described in L and L. You used C<\p> or C<\P> in a regular expression without specifying the property name. +=item ${^ENCODING} is no longer supported + +(D deprecated) The special variable C<${^ENCODING}>, formerly used to implement +the C pragma, is no longer supported as of Perl 5.26.0. + =item entering effective %s failed (F) While under the C pragma, switching the real and diff --git a/t/lib/warnings/gv b/t/lib/warnings/gv index f3334456..85e4c0a 100644 --- a/t/lib/warnings/gv +++ b/t/lib/warnings/gv @@ -14,6 +14,8 @@ $a = ${"#"} ; $a = ${"*"} ; + ${^ENCODING} is no longer supported. + Name "main::a" used only once: possible typo Mandatory Warnings ALL TODO @@ -115,6 +117,14 @@ $# is no longer supported at - line 2. $* is no longer supported at - line 3. ######## # gv.c +$a = ${^ENCODING}; +$a = ${^E_NCODING}; +${^ENCODING} = 1; +${^E_NCODING} = 1; # We pretend this variable never existed. +EXPECT +${^ENCODING} is no longer supported at - line 4. +######## +# gv.c use warnings 'syntax' ; use utf8; use open qw( :utf8 :std ); diff --git a/t/lib/warnings/mg b/t/lib/warnings/mg index 6bd6c3a..5fe2a88 100644 --- a/t/lib/warnings/mg +++ b/t/lib/warnings/mg @@ -110,5 +110,5 @@ ${^ENCODING} = 42; ${^ENCODING} = undef; { local ${^ENCODING} = 37; } EXPECT -Setting ${^ENCODING} is deprecated at - line 1. -Setting ${^ENCODING} is deprecated at - line 4. +${^ENCODING} is no longer supported at - line 1. +${^ENCODING} is no longer supported at - line 4. diff --git a/t/op/concat2.t b/t/op/concat2.t index b1f707d..955bc22 100644 --- a/t/op/concat2.t +++ b/t/op/concat2.t @@ -18,7 +18,7 @@ SKIP: { skip("no encoding pragma in EBCDIC", 1) if $::IS_EBCDIC; skip_if_miniperl("no dynamic loading on miniperl, no Encode", 1); fresh_perl_is <<'end', "ok\n", {}, - no warnings 'deprecated'; + BEGIN { $SIG{__WARN__} = sub{} }; use encoding 'utf8'; map { "a" . $a } ((1)x5000); print "ok\n"; diff --git a/t/op/magic.t b/t/op/magic.t index da7532e..ad90749 100644 --- a/t/op/magic.t +++ b/t/op/magic.t @@ -675,11 +675,14 @@ is ${^MPEN}, undef, '${^MPEN} starts undefined'; # This one used to croak due to that missing break: is ++${^MPEN}, 1, '${^MPEN} can be incremented'; -eval { ${^E_NCODING} = 1 }; -like $@, qr/^Modification of a /, 'Setting ${^E_NCODING} croaks'; -$_ = ${^E_NCODING}; -pass('can read ${^E_NCODING} without blowing up'); -is $_, undef, '${^E_NCODING} is undef'; +{ + no warnings 'deprecated'; + eval { ${^E_NCODING} = 1 }; + is $@, "", 'Setting ${^E_NCODING} does nothing'; + $_ = ${^E_NCODING}; + pass('can read ${^E_NCODING} without blowing up'); + is $_, 1, '${^E_NCODING} is whatever it was set to'; +} { my $warned = 0; diff --git a/t/uni/chomp.t b/t/uni/chomp.t index ea86a25..35060ee 100644 --- a/t/uni/chomp.t +++ b/t/uni/chomp.t @@ -3,43 +3,19 @@ BEGIN { chdir 't' if -d 't'; require './test.pl'; - skip_all_without_dynamic_extension('Encode'); - skip_all("encoding doesn't work with EBCDIC") if $::IS_EBCDIC; skip_all_without_perlio(); } use strict; -use Encode; -# %mbchars = (encoding => { bytes => utf8, ... }, ...); -# * pack('C*') is expected to return bytes even if ${^ENCODING} is true. -our %mbchars = ( - 'big-5' => { - pack('C*', 0x40) => pack('U*', 0x40), # COMMERCIAL AT - pack('C*', 0xA4, 0x40) => "\x{4E00}", # CJK-4E00 - }, - 'euc-jp' => { - pack('C*', 0xB0, 0xA1) => "\x{4E9C}", # CJK-4E9C - pack('C*', 0x8F, 0xB0, 0xA1) => "\x{4E02}", # CJK-4E02 - }, - 'shift-jis' => { - pack('C*', 0xA9) => "\x{FF69}", # halfwidth katakana small U - pack('C*', 0x82, 0xA9) => "\x{304B}", # hiragana KA - }, -); - -# 4 == @char; paired tests inside 3 nested loops, +# 6 == @char; paired tests inside 3 nested loops, # plus extra pair of tests in a loop, plus extra pair of tests. -plan tests => 2 * (4 ** 3 + 4 + 1) * (keys %mbchars); +plan tests => 6 ** 3 * 2 + 6 * 2 + 2; -for my $enc (sort keys %mbchars) { - no warnings 'deprecated'; - local ${^ENCODING} = find_encoding($enc); - use warnings 'deprecated'; - my @char = (sort(keys %{ $mbchars{$enc} }), - sort(values %{ $mbchars{$enc} })); +my @char = (pack('U*', 0x40), "\x{4E00}", "\x{4E9C}", "\x{4E02}", + "\x{FF69}", "\x{304B}"); - for my $rs (@char) { +for my $rs (@char) { local $/ = $rs; for my $start (@char) { for my $end (@char) { @@ -64,10 +40,10 @@ for my $enc (sort keys %mbchars) { my $got = chomp(); is ($got, 0); is (ref($_), "ARRAY", "chomp ref (no modify)"); - } - - $/ = ")"; # the last char of something like "ARRAY(0x80ff6e4)" - my $got = chomp(); - is ($got, 1); - ok (!ref($_), "chomp ref (modify)"); } + +$/ = ")"; # the last char of something like "ARRAY(0x80ff6e4)" +my $got = chomp(); +is ($got, 1); +ok (!ref($_), "chomp ref (modify)"); + diff --git a/t/uni/greek.t b/t/uni/greek.t index 7d73ecb..fdc2a18 100644 --- a/t/uni/greek.t +++ b/t/uni/greek.t @@ -3,9 +3,7 @@ BEGIN { chdir 't' if -d 't'; require './test.pl'; - skip_all_without_dynamic_extension('Encode'); - skip_all("no encoding pragma in EBCDIC") if $::IS_EBCDIC; - skip_all_without_perlio(); + skip_all("encoding.pm is no longer supported by the perl core"); } plan tests => 72; diff --git a/t/uni/latin2.t b/t/uni/latin2.t index ba67e09..2e51598 100644 --- a/t/uni/latin2.t +++ b/t/uni/latin2.t @@ -3,9 +3,7 @@ BEGIN { chdir 't' if -d 't'; require './test.pl'; - skip_all_without_dynamic_extension('Encode'); - skip_all("no encoding pragma in EBCDIC") if $::IS_EBCDIC; - skip_all_without_perlio(); + skip_all("encoding.pm is no longer supported by the perl core"); } plan tests => 94; diff --git a/t/uni/tr_7jis.t b/t/uni/tr_7jis.t index d1735f9..fc527b8 100644 --- a/t/uni/tr_7jis.t +++ b/t/uni/tr_7jis.t @@ -7,9 +7,7 @@ BEGIN { chdir 't' if -d 't'; require './test.pl'; - skip_all_without_dynamic_extension('Encode'); - skip_all("no encoding pragma in EBCDIC") if $::IS_EBCDIC; - skip_all_without_perlio(); + skip_all("encoding.pm is no longer supported by the perl core"); } use strict; diff --git a/t/uni/tr_sjis.t b/t/uni/tr_sjis.t index fec525d..ff78e7a 100644 --- a/t/uni/tr_sjis.t +++ b/t/uni/tr_sjis.t @@ -6,9 +6,7 @@ BEGIN { chdir 't' if -d 't'; require './test.pl'; - skip_all_without_dynamic_extension('Encode'); - skip_all("no encoding pragma in EBCDIC") if $::IS_EBCDIC; - skip_all_without_perlio(); + skip_all("encoding.pm is no longer supported by the perl core"); } use strict; diff --git a/t/uni/tr_utf8.t b/t/uni/tr_utf8.t index 59782f1..7d16969 100644 --- a/t/uni/tr_utf8.t +++ b/t/uni/tr_utf8.t @@ -1,21 +1,17 @@ #!perl -w # # This script is written intentionally in UTF-8 -# Requires Encode 1.83 or better # -- dankogai BEGIN { chdir 't' if -d 't'; require './test.pl'; - skip_all_without_dynamic_extension('Encode'); - skip_all("no encoding pragma in EBCDIC") if $::IS_EBCDIC; skip_all_without_perlio(); } use strict; plan(tests => 8); -no warnings 'deprecated'; -use encoding 'utf8'; +use utf8; my @hiragana = map {chr} ord("ぁ")..ord("ん"); my @katakana = map {chr} ord("ァ")..ord("ン"); -- 1.8.3.1