This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove obsolete notes and TODOs from feature.pm
[perl5.git] / perl.c
diff --git a/perl.c b/perl.c
index 9cb183d..f9cebf1 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -1,7 +1,7 @@
 /*    perl.c
  *
  *    Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- *    2000, 2001, 2002, 2003, 2004, 2005, 2006, by Larry Wall and others
+ *    2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 by Larry Wall and others
  *
  *    You may distribute under the terms of either the GNU General Public
  *    License or the Artistic License, as specified in the README file.
@@ -792,19 +792,6 @@ perl_destruct(pTHXx)
     PL_exitlist = NULL;
     PL_exitlistlen = 0;
 
-    if (destruct_level == 0){
-
-       DEBUG_P(debprofdump());
-
-#if defined(PERLIO_LAYERS)
-       /* No more IO - including error messages ! */
-       PerlIO_cleanup(aTHX);
-#endif
-
-       /* The exit() function will do everything that needs doing. */
-        return STATUS_EXIT;
-    }
-
     /* jettison our possibly duplicated environment */
     /* if PERL_USE_SAFE_PUTENV is defined environ will not have been copied
      * so we certainly shouldn't free it here
@@ -831,6 +818,22 @@ perl_destruct(pTHXx)
 #endif
 #endif /* !PERL_MICRO */
 
+    if (destruct_level == 0) {
+
+       DEBUG_P(debprofdump());
+
+#if defined(PERLIO_LAYERS)
+       /* No more IO - including error messages ! */
+       PerlIO_cleanup(aTHX);
+#endif
+
+       CopFILE_free(&PL_compiling);
+       CopSTASH_free(&PL_compiling);
+
+       /* The exit() function will do everything that needs doing. */
+        return STATUS_EXIT;
+    }
+
     /* reset so print() ends up where we expect */
     setdefout(NULL);
 
@@ -1199,7 +1202,7 @@ perl_destruct(pTHXx)
                        " flags=0x%"UVxf
                        " refcnt=%"UVuf pTHX__FORMAT "\n"
                        "\tallocated at %s:%d %s %s%s\n",
-                       sv, sv->sv_flags, sv->sv_refcnt pTHX__VALUE,
+                       (void*)sv, sv->sv_flags, sv->sv_refcnt pTHX__VALUE,
                        sv->sv_debug_file ? sv->sv_debug_file : "(unknown)",
                        sv->sv_debug_line,
                        sv->sv_debug_inpad ? "for" : "by",
@@ -1544,11 +1547,7 @@ setuid perl scripts securely.\n");
         }
         /* Can we grab env area too to be used as the area for $0? */
         if (s && PL_origenviron) {
-             if ((PL_origenviron[0] == s + 1
-#ifdef OS2
-                  || (PL_origenviron[0] == s + 9 && (s += 8))
-#endif 
-                 )
+             if ((PL_origenviron[0] == s + 1)
                  ||
                  (aligned &&
                   (PL_origenviron[0] >  s &&
@@ -1556,7 +1555,7 @@ setuid perl scripts securely.\n");
                    INT2PTR(char *, PTR2UV(s + PTRSIZE) & mask)))
                 )
              {
-#ifndef OS2
+#ifndef OS2            /* ENVIRON is read by the kernel too. */
                   s = PL_origenviron[0];
                   while (*s) s++;
 #endif
@@ -1654,7 +1653,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
     VOL bool dosearch = FALSE;
     const char *validarg = "";
     register SV *sv;
-    register char *s;
+    register char *s, c;
     const char *cddir = NULL;
 #ifdef USE_SITECUSTOMIZE
     bool minus_f = FALSE;
@@ -1682,7 +1681,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
 #endif
        s = argv[0]+1;
       reswitch:
-       switch (*s) {
+       switch ((c = *s)) {
        case 'C':
 #ifndef PERL_STRICT_CR
        case '\r':
@@ -1749,7 +1748,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
                argc--,argv++;
            }
            else
-               Perl_croak(aTHX_ "No code specified for -%c", *s);
+               Perl_croak(aTHX_ "No code specified for -%c", c);
            sv_catpvs(PL_e_script, "\n");
            break;
 
@@ -2062,11 +2061,6 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
     }
 #endif
 
-    if (PL_taint_warn && PL_dowarn != G_WARN_ALL_OFF) {
-        PL_compiling.cop_warnings
-           = Perl_new_warnings_bitfield(aTHX_ NULL, WARN_TAINTstring, WARNsize);
-    }
-
     if (!scriptname)
        scriptname = argv[0];
     if (PL_e_script) {
@@ -3275,13 +3269,13 @@ Perl_moreswitches(pTHX_ char *s)
                          " DEVEL" STRINGIFY(PERL_PATCHNUM)
 #endif
                          " built for %s",
-                         (void*)vstringify(PL_patchlevel),
+                         SVfARG(vstringify(PL_patchlevel)),
                          ARCHNAME));
 #else /* DGUX */
 /* Adjust verbose output as in the perl that ships with the DG/UX OS from EMC */
        PerlIO_printf(PerlIO_stdout(),
                Perl_form(aTHX_ "\nThis is perl, %"SVf"\n",
-                   vstringify(PL_patchlevel)));
+                   SVfARG(vstringify(PL_patchlevel))));
        PerlIO_printf(PerlIO_stdout(),
                        Perl_form(aTHX_ "        built under %s at %s %s\n",
                                        OSNAME, __DATE__, __TIME__));
