In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/f9cf141af97dff1d857ee2f905962a19ac97fc36?hp=0540b90bcca7b8f2c1eb9ab87c5fea1b461df4cf>
- Log ----------------------------------------------------------------- commit f9cf141af97dff1d857ee2f905962a19ac97fc36 Author: Father Chrysostomos <[email protected]> Date: Fri Jan 20 13:29:38 2012 -0800 [perl #82772] utf8::decode: Donât read past SvCUR M sv.c commit 05bb32d213ce171a55a6a7226fba6f1f1fea3fd6 Author: Father Chrysostomos <[email protected]> Date: Fri Jan 20 13:12:14 2012 -0800 Warn for stat(*unopened) after statting file Statting an existing file used to prevent a subsequent stat(*unopened) from warning if the GV happened to have no IO. If the GV *did* have an IO, but an unopened one, it *would* warn. This inconsistency was introduced in 5.10.0 with commit 5228a96c60 (which was also backported to 5.8.9). M pp_sys.c M t/lib/warnings/pp_sys commit b8413ac3c2aeba8d9cbe9ce77d7eafc3f5ae0fef Author: Father Chrysostomos <[email protected]> Date: Fri Jan 20 12:59:35 2012 -0800 pp_sys.c:pp_stat: Change scope of havefp var This is only used in the if(gv != PL_defgv) block now. Also, it was being used uninitialized for bad iorefs, probably resulting in random warning suppression (untested). M pp_sys.c commit daa30a688f5d99ab2f3405562a4325687c307066 Author: Father Chrysostomos <[email protected]> Date: Fri Jan 20 12:55:17 2012 -0800 [perl #71002] stat() on unopened fh _ stat _ was producing an erroneous warning about an unopened filehandle with _. But _ isnât a real filehandle and is special-cased, so it shouldnât warn. See also commit 8080e3c8. M pp_sys.c M t/op/stat.t ----------------------------------------------------------------------- Summary of changes: pp_sys.c | 7 ++++--- sv.c | 2 +- t/lib/warnings/pp_sys | 5 +++++ t/op/stat.t | 12 +++++++++++- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/pp_sys.c b/pp_sys.c index 0a1b1dc..20a34ac 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -2759,7 +2759,6 @@ PP(pp_stat) if (PL_op->op_flags & OPf_REF ? (gv = cGVOP_gv, 1) : !!(sv=POPs, gv = MAYBE_DEREF_GV(sv))) { - bool havefp; if (PL_op->op_type == OP_LSTAT) { if (gv != PL_defgv) { do_fstat_warning_check: @@ -2774,9 +2773,10 @@ PP(pp_stat) Perl_croak(aTHX_ "The stat preceding lstat() wasn't an lstat"); } - havefp = FALSE; if (gv != PL_defgv) { + bool havefp; do_fstat_have_io: + havefp = FALSE; PL_laststype = OP_STAT; PL_statgv = gv ? gv : (GV *)io; sv_setpvs(PL_statname, ""); @@ -2796,10 +2796,11 @@ PP(pp_stat) PL_laststatval = -1; } } + else PL_laststatval = -1; + if (PL_laststatval < 0 && !havefp) report_evil_fh(gv); } if (PL_laststatval < 0) { - if (!havefp) report_evil_fh(gv); max = 0; } } diff --git a/sv.c b/sv.c index d116996..6e8ed66 100644 --- a/sv.c +++ b/sv.c @@ -3562,7 +3562,7 @@ Perl_sv_utf8_decode(pTHX_ register SV *const sv) * we want to make sure everything inside is valid utf8 first. */ c = start = (const U8 *) SvPVX_const(sv); - if (!is_utf8_string(c, SvCUR(sv)+1)) + if (!is_utf8_string(c, SvCUR(sv))) return FALSE; e = (const U8 *) SvEND(sv); while (c < e) { diff --git a/t/lib/warnings/pp_sys b/t/lib/warnings/pp_sys index 03492c2..f0a5627 100644 --- a/t/lib/warnings/pp_sys +++ b/t/lib/warnings/pp_sys @@ -585,16 +585,21 @@ close STDIN ; stat(STDIN) ; -T HOCUS; stat(POCUS); +stat "../test.pl"; +stat *foo; no warnings qw(unopened closed) ; -T STDIN ; stat(STDIN); -T HOCUS; stat(POCUS); +stat "../test.pl"; +stat *foo; EXPECT -T on closed filehandle STDIN at - line 4. stat() on closed filehandle STDIN at - line 5. -T on unopened filehandle HOCUS at - line 6. stat() on unopened filehandle POCUS at - line 7. +stat() on unopened filehandle foo at - line 9. ######## # pp_sys.c [pp_fttext] use warnings 'newline' ; diff --git a/t/op/stat.t b/t/op/stat.t index 4f5e36e..df31a38 100644 --- a/t/op/stat.t +++ b/t/op/stat.t @@ -20,7 +20,7 @@ if(eval {require File::Spec; 1}) { } -plan tests => 112; +plan tests => 113; my $Perl = which_perl(); @@ -587,6 +587,16 @@ SKIP: { } } +# [perl #71002] +{ + local $^W = 1; + my $w; + local $SIG{__WARN__} = sub { warn shift; ++$w }; + stat 'prepeinamehyparcheiarcheiometoonomaavto'; + stat _; + is $w, undef, 'no unopened warning from stat _'; +} + END { chmod 0666, $tmpfile; unlink_all $tmpfile; -- Perl5 Master Repository
