develooper Front page | perl.perl5.porters | Postings from December 2005

[PATCH] Make -e enable features, and remove -E

Thread Next
From:
Robin Houston
Date:
December 22, 2005 05:34
Subject:
[PATCH] Make -e enable features, and remove -E
This one will make -e work, new features and all, even if you've deleted
everything apart from the actual perl binary.

Robin

--- perl-before/intrpvar.h	2005-12-21 16:20:18.000000000 +0000
+++ perl-after/intrpvar.h	2005-12-22 12:00:52.000000000 +0000
@@ -38,7 +38,6 @@
 PERLVAR(Iminus_a,	bool)
 PERLVAR(Iminus_F,	bool)
 PERLVAR(Idoswitches,	bool)
-PERLVAR(Iminus_E,	bool)
 
 /*
 =head1 Global Variables
--- perl-before/perl.c	2005-12-21 16:20:18.000000000 +0000
+++ perl-after/perl.c	2005-12-22 13:05:12.000000000 +0000
@@ -1665,9 +1665,6 @@
 	    s++;
 	    goto reswitch;
 
-	case 'E':
-	    PL_minus_E = TRUE;
-	    /* FALL THROUGH */
 	case 'e':
 #ifdef MACOS_TRADITIONAL
 	    /* ignore -e for Dev:Pseudo argument */
@@ -1675,6 +1672,13 @@
 		break;
 #endif
 	    forbid_setid("-e");
+	    PL_hints |= HINT_LOCALIZE_HH;
+	    {
+		HV *hinthv = newHV();
+		hv_store(hinthv, "feature_all", 11, &PL_sv_yes, 0);
+		GvHV(PL_hintgv) = hinthv;
+	    }
+	    
 	    if (!PL_e_script) {
 		PL_e_script = newSVpvn("",0);
 		filter_add(read_e_script, NULL);
--- perl-before/pod/perlrun.pod	2005-12-21 16:20:18.000000000 +0000
+++ perl-after/pod/perlrun.pod	2005-12-22 11:59:46.000000000 +0000
@@ -15,7 +15,7 @@
 	S<[ B<-S> ]>
 	S<[ B<-x>[I<dir>] ]>
 	S<[ B<-i>[I<extension>] ]>
-	S<[ B<-eE> I<'command'> ] [ B<--> ] [ I<programfile> ] [ I<argument> ]...>
+	S<[ B<-e> I<'command'> ] [ B<--> ] [ I<programfile> ] [ I<argument> ]...>
 
 =head1 DESCRIPTION
 
@@ -30,7 +30,7 @@
 
 =item 1.
 
-Specified line by line via B<-e> or B<-E> switches on the command line.
+Specified line by line via B<-e> switches on the command line.
 
 =item 2.
 
@@ -446,13 +446,9 @@
 may be used to enter one line of program.  If B<-e> is given, Perl
 will not look for a filename in the argument list.  Multiple B<-e>
 commands may be given to build up a multi-line script.  Make sure
-to use semicolons where you would in a normal program.
-
-=item B<-E> I<commandline>
-X<-E>
-
-behaves just like B<-e>, except that it implicitly enables all
-optional features (in the main compilation unit). See L<feature>.
+to use semicolons where you would in a normal program. Also
+implicitly enables all optional features (in the main compilation
+unit). See L<feature>.
 
 =item B<-f>
 X<-f>
--- perl-before/sv.c	2005-12-22 13:07:24.000000000 +0000
+++ perl-after/sv.c	2005-12-22 13:07:26.000000000 +0000
@@ -10241,7 +10241,6 @@
     PL_minus_p		= proto_perl->Iminus_p;
     PL_minus_l		= proto_perl->Iminus_l;
     PL_minus_a		= proto_perl->Iminus_a;
-    PL_minus_E		= proto_perl->Iminus_E;
     PL_minus_F		= proto_perl->Iminus_F;
     PL_doswitches	= proto_perl->Idoswitches;
     PL_dowarn		= proto_perl->Idowarn;
--- perl-before/toke.c	2005-12-21 16:20:18.000000000 +0000
+++ perl-after/toke.c	2005-12-22 13:03:39.000000000 +0000
@@ -471,7 +471,8 @@
     char he_name[32] = "feature_";
     (void) strncpy(&he_name[8], name, 24);
     
-    return (hinthv && hv_exists(hinthv, he_name, 8 + namelen));
+    return (hinthv && (hv_exists(hinthv, he_name, 8 + namelen)
+		    || hv_exists(hinthv, "feature_all", 11)) );
 }
 
 /*
@@ -2727,8 +2728,6 @@
 		        sv_catpv(PL_linestr,"our @F=split(' ');");
 		}
 	    }
-	    if (PL_minus_E)
-		sv_catpv(PL_linestr,"use feature ':5.10';");
 	    sv_catpvn(PL_linestr, "\n", 1);
 	    PL_oldoldbufptr = PL_oldbufptr = s = PL_linestart = SvPVX(PL_linestr);
 	    PL_bufend = SvPVX(PL_linestr) + SvCUR(PL_linestr);
--- perl-before/t/run/switches.t	2005-12-21 16:20:18.000000000 +0000
+++ perl-after/t/run/switches.t	2005-12-22 13:28:51.000000000 +0000
@@ -283,25 +283,25 @@
        "-i backup file");
 }
 
-# Tests for -E
+# Tests for -e (make sure it enables features)
 
 $r = runperl(
-    switches	=> [ '-E', '"say q(Hello, world!)"']
+    switches	=> [ '-e', '"say q(Hello, world!)"']
 );
-is( $r, "Hello, world!\n", "-E say" );
+is( $r, "Hello, world!\n", "-e say" );
 
 
 $r = runperl(
-    switches	=> [ '-E', '"undef err say q(Hello, world!)"']
+    switches	=> [ '-e', '"undef err say q(Hello, world!)"']
 );
-is( $r, "Hello, world!\n", "-E err" );
+is( $r, "Hello, world!\n", "-e err" );
 
 $r = runperl(
-    switches	=> [ '-E', '"undef ~~ undef and say q(Hello, world!)"']
+    switches	=> [ '-e', '"undef ~~ undef and say q(Hello, world!)"']
 );
-is( $r, "Hello, world!\n", "-E ~~" );
+is( $r, "Hello, world!\n", "-e ~~" );
 
 $r = runperl(
-    switches	=> [ '-E', '"given(undef) {when(undef) { say q(Hello, world!)"}}']
+    switches	=> [ '-e', '"given(undef) {when(undef) { say q(Hello, world!)"}}']
 );
-is( $r, "Hello, world!\n", "-E given" );
+is( $r, "Hello, world!\n", "-e given" );

Thread Next


Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About