@@ -3300,7 +3294,7 @@ Perl_moreswitches(pTHX_ char *s)
 #endif
 
        PerlIO_printf(PerlIO_stdout(),
-                     "\n\nCopyright 1987-2006, Larry Wall\n");
+                     "\n\nCopyright 1987-2007, Larry Wall\n");
 #ifdef MACOS_TRADITIONAL
        PerlIO_printf(PerlIO_stdout(),
                      "\nMac OS port Copyright 1991-2002, Matthias Neeracher;\n"
@@ -3377,8 +3371,9 @@ this system using \"man perl\" or \"perldoc perl\".  If you have access to the\n
 Internet, point your browser at http://www.perl.org/, the Perl Home Page.\n\n");
        my_exit(0);
     case 'w':
-       if (! (PL_dowarn & G_WARN_ALL_MASK))
+       if (! (PL_dowarn & G_WARN_ALL_MASK)) {
            PL_dowarn |= G_WARN_ON;
+       }
        s++;
        return s;
     case 'W':
@@ -3680,8 +3675,8 @@ S_open_script(pTHX_ const char *scriptname, bool dosearch, SV *sv,
 
         Perl_sv_setpvf(aTHX_ cmd, "\
 %s -ne%s%s%s %s | %"SVf" %s %"SVf" %s",
-                       perl, quote, code, quote, scriptname, (void*)cpp,
-                       cpp_discard_flag, (void*)sv, CPPMINUS);
+                       perl, quote, code, quote, scriptname, SVfARG(cpp),
+                       cpp_discard_flag, SVfARG(sv), CPPMINUS);
 
        PL_doextract = FALSE;
 
@@ -4654,6 +4649,7 @@ S_init_postdump_symbols(pTHX_ register int argc, register char **argv, register
     }
     if ((PL_envgv = gv_fetchpvs("ENV", GV_ADD|GV_NOTQUAL, SVt_PVHV))) {
        HV *hv;
+       bool env_is_not_environ;
        GvMULTI_on(PL_envgv);
        hv = GvHVn(PL_envgv);
        hv_magic(hv, NULL, PERL_MAGIC_env);
@@ -4666,7 +4662,8 @@ S_init_postdump_symbols(pTHX_ register int argc, register char **argv, register
        */
        if (!env)
            env = environ;
-       if (env != environ
+       env_is_not_environ = env != environ;
+       if (env_is_not_environ
 #  ifdef USE_ITHREADS
            && PL_curinterp == aTHX
 #  endif
@@ -4688,7 +4685,7 @@ S_init_postdump_symbols(pTHX_ register int argc, register char **argv, register
 #endif
            sv = newSVpv(s+1, 0);
            (void)hv_store(hv, *env, s - *env, sv, 0);
-           if (env != environ)
+           if (env_is_not_environ)
                mg_set(sv);
            if (origenv != environ) {
              /* realloc has shifted us */
@@ -5060,21 +5057,21 @@ S_incpush(pTHX_ const char *dir, bool addsubdirs, bool addoldvers, bool usesep,
 #endif
                /* .../version/archname if -d .../version/archname */
                Perl_sv_setpvf(aTHX_ subdir, "%"SVf PERL_ARCH_FMT_PATH PERL_ARCH_FMT,
-                              (void*)libdir,
+                              SVfARG(libdir),
                               (int)PERL_REVISION, (int)PERL_VERSION,
                               (int)PERL_SUBVERSION, ARCHNAME);
                subdir = S_incpush_if_exists(aTHX_ subdir);
 
                /* .../version if -d .../version */
                Perl_sv_setpvf(aTHX_ subdir, "%"SVf PERL_ARCH_FMT_PATH,
-                              (void*)libdir,
+                              SVfARG(libdir),
                               (int)PERL_REVISION, (int)PERL_VERSION,
                               (int)PERL_SUBVERSION);
                subdir = S_incpush_if_exists(aTHX_ subdir);
 
                /* .../archname if -d .../archname */
                Perl_sv_setpvf(aTHX_ subdir, "%"SVf PERL_ARCH_FMT,
-                              (void*)libdir, ARCHNAME);
+                              SVfARG(libdir), ARCHNAME);
                subdir = S_incpush_if_exists(aTHX_ subdir);
 
            }
@@ -5083,7 +5080,8 @@ S_incpush(pTHX_ const char *dir, bool addsubdirs, bool addoldvers, bool usesep,
            if (addoldvers) {
                for (incver = incverlist; *incver; incver++) {
                    /* .../xxx if -d .../xxx */
-                   Perl_sv_setpvf(aTHX_ subdir, "%"SVf PERL_ARCH_FMT, (void *)libdir, *incver);
+                   Perl_sv_setpvf(aTHX_ subdir, "%"SVf PERL_ARCH_FMT,
+                                  SVfARG(libdir), *incver);
                    subdir = S_incpush_if_exists(aTHX_ subdir);
                }
            }
@@ -5167,7 +5165,7 @@ Perl_call_list(pTHX_ I32 oldscope, AV *paramList)
                while (PL_scopestack_ix > oldscope)
                    LEAVE;
                JMPENV_POP;
-               Perl_croak(aTHX_ "%"SVf"", (void*)atsv);
+               Perl_croak(aTHX_ "%"SVf"", SVfARG(atsv));
            }
            break;
        case 1:
@@ -5215,7 +5213,7 @@ Perl_my_exit(pTHX_ U32 status)
 {
     dVAR;
     DEBUG_S(PerlIO_printf(Perl_debug_log, "my_exit: thread %p, status %lu\n",
-                         thr, (unsigned long) status));
+                         (void*)thr, (unsigned long) status));
     switch (status) {
     case 0:
        STATUS_ALL_SUCCESS;