Skip to content

Commit 4c84d7f

Browse files
committed
Remove the -P switch
p4raw-id: //depot/perl@32954
1 parent 5ac1e9b commit 4c84d7f

17 files changed

+9
-333
lines changed

Diff for: MANIFEST

-4
Original file line numberDiff line numberDiff line change
@@ -3465,8 +3465,6 @@ t/cmd/while.t See if while loops work
34653465
t/comp/bproto.t See if builtins conform to their prototypes
34663466
t/comp/cmdopt.t See if command optimization works
34673467
t/comp/colon.t See if colons are parsed correctly
3468-
t/comp/cpp.aux main file for cpp.t
3469-
t/comp/cpp.t See if C preprocessor works
34703468
t/comp/decl.t See if declarations work
34713469
t/comp/fold.t See if constant folding works
34723470
t/comp/hints.t See if %^H works
@@ -4009,8 +4007,6 @@ t/run/switchF.t Test the -F switch
40094007
t/run/switchI.t Test the -I switch
40104008
t/run/switchn.t Test the -n switch
40114009
t/run/switchp.t Test the -p switch
4012-
t/run/switchPx.aux Data for switchPx.t
4013-
t/run/switchPx.t Test the -Px combination
40144010
t/run/switcht.t Test the -t switch
40154011
t/run/switchx2.aux Data for switchx.t
40164012
t/run/switchx.aux Data for switchx.t

Diff for: README.hpux

-19
Original file line numberDiff line numberDiff line change
@@ -559,25 +559,6 @@ If you are compiling Perl on a remotely-mounted NFS filesystem, the test
559559
io/fs.t may fail on test #18. This appears to be a bug in HP-UX and no
560560
fix is currently available.
561561

562-
=head2 perl -P and // and HP-UX
563-
564-
If HP-UX Perl is compiled with flags that will cause problems if the
565-
-P flag of Perl (preprocess Perl code with the C preprocessor before
566-
perl sees it) is used. The problem is that C<//>, being a C++-style
567-
until-end-of-line comment, will disappear along with the remainder
568-
of the line. This means that common Perl constructs like
569-
570-
s/foo//;
571-
572-
will turn into illegal code
573-
574-
s/foo
575-
576-
The workaround is to use some other quoting separator than C<"/">,
577-
like for example C<"!">:
578-
579-
s!foo!!;
580-
581562
=head2 HP-UX Kernel Parameters (maxdsiz) for Compiling Perl
582563

583564
By default, HP-UX comes configured with a maximum data segment size of

Diff for: README.os390

-14
Original file line numberDiff line numberDiff line change
@@ -229,20 +229,6 @@ anomalies:
229229

230230
=item *
231231

232-
A message of the form:
233-
234-
comp/cpp.............ERROR CBC3191 ./.301989890.c:1 The character $ is not a
235-
valid C source character.
236-
FSUM3065 The COMPILE step ended with return code 12.
237-
FSUM3017 Could not compile .301989890.c. Correct the errors and try again.
238-
ok
239-
240-
indicates that the t/comp/cpp.t test of Perl's -P command line switch has
241-
passed but that the particular invocation of c89 -E in the cpp script does
242-
not suppress the C compiler check of source code validity.
243-
244-
=item *
245-
246232
A message of the form:
247233

248234
io/openpid...........CEE5210S The signal SIGHUP was received.

Diff for: embedvar.h

-2
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@
235235
#define PL_pidstatus (vTHX->Ipidstatus)
236236
#define PL_ppid (vTHX->Ippid)
237237
#define PL_preambleav (vTHX->Ipreambleav)
238-
#define PL_preprocess (vTHX->Ipreprocess)
239238
#define PL_profiledata (vTHX->Iprofiledata)
240239
#define PL_psig_name (vTHX->Ipsig_name)
241240
#define PL_psig_pend (vTHX->Ipsig_pend)
@@ -547,7 +546,6 @@
547546
#define PL_Ipidstatus PL_pidstatus
548547
#define PL_Ippid PL_ppid
549548
#define PL_Ipreambleav PL_preambleav
550-
#define PL_Ipreprocess PL_preprocess
551549
#define PL_Iprofiledata PL_profiledata
552550
#define PL_Ipsig_name PL_psig_name
553551
#define PL_Ipsig_pend PL_psig_pend

Diff for: intrpvar.h

-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ PERLVAR(Ilocalpatches, const char * const *)
215215
PERLVARI(Isplitstr, const char *, " ")
216216

217217
PERLVAR(Iminus_c, bool)
218-
PERLVAR(Ipreprocess, bool)
219218
PERLVAR(Iminus_n, bool)
220219
PERLVAR(Iminus_p, bool)
221220
PERLVAR(Iminus_l, bool)

