Multiline one-liners are a bit too much to ask.
[p5sagit/p5-mst-13.2.git] / perl.c
diff --git a/perl.c b/perl.c
index 32e0469..0569d5b 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -181,6 +181,9 @@ perl_construct(pTHXx)
            SvNV(&PL_sv_yes);
            SvREADONLY_on(&PL_sv_yes);
            SvREFCNT(&PL_sv_yes) = (~(U32)0)/2;
+
+           SvREADONLY_on(&PL_sv_placeholder);
+           SvREFCNT(&PL_sv_placeholder) = (~(U32)0)/2;
        }
 
        PL_sighandlerp = Perl_sighandler;
@@ -260,8 +263,10 @@ perl_construct(pTHXx)
        ("__environ", (unsigned long *) &environ_pointer, NULL);
 #endif /* environ */
 
-#ifdef  USE_ENVIRON_ARRAY
+#ifndef PERL_MICRO
+#   ifdef  USE_ENVIRON_ARRAY
     PL_origenviron = environ;
+#   endif
 #endif
 
     /* Use sysconf(_SC_CLK_TCK) if available, if not
@@ -406,6 +411,7 @@ perl_destruct(pTHXx)
     /* if PERL_USE_SAFE_PUTENV is defined environ will not have been copied
      * so we certainly shouldn't free it here
      */
+#ifndef PERL_MICRO
 #if defined(USE_ENVIRON_ARRAY) && !defined(PERL_USE_SAFE_PUTENV)
     if (environ != PL_origenviron
 #ifdef USE_ITHREADS
@@ -425,6 +431,7 @@ perl_destruct(pTHXx)
        environ = PL_origenviron;
     }
 #endif
+#endif /* !PERL_MICRO */
 
 #ifdef USE_ITHREADS
     /* the syntax tree is shared between clones
@@ -783,6 +790,9 @@ perl_destruct(pTHXx)
     SvREFCNT(&PL_sv_undef) = 0;
     SvREADONLY_off(&PL_sv_undef);
 
+    SvREFCNT(&PL_sv_placeholder) = 0;
+    SvREADONLY_off(&PL_sv_placeholder);
+
     Safefree(PL_origfilename);
     Safefree(PL_reg_start_tmp);
     if (PL_reg_curpm)
@@ -899,9 +909,12 @@ setuid perl scripts securely.\n");
 
 #if defined(USE_HASH_SEED) || defined(USE_HASH_SEED_EXPLICIT)
     /* [perl #22371] Algorimic Complexity Attack on Perl 5.6.1, 5.8.0
-     * This MUST be done before any hash stores or fetches take place. */
+     * This MUST be done before any hash stores or fetches take place.
+     * If you set PL_hash_seed (and assumedly also PL_hash_seed_set) yourself,
+     * it is your responsibility to provide a good random seed!
+     * You can also define PERL_HASH_SEED in compile time, see hv.h. */
     if (!PL_hash_seed_set)
-        PL_hash_seed = get_seed();
+        PL_hash_seed = get_hash_seed();
     {
         char *s = PerlEnv_getenv("PERL_HASH_SEED_DEBUG");
 
@@ -926,7 +939,7 @@ setuid perl scripts securely.\n");
         * the area we are able to modify is limited to the size of
         * the original argv[0].  (See below for 'contiguous', though.)
         * --jhi */
-        char *s;
+        char *s = NULL;
         int i;
         UV mask =
           ~(UV)(PTRSIZE == 4 ? 3 : PTRSIZE == 8 ? 7 : PTRSIZE == 16 ? 15 : 0);
@@ -943,26 +956,27 @@ setuid perl scripts securely.\n");
          * PTRSIZE bytes.  As long as no system has something bizarre
          * like the argv[] interleaved with some other data, we are
          * fine.  (Did I just evoke Murphy's Law?)  --jhi */
-        s = PL_origargv[0];
-        while (*s) s++;
-        for (i = 1; i < PL_origargc; i++) {
-             if ((PL_origargv[i] == s + 1
+        if (PL_origargv && PL_origargc >= 1 && (s = PL_origargv[0])) {
+             while (*s) s++;
+             for (i = 1; i < PL_origargc; i++) {
+                  if ((PL_origargv[i] == s + 1
 #ifdef OS2
-                  || PL_origargv[i] == s + 2
+                       || PL_origargv[i] == s + 2
 #endif 
-                 )
-                 ||
-                 (aligned &&
-                  (PL_origargv[i] >  s &&
-                   PL_origargv[i] <=
-                   INT2PTR(char *, PTR2UV(s + PTRSIZE) & mask)))
-                )
-             {
-                  s = PL_origargv[i];
-                  while (*s) s++;
+                           )
+                      ||
+                      (aligned &&
+                       (PL_origargv[i] >  s &&
+                        PL_origargv[i] <=
+                        INT2PTR(char *, PTR2UV(s + PTRSIZE) & mask)))
+                       )
+                  {
+                       s = PL_origargv[i];
+                       while (*s) s++;
+                  }
+                  else
+                       break;
              }
-             else
-                  break;
         }
         /* Can we grab env area too to be used as the area for $0? */
         if (PL_origenviron) {
@@ -1435,9 +1449,7 @@ print \"  \\@INC:\\n    @INC\\n\";");
 
     boot_core_PerlIO();
     boot_core_UNIVERSAL();
-#ifndef PERL_MICRO
     boot_core_xsutils();
-#endif
 
     if (xsinit)
        (*xsinit)(aTHX);        /* in case linked C routines want magical variables */
@@ -1655,7 +1667,7 @@ S_run_body(pTHX_ I32 oldscope)
 
     if (!PL_restartop) {
        DEBUG_x(dump_all());
-       DEBUG(PerlIO_printf(Perl_debug_log, "\nEXECUTING...\n\n"));
+       PERL_DEBUG(PerlIO_printf(Perl_debug_log, "\nEXECUTING...\n\n"));
        DEBUG_S(PerlIO_printf(Perl_debug_log, "main thread is 0x%"UVxf"\n",
                              PTR2UV(thr)));
 
@@ -2868,6 +2880,8 @@ S_open_script(pTHX_ char *scriptname, bool dosearch, SV *sv, int *fdscript)
        SV *cpp = newSVpvn("",0);
        SV *cmd = NEWSV(0,0);
 
+       if (cpp_cfg[0] == 0) /* PERL_MICRO? */
+            Perl_croak(aTHX_ "Can't run with cpp -P with CPPSTDIN undefined");
        if (strEQ(cpp_cfg, "cppstdin"))
            Perl_sv_catpvf(aTHX_ cpp, "%s/", BIN_EXP);
        sv_catpv(cpp, cpp_cfg);
@@ -3724,6 +3738,7 @@ S_init_postdump_symbols(pTHX_ register int argc, register char **argv, register
        GvMULTI_on(PL_envgv);
        hv = GvHVn(PL_envgv);
        hv_magic(hv, Nullgv, PERL_MAGIC_env);
+#ifndef PERL_MICRO
 #ifdef USE_ENVIRON_ARRAY
        /* Note that if the supplied env parameter is actually a copy
           of the global environ then it may now point to free'd memory
@@ -3755,6 +3770,7 @@ S_init_postdump_symbols(pTHX_ register int argc, register char **argv, register
                mg_set(sv);
          }
 #endif /* USE_ENVIRON_ARRAY */
+#endif /* !PERL_MICRO */
     }
     TAINT_NOT;
     if ((tmpgv = gv_fetchpv("$",TRUE, SVt_PV))) {