PATCH: untaint method for IO::Handle, 5.003_06 version
[p5sagit/p5-mst-13.2.git] / perl.c
diff --git a/perl.c b/perl.c
index f1d4aa2..b340b73 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -121,10 +121,12 @@ register PerlInterpreter *sv_interp;
     init_ids();
 
 #if defined(SUBVERSION) && SUBVERSION > 0
-    sprintf(patchlevel, "%7.5f", 5.0 + (PATCHLEVEL / 1000.0)
-                                    + (SUBVERSION / 100000.0));
+    sprintf(patchlevel, "%7.5f",   (double) 5 
+                               + ((double) PATCHLEVEL / (double) 1000)
+                               + ((double) SUBVERSION / (double) 100000));
 #else
-    sprintf(patchlevel, "%5.3f", 5.0 + (PATCHLEVEL / 1000.0));
+    sprintf(patchlevel, "%5.3f", (double) 5 +
+                               ((double) PATCHLEVEL / (double) 1000));
 #endif
 
 #if defined(LOCAL_PATCH_COUNT)
@@ -187,6 +189,14 @@ register PerlInterpreter *sv_interp;
        /* The exit() function will do everything that needs doing. */
        return;
     }
+
+    /* unhook hooks which may now point to, or use, broken code        */
+    if (warnhook && SvREFCNT(warnhook))
+       SvREFCNT_dec(warnhook);
+    if (diehook && SvREFCNT(diehook))
+       SvREFCNT_dec(diehook);
+    if (parsehook && SvREFCNT(parsehook))
+       SvREFCNT_dec(parsehook);
     
     /* Prepare to destruct main symbol table.  */
     hv = defstash;
@@ -393,10 +403,14 @@ setuid perl scripts securely.\n");
                if (!e_fp)
                    croak("Cannot open temporary file");
            }
-           if (argv[1]) {
+           if (*++s)
+               PerlIO_puts(e_fp,s);
+           else if (argv[1]) {
                PerlIO_puts(e_fp,argv[1]);
                argc--,argv++;
            }
+           else
+               croak("No code specified for -e");
            (void)PerlIO_putc(e_fp,'\n');
            break;
        case 'I':
@@ -1288,7 +1302,7 @@ char *s;
        printf("MS-DOS port Copyright (c) 1989, 1990, Diomidis Spinellis\n");
 #endif
 #ifdef OS2
-       printf("OS/2 port Copyright (c) 1990, 1991, Raymond Chen, Kai Uwe Rommel\n"
+       printf("\n\nOS/2 port Copyright (c) 1990, 1991, Raymond Chen, Kai Uwe Rommel\n"
            "Version 5 port Copyright (c) 1994-1996, Andreas Kaiser, Ilya Zakharevich\n");
 #endif
 #ifdef atarist
@@ -1378,6 +1392,7 @@ init_main_stash()
     defgv = gv_fetchpv("_",TRUE, SVt_PVAV);
     errgv = gv_HVadd(gv_fetchpv("@", TRUE, SVt_PV));
     GvMULTI_on(errgv);
+    sv_setpvn(GvSV(errgv), "", 0);
     curstash = defstash;
     compiling.cop_stash = defstash;
     debstash = GvHV(gv_fetchpv("DB::", GV_ADDMULTI, SVt_PVHV));
@@ -1583,6 +1598,9 @@ sed %s -e \"/^[^#]/b\" \
        fcntl(PerlIO_fileno(rsfp),F_SETFD,1);   /* ensure close-on-exec */
 #endif
     }
+    if (e_tmpname) {
+       e_fp = rsfp;
+    }
     if ((PerlIO*)rsfp == Nullfp) {
 #ifdef DOSUID
 #ifndef IAMSUID                /* in case script is not readable before setuid */
@@ -2111,11 +2129,24 @@ init_perllib()
 {
     char *s;
     if (!tainting) {
+#ifndef VMS
        s = getenv("PERL5LIB");
        if (s)
            incpush(s);
        else
            incpush(getenv("PERLLIB"));
+#else /* VMS */
+       /* Treat PERL5?LIB as a possible search list logical name -- the
+        * "natural" VMS idiom for a Unix path string.  We allow each
+        * element to be a set of |-separated directories for compatibility.
+        */
+       char buf[256];
+       int idx = 0;
+       if (my_trnlnm("PERL5LIB",buf,0))
+           do { incpush(buf); } while (my_trnlnm("PERL5LIB",buf,++idx));
+       else
+           while (my_trnlnm("PERLLIB",buf,idx++)) incpush(buf);
+#endif /* VMS */
     }
 
 /* Use the ~-expanded versions of APPLIB (undocumented),