Diff for: perl.c

+1-82
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,6 @@ perl_destruct(pTHXx)
894894
}
895895

896896
/* switches */
897-
PL_preprocess = FALSE;
898897
PL_minus_n = FALSE;
899898
PL_minus_p = FALSE;
900899
PL_minus_l = FALSE;
@@ -1804,12 +1803,6 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
18041803
else
18051804
Perl_croak(aTHX_ "No directory specified for -I");
18061805
break;
1807-
case 'P':
1808-
forbid_setid('P', -1);
1809-
PL_preprocess = TRUE;
1810-
s++;
1811-
deprecate("-P");
1812-
goto reswitch;
18131806
case 'S':
18141807
forbid_setid('S', -1);
18151808
dosearch = TRUE;
@@ -2225,7 +2218,6 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
22252218
#endif
22262219
CopLINE_set(PL_curcop, 0);
22272220
PL_curstash = PL_defstash;
2228-
PL_preprocess = FALSE;
22292221
if (PL_e_script) {
22302222
SvREFCNT_dec(PL_e_script);
22312223
PL_e_script = NULL;
@@ -2862,7 +2854,6 @@ S_usage(pTHX_ const char *name) /* XXX move this out into a module ? */
28622854
"-[mM][-]module execute \"use/no module...\" before executing program",
28632855
"-n assume \"while (<>) { ... }\" loop around program",
28642856
"-p assume loop like -n but print line also, like sed",
2865-
"-P run program through C preprocessor before compilation",
28662857
"-s enable rudimentary parsing for switches after programfile",
28672858
"-S look for programfile using PATH environment variable",
28682859
"-t enable tainting warnings",
@@ -2902,7 +2893,7 @@ Perl_get_debug_opts(pTHX_ const char **s, bool givehelp)
29022893
" t Trace execution",
29032894
" o Method and overloading resolution",
29042895
" c String/numeric conversions",
2905-
" P Print profiling info, preprocessor command for -P, source file input state",
2896+
" P Print profiling info, source file input state",
29062897
" m Memory allocation",
29072898
" f Format processing",
29082899
" 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");
33713362
case 'S': /* OS/2 needs -S on "extproc" line. */
33723363
break;
33733364
#endif
3374-
case 'P':
3375-
if (PL_preprocess)
3376-
return s+1;
3377-
/* FALL THROUGH */
33783365
default:
33793366
Perl_croak(aTHX_ "Can't emulate -%.1s on #! line",s);
33803367
}
@@ -3584,72 +3571,6 @@ S_open_script(pTHX_ const char *scriptname, bool dosearch, SV *sv,
35843571
Perl_croak(aTHX_ "suidperl needs (suid) fd script\n");
35853572
}
35863573
#else /* IAMSUID */
3587-
else if (PL_preprocess) {
3588-
const char * const cpp_cfg = CPPSTDIN;
3589-
SV * const cpp = newSVpvs("");
3590-
SV * const cmd = newSV(0);
3591-
3592-
if (cpp_cfg[0] == 0) /* PERL_MICRO? */
3593-
Perl_croak(aTHX_ "Can't run with cpp -P with CPPSTDIN undefined");
3594-
if (strEQ(cpp_cfg, "cppstdin"))
3595-
Perl_sv_catpvf(aTHX_ cpp, "%s/", BIN_EXP);
3596-
sv_catpv(cpp, cpp_cfg);
3597-
3598-
# ifndef VMS
3599-
sv_catpvs(sv, "-I");
3600-
sv_catpv(sv,PRIVLIB_EXP);
3601-
# endif
3602-
3603-
DEBUG_P(PerlIO_printf(Perl_debug_log,
3604-
"PL_preprocess: scriptname=\"%s\", cpp=\"%s\", sv=\"%s\", CPPMINUS=\"%s\"\n",
3605-
scriptname, SvPVX_const (cpp), SvPVX_const (sv),
3606-
CPPMINUS));
3607-
3608-
# if defined(MSDOS) || defined(WIN32) || defined(VMS)
3609-
quote = "\"";
3610-
# else
3611-
quote = "'";
3612-
# endif
3613-
3614-
# ifdef VMS
3615-
cpp_discard_flag = "";
3616-
# else
3617-
cpp_discard_flag = "-C";
3618-
# endif
3619-
3620-
# ifdef OS2
3621-
perl = os2_execname(aTHX);
3622-
# else
3623-
perl = PL_origargv[0];
3624-
# endif
3625-
3626-
3627-
/* This strips off Perl comments which might interfere with
3628-
the C pre-processor, including #!. #line directives are
3629-
deliberately stripped to avoid confusion with Perl's version
3630-
of #line. FWP played some golf with it so it will fit
3631-
into VMS's 255 character buffer.
3632-
*/
3633-
if( PL_doextract )
3634-
code = "(1../^#!.*perl/i)|/^\\s*#(?!\\s*((ifn?|un)def|(el|end)?if|define|include|else|error|pragma)\\b)/||!($|=1)||print";
3635-
else
3636-
code = "/^\\s*#(?!\\s*((ifn?|un)def|(el|end)?if|define|include|else|error|pragma)\\b)/||!($|=1)||print";
3637-
3638-
Perl_sv_setpvf(aTHX_ cmd, "\
3639-
%s -ne%s%s%s %s | %"SVf" %s %"SVf" %s",
3640-
perl, quote, code, quote, scriptname, SVfARG(cpp),
3641-
cpp_discard_flag, SVfARG(sv), CPPMINUS);
3642-
3643-
PL_doextract = FALSE;
3644-
3645-
DEBUG_P(PerlIO_printf(Perl_debug_log,
3646-
"PL_preprocess: cmd=\"%s\"\n",
3647-
SvPVX_const(cmd)));
3648-
3649-
*rsfpp = PerlProc_popen((char *)SvPVX_const(cmd), (char *)"r");
3650-
SvREFCNT_dec(cmd);
3651-
SvREFCNT_dec(cpp);
3652-
}
36533574
else if (!*scriptname) {
36543575
forbid_setid(0, *suidscript);
36553576
*rsfpp = PerlIO_stdin();
@@ -4172,8 +4093,6 @@ FIX YOUR KERNEL, OR PUT A C WRAPPER AROUND THIS SCRIPT!\n");
41724093
Perl_croak(aTHX_ "Effective UID cannot exec script\n"); /* they can't do this */
41734094
}
41744095
# ifdef IAMSUID
4175-
else if (PL_preprocess) /* PSz 13 Nov 03 Caught elsewhere, useless(?!) here */
4176-
Perl_croak(aTHX_ "-P not allowed for setuid/setgid script\n");
41774096
else if (fdscript < 0 || suidscript != 1)
41784097
/* PSz 13 Nov 03 Caught elsewhere, useless(?!) here */
41794098
Perl_croak(aTHX_ "(suid) fdscript needed in suidperl\n");

