Suppress confusing uninit warning from -T _
authorFather Chrysostomos <sprout@cpan.org>
Fri, 13 Jan 2012 22:26:19 +0000 (14:26 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 14 Jan 2012 05:24:54 +0000 (21:24 -0800)
-T _ uses the file name saved by a preceding stat.  If there was no
preceding stat, the internal sv used to store the file name is unde-
fined, so SvPV producing an uninitialized warning.  Normally a failed
-T will just return undefined and set $!.  Normally stat on a filehan-
dle will set the internal stat file name to "".

This commit sets the internal file name to "" initially on startup,
instead of creating an undefined scalar.

perl.c
t/op/filetest.t

diff --git a/perl.c b/perl.c
index 74e7470..2879511 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -4088,7 +4088,7 @@ S_init_predump_symbols(pTHX)
     GvMULTI_on(tmpgv);
     GvIOp(tmpgv) = MUTABLE_IO(SvREFCNT_inc_simple(io));
 
-    PL_statname = newSV(0);            /* last filename we did stat on */
+    PL_statname = newSVpvs("");                /* last filename we did stat on */
 }
 
 void
index 5cc83d7..647bd9d 100644 (file)
@@ -10,7 +10,7 @@ BEGIN {
 }
 
 use Config;
-plan(tests => 35 + 27*14);
+plan(tests => 36 + 27*14);
 
 ok( -d 'op' );
 ok( -f 'TEST' );
@@ -257,3 +257,6 @@ SKIP: {
     like $@, qr/^The stat preceding -l _ wasn't an lstat at /,
        '-T HANDLE sets the stat type';
 }
+
+is runperl(prog => '-T _', switches => ['-w'], stderr => 1), "",
+  'no uninit warnings from -T with no preceding stat';