From: Rafael Garcia-Suarez Date: Fri, 11 Jan 2008 13:55:07 +0000 (+0000) Subject: Remove the -P switch X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4c84d7f2;p=p5sagit%2Fp5-mst-13.2.git Remove the -P switch p4raw-id: //depot/perl@32954 --- diff --git a/MANIFEST b/MANIFEST index cd81824..222cdeb 100644 --- a/MANIFEST +++ b/MANIFEST @@ -3465,8 +3465,6 @@ t/cmd/while.t See if while loops work t/comp/bproto.t See if builtins conform to their prototypes t/comp/cmdopt.t See if command optimization works t/comp/colon.t See if colons are parsed correctly -t/comp/cpp.aux main file for cpp.t -t/comp/cpp.t See if C preprocessor works t/comp/decl.t See if declarations work t/comp/fold.t See if constant folding works t/comp/hints.t See if %^H works @@ -4009,8 +4007,6 @@ t/run/switchF.t Test the -F switch t/run/switchI.t Test the -I switch t/run/switchn.t Test the -n switch t/run/switchp.t Test the -p switch -t/run/switchPx.aux Data for switchPx.t -t/run/switchPx.t Test the -Px combination t/run/switcht.t Test the -t switch t/run/switchx2.aux Data for switchx.t t/run/switchx.aux Data for switchx.t diff --git a/README.hpux b/README.hpux index f1e1fea..d95d5eb 100644 --- a/README.hpux +++ b/README.hpux @@ -559,25 +559,6 @@ If you are compiling Perl on a remotely-mounted NFS filesystem, the test io/fs.t may fail on test #18. This appears to be a bug in HP-UX and no fix is currently available. -=head2 perl -P and // and HP-UX - -If HP-UX Perl is compiled with flags that will cause problems if the --P flag of Perl (preprocess Perl code with the C preprocessor before -perl sees it) is used. The problem is that C, being a C++-style -until-end-of-line comment, will disappear along with the remainder -of the line. This means that common Perl constructs like - - s/foo//; - -will turn into illegal code - - s/foo - -The workaround is to use some other quoting separator than C<"/">, -like for example C<"!">: - - s!foo!!; - =head2 HP-UX Kernel Parameters (maxdsiz) for Compiling Perl By default, HP-UX comes configured with a maximum data segment size of diff --git a/README.os390 b/README.os390 index cea717d..9860bae 100644 --- a/README.os390 +++ b/README.os390 @@ -231,20 +231,6 @@ anomalies: A message of the form: - comp/cpp.............ERROR CBC3191 ./.301989890.c:1 The character $ is not a - valid C source character. - FSUM3065 The COMPILE step ended with return code 12. - FSUM3017 Could not compile .301989890.c. Correct the errors and try again. - ok - -indicates that the t/comp/cpp.t test of Perl's -P command line switch has -passed but that the particular invocation of c89 -E in the cpp script does -not suppress the C compiler check of source code validity. - -=item * - -A message of the form: - io/openpid...........CEE5210S The signal SIGHUP was received. CEE5210S The signal SIGHUP was received. CEE5210S The signal SIGHUP was received. diff --git a/embedvar.h b/embedvar.h index 71b603a..71199c9 100644 --- a/embedvar.h +++ b/embedvar.h @@ -235,7 +235,6 @@ #define PL_pidstatus (vTHX->Ipidstatus) #define PL_ppid (vTHX->Ippid) #define PL_preambleav (vTHX->Ipreambleav) -#define PL_preprocess (vTHX->Ipreprocess) #define PL_profiledata (vTHX->Iprofiledata) #define PL_psig_name (vTHX->Ipsig_name) #define PL_psig_pend (vTHX->Ipsig_pend) @@ -547,7 +546,6 @@ #define PL_Ipidstatus PL_pidstatus #define PL_Ippid PL_ppid #define PL_Ipreambleav PL_preambleav -#define PL_Ipreprocess PL_preprocess #define PL_Iprofiledata PL_profiledata #define PL_Ipsig_name PL_psig_name #define PL_Ipsig_pend PL_psig_pend diff --git a/intrpvar.h b/intrpvar.h index 153b2b8..787543f 100644 --- a/intrpvar.h +++ b/intrpvar.h @@ -215,7 +215,6 @@ PERLVAR(Ilocalpatches, const char * const *) PERLVARI(Isplitstr, const char *, " ") PERLVAR(Iminus_c, bool) -PERLVAR(Ipreprocess, bool) PERLVAR(Iminus_n, bool) PERLVAR(Iminus_p, bool) PERLVAR(Iminus_l, bool) diff --git a/perl.c b/perl.c index a299667..67c99eb 100644 --- a/perl.c +++ b/perl.c @@ -894,7 +894,6 @@ perl_destruct(pTHXx) } /* switches */ - PL_preprocess = FALSE; PL_minus_n = FALSE; PL_minus_p = FALSE; PL_minus_l = FALSE; @@ -1804,12 +1803,6 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit) else Perl_croak(aTHX_ "No directory specified for -I"); break; - case 'P': - forbid_setid('P', -1); - PL_preprocess = TRUE; - s++; - deprecate("-P"); - goto reswitch; case 'S': forbid_setid('S', -1); dosearch = TRUE; @@ -2225,7 +2218,6 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit) #endif CopLINE_set(PL_curcop, 0); PL_curstash = PL_defstash; - PL_preprocess = FALSE; if (PL_e_script) { SvREFCNT_dec(PL_e_script); PL_e_script = NULL; @@ -2862,7 +2854,6 @@ S_usage(pTHX_ const char *name) /* XXX move this out into a module ? */ "-[mM][-]module execute \"use/no module...\" before executing program", "-n assume \"while (<>) { ... }\" loop around program", "-p assume loop like -n but print line also, like sed", -"-P run program through C preprocessor before compilation", "-s enable rudimentary parsing for switches after programfile", "-S look for programfile using PATH environment variable", "-t enable tainting warnings", @@ -2902,7 +2893,7 @@ Perl_get_debug_opts(pTHX_ const char **s, bool givehelp) " t Trace execution", " o Method and overloading resolution", " c String/numeric conversions", - " P Print profiling info, preprocessor command for -P, source file input state", + " P Print profiling info, source file input state", " m Memory allocation", " f Format processing", " r Regular expression parsing and execution", @@ -3371,10 +3362,6 @@ Internet, point your browser at http://www.perl.org/, the Perl Home Page.\n\n"); case 'S': /* OS/2 needs -S on "extproc" line. */ break; #endif - case 'P': - if (PL_preprocess) - return s+1; - /* FALL THROUGH */ default: Perl_croak(aTHX_ "Can't emulate -%.1s on #! line",s); } @@ -3584,72 +3571,6 @@ S_open_script(pTHX_ const char *scriptname, bool dosearch, SV *sv, Perl_croak(aTHX_ "suidperl needs (suid) fd script\n"); } #else /* IAMSUID */ - else if (PL_preprocess) { - const char * const cpp_cfg = CPPSTDIN; - SV * const cpp = newSVpvs(""); - SV * const cmd = newSV(0); - - if (cpp_cfg[0] == 0) /* PERL_MICRO? */ - Perl_croak(aTHX_ "Can't run with cpp -P with CPPSTDIN undefined"); - if (strEQ(cpp_cfg, "cppstdin")) - Perl_sv_catpvf(aTHX_ cpp, "%s/", BIN_EXP); - sv_catpv(cpp, cpp_cfg); - -# ifndef VMS - sv_catpvs(sv, "-I"); - sv_catpv(sv,PRIVLIB_EXP); -# endif - - DEBUG_P(PerlIO_printf(Perl_debug_log, - "PL_preprocess: scriptname=\"%s\", cpp=\"%s\", sv=\"%s\", CPPMINUS=\"%s\"\n", - scriptname, SvPVX_const (cpp), SvPVX_const (sv), - CPPMINUS)); - -# if defined(MSDOS) || defined(WIN32) || defined(VMS) - quote = "\""; -# else - quote = "'"; -# endif - -# ifdef VMS - cpp_discard_flag = ""; -# else - cpp_discard_flag = "-C"; -# endif - -# ifdef OS2 - perl = os2_execname(aTHX); -# else - perl = PL_origargv[0]; -# endif - - - /* This strips off Perl comments which might interfere with - the C pre-processor, including #!. #line directives are - deliberately stripped to avoid confusion with Perl's version - of #line. FWP played some golf with it so it will fit - into VMS's 255 character buffer. - */ - if( PL_doextract ) - code = "(1../^#!.*perl/i)|/^\\s*#(?!\\s*((ifn?|un)def|(el|end)?if|define|include|else|error|pragma)\\b)/||!($|=1)||print"; - else - code = "/^\\s*#(?!\\s*((ifn?|un)def|(el|end)?if|define|include|else|error|pragma)\\b)/||!($|=1)||print"; - - Perl_sv_setpvf(aTHX_ cmd, "\ -%s -ne%s%s%s %s | %"SVf" %s %"SVf" %s", - perl, quote, code, quote, scriptname, SVfARG(cpp), - cpp_discard_flag, SVfARG(sv), CPPMINUS); - - PL_doextract = FALSE; - - DEBUG_P(PerlIO_printf(Perl_debug_log, - "PL_preprocess: cmd=\"%s\"\n", - SvPVX_const(cmd))); - - *rsfpp = PerlProc_popen((char *)SvPVX_const(cmd), (char *)"r"); - SvREFCNT_dec(cmd); - SvREFCNT_dec(cpp); - } else if (!*scriptname) { forbid_setid(0, *suidscript); *rsfpp = PerlIO_stdin(); @@ -4172,8 +4093,6 @@ FIX YOUR KERNEL, OR PUT A C WRAPPER AROUND THIS SCRIPT!\n"); Perl_croak(aTHX_ "Effective UID cannot exec script\n"); /* they can't do this */ } # ifdef IAMSUID - else if (PL_preprocess) /* PSz 13 Nov 03 Caught elsewhere, useless(?!) here */ - Perl_croak(aTHX_ "-P not allowed for setuid/setgid script\n"); else if (fdscript < 0 || suidscript != 1) /* PSz 13 Nov 03 Caught elsewhere, useless(?!) here */ Perl_croak(aTHX_ "(suid) fdscript needed in suidperl\n"); diff --git a/perlapi.h b/perlapi.h index 1468acc..d1c3404 100644 --- a/perlapi.h +++ b/perlapi.h @@ -506,8 +506,6 @@ END_EXTERN_C #define PL_ppid (*Perl_Ippid_ptr(aTHX)) #undef PL_preambleav #define PL_preambleav (*Perl_Ipreambleav_ptr(aTHX)) -#undef PL_preprocess -#define PL_preprocess (*Perl_Ipreprocess_ptr(aTHX)) #undef PL_profiledata #define PL_profiledata (*Perl_Iprofiledata_ptr(aTHX)) #undef PL_psig_name diff --git a/pod/perl.pod b/pod/perl.pod index 040a55c..c5bbd32 100644 --- a/pod/perl.pod +++ b/pod/perl.pod @@ -10,7 +10,6 @@ B S<[ B<-sTtuUWX> ]> S<[ B<-pna> ] [ B<-F>I ] [ B<-l>[I] ] [ B<-0>[I] ]> S<[ B<-I>I ] [ B<-m>[B<->]I ] [ B<-M>[B<->]I<'module...'> ] [ B<-f> ]> S<[ B<-C [I] >]> - S<[ B<-P> ]> S<[ B<-S> ]> S<[ B<-x>[I] ]> S<[ B<-i>[I] ]> diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 29d3cd6..caa3915 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -3294,11 +3294,6 @@ fine from VMS' perspective, it's probably not what you intended. (F) The unpack format P must have an explicit size, not "*". -=item B<-P> not allowed for setuid/setgid script - -(F) The script would have to be opened by the C preprocessor by name, -which provides a race condition that breaks security. - =item POSIX class [:%s:] unknown in regex; marked by <-- HERE in m/%s/ (F) The class in the character class [: :] syntax is unknown. The <-- HERE diff --git a/pod/perlfilter.pod b/pod/perlfilter.pod index d43028c..f96fe66 100644 --- a/pod/perlfilter.pod +++ b/pod/perlfilter.pod @@ -81,9 +81,8 @@ a source filter is just a special kind of module. Like all Perl modules, a source filter is invoked with a use statement. Say you want to pass your Perl source through the C preprocessor before -execution. You could use the existing C<-P> command line option to do -this, but as it happens, the source filters distribution comes with a C -preprocessor filter module called Filter::cpp. Let's use that instead. +execution. As it happens, the source filters distribution comes with a C +preprocessor filter module called Filter::cpp. Below is an example program, C, which makes use of this filter. Line numbers have been added to allow specific lines to be referenced diff --git a/pod/perlrun.pod b/pod/perlrun.pod index 5cbe8ff..c82e280 100644 --- a/pod/perlrun.pod +++ b/pod/perlrun.pod @@ -10,7 +10,6 @@ B S<[ B<-sTtuUWX> ]> S<[ B<-pna> ] [ B<-F>I ] [ B<-l>[I] ] [ B<-0>[I] ]> S<[ B<-I>I ] [ B<-m>[B<->]I ] [ B<-M>[B<->]I<'module...'> ] [ B<-f> ]> S<[ B<-C [I] >]> - S<[ B<-P> ]> S<[ B<-S> ]> S<[ B<-x>[I] ]> S<[ B<-i>[I] ]> @@ -395,7 +394,7 @@ B<-D14> is equivalent to B<-Dtls>): 8 t Trace execution 16 o Method and overloading resolution 32 c String/numeric conversions - 64 P Print profiling info, preprocessor command for -P, source file input state + 64 P Print profiling info, source file input state 128 m Memory allocation 256 f Format processing 512 r Regular expression parsing and execution @@ -588,9 +587,7 @@ proceeds from STDIN to STDOUT as might be expected. X<-I> X<@INC> Directories specified by B<-I> are prepended to the search path for -modules (C<@INC>), and also tells the C preprocessor where to search for -include files. The C preprocessor is invoked with B<-P>; by default it -searches /usr/include and /usr/lib/perl. +modules (C<@INC>). =item B<-l>[I] X<-l> X<$/> X<$\> @@ -695,73 +692,6 @@ overrides a B<-n> switch. C and C blocks may be used to capture control before or after the implicit loop, just as in B. -=item B<-P> -X<-P> - -B - -This option causes your program to be run through the C preprocessor before -compilation by Perl. Because both comments and B directives begin -with the # character, you should avoid starting comments with any words -recognized by the C preprocessor such as C<"if">, C<"else">, or C<"define">. - -If you're considering using C<-P>, you might also want to look at the -Filter::cpp module from CPAN. - -The problems of -P include, but are not limited to: - -=over 10 - -=item * - -The C<#!> line is stripped, so any switches there don't apply. - -=item * - -A C<-P> on a C<#!> line doesn't work. - -=item * - -B lines that begin with (whitespace and) a C<#> but -do not look like cpp commands, are stripped, including anything -inside Perl strings, regular expressions, and here-docs . - -=item * - -In some platforms the C preprocessor knows too much: it knows about -the C++ -style until-end-of-line comments starting with C<"//">. -This will cause problems with common Perl constructs like - - s/foo//; - -because after -P this will became illegal code - - s/foo - -The workaround is to use some other quoting separator than C<"/">, -like for example C<"!">: - - s!foo!!; - - - -=item * - -It requires not only a working C preprocessor but also a working -F. If not on UNIX, you are probably out of luck on this. - -=item * - -Script line numbers are not preserved. - -=item * - -The C<-x> does not work with C<-P>. - -=back - =item B<-s> X<-s> diff --git a/sv.c b/sv.c index 37f527f..f387d6c 100644 --- a/sv.c +++ b/sv.c @@ -11234,7 +11234,6 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags, PL_patchlevel = sv_dup_inc(proto_perl->Ipatchlevel, param); PL_localpatches = proto_perl->Ilocalpatches; PL_splitstr = proto_perl->Isplitstr; - PL_preprocess = proto_perl->Ipreprocess; PL_minus_n = proto_perl->Iminus_n; PL_minus_p = proto_perl->Iminus_p; PL_minus_l = proto_perl->Iminus_l; diff --git a/t/comp/cpp.aux b/t/comp/cpp.aux deleted file mode 100755 index 9452bdd..0000000 --- a/t/comp/cpp.aux +++ /dev/null @@ -1,35 +0,0 @@ -#!./perl -l - -# There's a bug in -P where the #! line is ignored. If this test -# suddenly starts printing blank lines that bug has been fixed. - -print "1..3\n"; - -#define MESS "ok 1\n" -print MESS; - -#ifdef MESS - print "ok 2\n"; -#else - print "not ok 2\n"; -#endif - -open(TRY,">Comp_cpp.tmp") || die "Can't open temp perl file: $!"; - -($prog = <<'END') =~ s/X//g; -X$ok = "not ok 3\n"; -X#include "Comp_cpp.inc" -X#ifdef OK -X$ok = OK; -X#endif -Xprint $ok; -END -print TRY $prog; -close TRY or die "Could not close Comp_cpp.tmp: $!"; - -open(TRY,">Comp_cpp.inc") || (die "Can't open temp include file: $!"); -print TRY '#define OK "ok 3\n"' . "\n"; -close TRY or die "Could not close Comp_cpp.tmp: $!"; - -print `$^X "-P" Comp_cpp.tmp`; -unlink "Comp_cpp.tmp", "Comp_cpp.inc"; diff --git a/t/comp/cpp.t b/t/comp/cpp.t deleted file mode 100755 index 80add81..0000000 --- a/t/comp/cpp.t +++ /dev/null @@ -1,17 +0,0 @@ -#!./perl - -BEGIN { - chdir 't' if -d 't'; - @INC = '../lib'; - $ENV{PERL5LIB} = '../lib'; -} - -use Config; -if ( $^O eq 'MacOS' || - ($Config{'cppstdin'} =~ /\bcppstdin\b/) && - ! -x $Config{'binexp'} . "/cppstdin" ) { - print "1..0 # Skip: \$Config{cppstdin} unavailable\n"; - exit; # Cannot test till after install, alas. -} - -system qq{$^X -"P" "comp/cpp.aux"}; diff --git a/t/run/switchPx.aux b/t/run/switchPx.aux deleted file mode 100644 index 68ebc83..0000000 --- a/t/run/switchPx.aux +++ /dev/null @@ -1,34 +0,0 @@ -Some stuff that's not Perl - -This CPP directive should not be read. -#define BARMAR 1 - -#perl - -Still not perl. - -#! - -still not perl - -#!/something/else - -still not perl - -#!/some/path/that/leads/to/perl -l - -# The -l switch should be applied from the #! line. -# Unfortunately, -P has a bug whereby the #! line is ignored. -# If this test suddenly starts printing blank lines that bug is fixed. - -#define FOO "ok 1\n" - -#ifdef BARMAR -# define YAR "not ok 2\n" -#else -# define YAR "ok 2\n" -#endif - -print "1..2\n"; -print FOO; -print YAR; diff --git a/t/run/switchPx.t b/t/run/switchPx.t deleted file mode 100644 index 72b068f..0000000 --- a/t/run/switchPx.t +++ /dev/null @@ -1,22 +0,0 @@ -#!./perl - -# Ensure that the -P and -x flags work together. - -BEGIN { - chdir 't' if -d 't'; - @INC = '../lib'; - $ENV{PERL5LIB} = '../lib'; - - use Config; - if ( $^O eq 'MacOS' || ($Config{'cppstdin'} =~ /\bcppstdin\b/) && - ! -x $Config{'binexp'} . "/cppstdin" ) { - print "1..0 # Skip: \$Config{cppstdin} unavailable\n"; - exit; # Cannot test till after install, alas. - } -} - -require './test.pl'; - -print runperl( switches => ['-Px'], - nolib => 1, # for some reason this is necessary under VMS - progfile => 'run/switchPx.aux' ); diff --git a/toke.c b/toke.c index c3a8475..32ef3e5 100644 --- a/toke.c +++ b/toke.c @@ -1109,16 +1109,14 @@ S_skipspace(pTHX_ register char *s) PL_bufend = SvPVX(PL_linestr) + SvCUR(PL_linestr); PL_last_lop = PL_last_uni = NULL; - /* Close the filehandle. Could be from -P preprocessor, + /* Close the filehandle. Could be from * STDIN, or a regular file. If we were reading code from * STDIN (because the commandline held no -e or filename) * then we don't close it, we reset it so the code can * read from STDIN too. */ - if (PL_preprocess && !PL_in_eval) - (void)PerlProc_pclose(PL_rsfp); - else if ((PerlIO*)PL_rsfp == PerlIO_stdin()) + if ((PerlIO*)PL_rsfp == PerlIO_stdin()) PerlIO_clearerr(PL_rsfp); else (void)PerlIO_close(PL_rsfp); @@ -3668,9 +3666,7 @@ Perl_yylex(pTHX) PL_realtokenstart = -1; #endif if (PL_rsfp) { - if (PL_preprocess && !PL_in_eval) - (void)PerlProc_pclose(PL_rsfp); - else if ((PerlIO *)PL_rsfp == PerlIO_stdin()) + if ((PerlIO *)PL_rsfp == PerlIO_stdin()) PerlIO_clearerr(PL_rsfp); else (void)PerlIO_close(PL_rsfp); @@ -3717,16 +3713,7 @@ Perl_yylex(pTHX) # endif # endif #endif -#ifdef FTELL_FOR_PIPE_IS_BROKEN - /* This loses the possibility to detect the bof - * situation on perl -P when the libc5 is being used. - * Workaround? Maybe attach some extra state to PL_rsfp? - */ - if (!PL_preprocess) - bof = PerlIO_tell(PL_rsfp) == SvCUR(PL_linestr); -#else bof = PerlIO_tell(PL_rsfp) == (Off_t)SvCUR(PL_linestr); -#endif if (bof) { PL_bufend = SvPVX(PL_linestr) + SvCUR(PL_linestr); s = swallow_bom((U8*)s); @@ -5662,9 +5649,7 @@ Perl_yylex(pTHX) #endif /* Mark this internal pseudo-handle as clean */ IoFLAGS(GvIOp(gv)) |= IOf_UNTAINT; - if (PL_preprocess) - IoTYPE(GvIOp(gv)) = IoTYPE_PIPE; - else if ((PerlIO*)PL_rsfp == PerlIO_stdin()) + if ((PerlIO*)PL_rsfp == PerlIO_stdin()) IoTYPE(GvIOp(gv)) = IoTYPE_STD; else IoTYPE(GvIOp(gv)) = IoTYPE_RDONLY;