This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Change the value of ${^TAINT} : 0 without taint checks,
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Mon, 6 Jan 2003 20:31:43 +0000 (20:31 +0000)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Mon, 6 Jan 2003 20:31:43 +0000 (20:31 +0000)
1 with -T, and -1 with -t or -TU.

p4raw-id: //depot/perl@18453

mg.c
pod/perlvar.pod
t/op/taint.t
t/run/runenv.t
t/run/switcht.t

diff --git a/mg.c b/mg.c
index 408c7de..bdf204b 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -658,7 +658,9 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
 #endif
         }
         else if (strEQ(mg->mg_ptr, "\024AINT"))
-            sv_setiv(sv, PL_tainting);
+            sv_setiv(sv, PL_tainting
+                   ? (PL_taint_warn || PL_unsafe ? -1 : 1)
+                   : 0);
         break;
     case '\027':               /* ^W  & $^WARNING_BITS & ^WIDE_SYSTEM_CALLS */
        if (*(mg->mg_ptr+1) == '\0')
index 1a71142..271633e 100644 (file)
@@ -1105,8 +1105,9 @@ and B<-C> filetests are based on this value.
 
 =item ${^TAINT}
 
-Reflects if taint mode is on or off (i.e. if the program was run with
-B<-T> or not).  True for on, false for off.
+Reflects if taint mode is on or off.  1 for on (the program was run with
+B<-T>), 0 for off, -1 when only taint warnings are enabled (i.e. with
+B<-t> or B<-TU>).
 
 =item $PERL_VERSION
 
index 4b8039c..686354e 100755 (executable)
@@ -904,7 +904,7 @@ else {
 }
 
 
-ok( ${^TAINT} '$^TAINT is on' );
+ok( ${^TAINT} == 1, '$^TAINT is on' );
 
 eval { ${^TAINT} = 0 };
 ok( ${^TAINT},  '$^TAINT is not assignable' );
index 9acad00..df4a778 100644 (file)
@@ -150,7 +150,7 @@ try({PERL5OPT => '-w -w'},
 
 try({PERL5OPT => '-t'},
     ['-e', 'print ${^TAINT}'],
-    '1',
+    '-1',
     '');
 
 try({PERLLIB => "foobar$Config{path_sep}42"},
index 869605f..f48124e 100644 (file)
@@ -14,7 +14,7 @@ my $warning;
 local $SIG{__WARN__} = sub { $warning = join "\n", @_; };
 my $Tmsg = 'while running with -t switch';
 
-ok( ${^TAINT},      '${^TAINT} defined' );
+is( ${^TAINT}, -1, '${^TAINT} == -1' );
 
 my $out = `$Perl -le "print q(Hello)"`;
 is( $out, "Hello\n",                      '`` worked' );