Diff for: perlapi.h

-2
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,6 @@ END_EXTERN_C
506506
#define PL_ppid (*Perl_Ippid_ptr(aTHX))
507507
#undef PL_preambleav
508508
#define PL_preambleav (*Perl_Ipreambleav_ptr(aTHX))
509-
#undef PL_preprocess
510-
#define PL_preprocess (*Perl_Ipreprocess_ptr(aTHX))
511509
#undef PL_profiledata
512510
#define PL_profiledata (*Perl_Iprofiledata_ptr(aTHX))
513511
#undef PL_psig_name

Diff for: pod/perl.pod

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ B<perl> S<[ B<-sTtuUWX> ]>
1010
S<[ B<-pna> ] [ B<-F>I<pattern> ] [ B<-l>[I<octal>] ] [ B<-0>[I<octal/hexadecimal>] ]>
1111
S<[ B<-I>I<dir> ] [ B<-m>[B<->]I<module> ] [ B<-M>[B<->]I<'module...'> ] [ B<-f> ]>
1212
S<[ B<-C [I<number/list>] >]>
13-
S<[ B<-P> ]>
1413
S<[ B<-S> ]>
1514
S<[ B<-x>[I<dir>] ]>
1615
S<[ B<-i>[I<extension>] ]>

Diff for: pod/perldiag.pod

-5
Original file line numberDiff line numberDiff line change
@@ -3294,11 +3294,6 @@ fine from VMS' perspective, it's probably not what you intended.
32943294

32953295
(F) The unpack format P must have an explicit size, not "*".
32963296

3297-
=item B<-P> not allowed for setuid/setgid script
3298-
3299-
(F) The script would have to be opened by the C preprocessor by name,
3300-
which provides a race condition that breaks security.
3301-
33023297
=item POSIX class [:%s:] unknown in regex; marked by <-- HERE in m/%s/
33033298

33043299
(F) The class in the character class [: :] syntax is unknown. The <-- HERE

Diff for: pod/perlfilter.pod

+2-3
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,8 @@ a source filter is just a special kind of module. Like all Perl
8181
modules, a source filter is invoked with a use statement.
8282

8383
Say you want to pass your Perl source through the C preprocessor before
84-
execution. You could use the existing C<-P> command line option to do
85-
this, but as it happens, the source filters distribution comes with a C
86-
preprocessor filter module called Filter::cpp. Let's use that instead.
84+
execution. As it happens, the source filters distribution comes with a C
85+
preprocessor filter module called Filter::cpp.
8786

