This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Change S_open_script() to return NULL to signal "read from stdin".
authorNicholas Clark <nick@ccl4.org>
Thu, 23 Feb 2012 16:35:31 +0000 (17:35 +0100)
committerNicholas Clark <nick@ccl4.org>
Mon, 27 Feb 2012 10:31:48 +0000 (11:31 +0100)
Move the logic to assign PerlIO_stdin() to rsfp from S_open_script() to its
only caller, S_parse_body().

perl.c

diff --git a/perl.c b/perl.c
index 2385f89..83b5cde 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -2074,6 +2074,9 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
        bool suidscript = FALSE;
 
        rsfp = open_script(scriptname, dosearch, &suidscript);
+       if (!rsfp) {
+           rsfp = PerlIO_stdin();
+       }
 
        validate_suid(validarg, scriptname, fdscript, suidscript,
                      linestr_sv, rsfp);
@@ -3677,7 +3680,7 @@ S_open_script(pTHX_ const char *scriptname, bool dosearch, bool *suidscript)
     }
     else if (!*scriptname) {
        forbid_setid(0, *suidscript);
-       rsfp = PerlIO_stdin();
+       return NULL;
     }
     else {
 #ifdef FAKE_BIT_BUCKET