test -d /system is a bit too generic test for VOS
[p5sagit/p5-mst-13.2.git] / perl.c
diff --git a/perl.c b/perl.c
index e1d3d18..50e7aa1 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -1099,6 +1099,10 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
                goto reswitch;
            break;
 
+       case 't':
+           PL_taint_warn = TRUE;
+           if (! (PL_dowarn & G_WARN_ALL_MASK))
+               PL_dowarn |= G_WARN_ON;
        case 'T':
            PL_tainting = TRUE;
            s++;
@@ -1295,7 +1299,7 @@ print \"  \\@INC:\\n    @INC\\n\";");
                d = s;
                if (!*s)
                    break;
-               if (!strchr("DIMUdmw", *s))
+               if (!strchr("DIMUdmtw", *s))
                    Perl_croak(aTHX_ "Illegal switch in PERL5OPT: -%c", *s);
                while (++s && *s) {
                    if (isSPACE(*s)) {
@@ -1308,7 +1312,12 @@ print \"  \\@INC:\\n    @INC\\n\";");
                        break;
                    }
                }
-               moreswitches(d);
+               if (*d == 't') {
+                   PL_tainting = TRUE;
+                   PL_taint_warn = TRUE;
+               } else {
+                   moreswitches(d);
+               }
            }
        }
     }
@@ -2373,6 +2382,11 @@ Perl_moreswitches(pTHX_ char *s)
        PL_doswitches = TRUE;
        s++;
        return s;
+    case 't':
+        if (!PL_tainting)
+            Perl_croak(aTHX_ "Too late for \"-t\" option");
+        s++;
+        return s;
     case 'T':
        if (!PL_tainting)
            Perl_croak(aTHX_ "Too late for \"-T\" option");
@@ -3430,10 +3444,6 @@ S_init_postdump_symbols(pTHX_ register int argc, register char **argv, register
     char *s;
     SV *sv;
     GV* tmpgv;
-#ifdef NEED_ENVIRON_DUP_FOR_MODIFY
-    char **dup_env_base = 0;
-    int dup_env_count = 0;
-#endif
 
     PL_toptarget = NEWSV(0,0);
     sv_upgrade(PL_toptarget, SVt_PVFM);
@@ -3482,46 +3492,20 @@ S_init_postdump_symbols(pTHX_ register int argc, register char **argv, register
            env = environ;
        if (env != environ)
            environ[0] = Nullch;
-#ifdef NEED_ENVIRON_DUP_FOR_MODIFY
-       {
-           char **env_base;
-           for (env_base = env; *env; env++)
-               dup_env_count++;
-           if ((dup_env_base = (char **)
-                safesysmalloc( sizeof(char *) * (dup_env_count+1) ))) {
-               char **dup_env;
-               for (env = env_base, dup_env = dup_env_base;
-                    *env;
-                    env++, dup_env++) {
-                   /* With environ one needs to use safesysmalloc(). */
-                   *dup_env = safesysmalloc(strlen(*env) + 1);
-                   (void)strcpy(*dup_env, *env);
-               }
-               *dup_env = Nullch;
-               env = dup_env_base;
-           } /* else what? */
-       }
-#endif /* NEED_ENVIRON_DUP_FOR_MODIFY */
        if (env)
          for (; *env; env++) {
            if (!(s = strchr(*env,'=')))
                continue;
-           *s++ = '\0';
 #if defined(MSDOS)
+           *s = '\0';
            (void)strupr(*env);
+           *s = '=';
 #endif
-           sv = newSVpv(s--,0);
+           sv = newSVpv(s+1, 0);
            (void)hv_store(hv, *env, s - *env, sv, 0);
-           *s = '=';
+           if (env != environ)
+               mg_set(sv);
          }
-#ifdef NEED_ENVIRON_DUP_FOR_MODIFY
-       if (dup_env_base) {
-           char **dup_env;
-           for (dup_env = dup_env_base; *dup_env; dup_env++)
-               safesysfree(*dup_env);
-           safesysfree(dup_env_base);
-       }
-#endif /* NEED_ENVIRON_DUP_FOR_MODIFY */
 #endif /* USE_ENVIRON_ARRAY */
     }
     TAINT_NOT;