8887
Below is an example program, C<cpp_test>, which makes use of this filter.
8988
Line numbers have been added to allow specific lines to be referenced

Diff for: pod/perlrun.pod

+2-72
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ B<perl> S<[ B<-sTtuUWX> ]>
1010
S<[ B<-pna> ] [ B<-F>I<pattern> ] [ B<-l>[I<octal>] ] [ B<-0>[I<octal/hexadecimal>] ]>
1111
S<[ B<-I>I<dir> ] [ B<-m>[B<->]I<module> ] [ B<-M>[B<->]I<'module...'> ] [ B<-f> ]>
1212
S<[ B<-C [I<number/list>] >]>
13-
S<[ B<-P> ]>
1413
S<[ B<-S> ]>
1514
S<[ B<-x>[I<dir>] ]>
1615
S<[ B<-i>[I<extension>] ]>
@@ -395,7 +394,7 @@ B<-D14> is equivalent to B<-Dtls>):
395394
8 t Trace execution
396395
16 o Method and overloading resolution
397396
32 c String/numeric conversions
398-
64 P Print profiling info, preprocessor command for -P, source file input state
397+
64 P Print profiling info, source file input state
399398
128 m Memory allocation
400399
256 f Format processing
401400
512 r Regular expression parsing and execution
@@ -588,9 +587,7 @@ proceeds from STDIN to STDOUT as might be expected.
588587
X<-I> X<@INC>
589588

590589
Directories specified by B<-I> are prepended to the search path for
591-
modules (C<@INC>), and also tells the C preprocessor where to search for
592-
include files. The C preprocessor is invoked with B<-P>; by default it
593-
searches /usr/include and /usr/lib/perl.
590+
modules (C<@INC>).
594591

595592
=item B<-l>[I<octnum>]
596593
X<-l> X<$/> X<$\>
@@ -695,73 +692,6 @@ overrides a B<-n> switch.
695692
C<BEGIN> and C<END> blocks may be used to capture control before or after
696693
the implicit loop, just as in B<awk>.
697694

698-
=item B<-P>
699-
X<-P>
700-
701-
B<NOTE: Use of -P is strongly discouraged because of its inherent
702-
problems, including poor portability. It is deprecated and will be
703-
removed in a future version of Perl.>
704-
705-
This option causes your program to be run through the C preprocessor before
706-
compilation by Perl. Because both comments and B<cpp> directives begin
707-
with the # character, you should avoid starting comments with any words
708-
recognized by the C preprocessor such as C<"if">, C<"else">, or C<"define">.
709-
710-
If you're considering using C<-P>, you might also want to look at the
711-
Filter::cpp module from CPAN.
712-
713-
The problems of -P include, but are not limited to:
714-
715-
=over 10
716-
717-
=item *
718-
719-
The C<#!> line is stripped, so any switches there don't apply.
720-
721-
=item *
722-
723-
A C<-P> on a C<#!> line doesn't work.
724-
725-
=item *
726-
727-
B<All> lines that begin with (whitespace and) a C<#> but
728-
do not look like cpp commands, are stripped, including anything
729-
inside Perl strings, regular expressions, and here-docs .
730-
731-
=item *
732-
733-
In some platforms the C preprocessor knows too much: it knows about
734-
the C++ -style until-end-of-line comments starting with C<"//">.
735-
This will cause problems with common Perl constructs like
736-
737-
s/foo//;
738-
739-
because after -P this will became illegal code
740-
741-
s/foo
742-
743-
The workaround is to use some other quoting separator than C<"/">,
744-
like for example C<"!">:
745-
746-
s!foo!!;
747-
748-
749-
750-
=item *
751-
752-
It requires not only a working C preprocessor but also a working
753-
F<sed>. If not on UNIX, you are probably out of luck on this.
754-
755-
=item *
756-
757-
Script line numbers are not preserved.
758-
759-
=item *
760-
761-
The C<-x> does not work with C<-P>.
762-
763-
=back
764-
765695
=item B<-s>
766696
X<-s>
767697

Diff for: sv.c

-1
Original file line numberDiff line numberDiff line change
@@ -11234,7 +11234,6 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,
1123411234
PL_patchlevel = sv_dup_inc(proto_perl->Ipatchlevel, param);
1123511235
PL_localpatches = proto_perl->Ilocalpatches;
1123611236
PL_splitstr = proto_perl->Isplitstr;
11237-
PL_preprocess = proto_perl->Ipreprocess;
1123811237
PL_minus_n = proto_perl->Iminus_n;
1123911238
PL_minus_p = proto_perl->Iminus_p;
1124011239
PL_minus_l = proto_perl->Iminus_l;

0 commit comments

Comments
 (0)