This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove obsolete comment.
[perl5.git] / perl.c
diff --git a/perl.c b/perl.c
index 09e49c6..411caea 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -1643,7 +1643,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
        case 'X':
        case 'w':
        case 'A':
-           if ((s = moreswitches(s, -1)))
+           if ((s = moreswitches(s)))
                goto reswitch;
            break;
 
@@ -1981,7 +1981,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
                        PL_tainting = TRUE;
                    }
                } else {
-                   moreswitches(d, -1);
+                   moreswitches(d);
                }
            }
        }
@@ -2009,7 +2009,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
     else if (scriptname == NULL) {
 #ifdef MSDOS
        if ( PerlLIO_isatty(PerlIO_fileno(PerlIO_stdin())) )
-           moreswitches("h", -1);
+           moreswitches("h");
 #endif
        scriptname = "-";
     }
@@ -2050,7 +2050,13 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
            || gMacPerl_AlwaysExtract
 #endif
            ) {
-           find_beginning(suidscript);
+
+           /* This will croak if suidscript is >= 0, as -x cannot be used with
+              setuid scripts.  */
+           forbid_setid('x', suidscript);
+           /* Hence you can't get here if suidscript >= 0  */
+
+           find_beginning();
            if (cddir && PerlDir_chdir( (char *)cddir ) < 0)
                Perl_croak(aTHX_ "Can't chdir to %s",cddir);
        }
@@ -2935,7 +2941,7 @@ Perl_get_debug_opts(pTHX_ const char **s, bool givehelp)
 /* This routine handles any switches that can be given during run */
 
 char *
-Perl_moreswitches(pTHX_ char *s, const int suidscript)
+Perl_moreswitches(pTHX_ char *s)
 {
     dVAR;
     UV rschar;
@@ -3003,7 +3009,7 @@ Perl_moreswitches(pTHX_ char *s, const int suidscript)
        s++;
        return s;
     case 'd':
-       forbid_setid('d', suidscript);
+       forbid_setid('d', -1);
        s++;
 
         /* -dt indicates to the debugger that threads will be used */
@@ -3037,7 +3043,7 @@ Perl_moreswitches(pTHX_ char *s, const int suidscript)
     case 'D':
     {  
 #ifdef DEBUGGING
-       forbid_setid('D', suidscript);
+       forbid_setid('D', -1);
        s++;
        PL_debug = get_debug_opts( (const char **)&s, 1) | DEBUG_TOP_FLAG;
 #else /* !DEBUGGING */
@@ -3069,7 +3075,7 @@ Perl_moreswitches(pTHX_ char *s, const int suidscript)
        }
        return s;
     case 'I':  /* -I handled both here and in parse_body() */
-       forbid_setid('I', suidscript);
+       forbid_setid('I', -1);
        ++s;
        while (*s && isSPACE(*s))
            ++s;
@@ -3118,7 +3124,7 @@ Perl_moreswitches(pTHX_ char *s, const int suidscript)
        }
        return s;
     case 'A':
-       forbid_setid('A', suidscript);
+       forbid_setid('A', -1);
        if (!PL_preambleav)
            PL_preambleav = newAV();
        s++;
@@ -3141,10 +3147,10 @@ Perl_moreswitches(pTHX_ char *s, const int suidscript)
            return s;
        }
     case 'M':
-       forbid_setid('M', suidscript);  /* XXX ? */
+       forbid_setid('M', -1);  /* XXX ? */
        /* FALL THROUGH */
     case 'm':
-       forbid_setid('m', suidscript);  /* XXX ? */
+       forbid_setid('m', -1);  /* XXX ? */
        if (*++s) {
            char *start;
            SV *sv;
@@ -3191,7 +3197,7 @@ Perl_moreswitches(pTHX_ char *s, const int suidscript)
        s++;
        return s;
     case 's':
-       forbid_setid('s', suidscript);
+       forbid_setid('s', -1);
        PL_doswitches = TRUE;
        s++;
        return s;
@@ -3500,7 +3506,6 @@ S_init_main_stash(pTHX)
     sv_setpvn(get_sv("/", TRUE), "\n", 1);
 }
 
-/* PSz 18 Nov 03  fdscript now global but do not change prototype */
 STATIC int
 S_open_script(pTHX_ const char *scriptname, bool dosearch, SV *sv,
              int *suidscript)
@@ -4218,7 +4223,7 @@ FIX YOUR KERNEL, PUT A C WRAPPER AROUND THIS SCRIPT, OR USE -u AND UNDUMP!\n");
 }
 
 STATIC void
-S_find_beginning(pTHX_ const int suidscript)
+S_find_beginning(pTHX)
 {
     dVAR;
     register char *s;
@@ -4229,7 +4234,6 @@ S_find_beginning(pTHX_ const int suidscript)
 
     /* skip forward in input to the real script? */
 
-    forbid_setid('x', suidscript);
 #ifdef MACOS_TRADITIONAL
     /* Since the Mac OS does not honor #! arguments for us, we do it ourselves */
 
@@ -4265,7 +4269,7 @@ S_find_beginning(pTHX_ const int suidscript)
                while (isDIGIT(s2[-1]) || s2[-1] == '-' || s2[-1] == '.'
                       || s2[-1] == '_') s2--;
                if (strnEQ(s2-4,"perl",4))
-                   while ((s = moreswitches(s, -1)))
+                   while ((s = moreswitches(s)))
                        ;
            }
 #ifdef MACOS_TRADITIONAL