X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl.c;h=a98314b49efeacd71f1651aec9ebd436cc69c3bc;hb=7087a21c096179886f18cec5311cc7e897850eef;hp=d8077d6027a9aa30b6b183e0731dcd9626b2d636;hpb=95a2b409a511e1c8014f7610e7fa60a947660625;p=p5sagit%2Fp5-mst-13.2.git diff --git a/perl.c b/perl.c index d8077d6..a98314b 100644 --- a/perl.c +++ b/perl.c @@ -389,6 +389,10 @@ perl_construct(pTHXx) PL_timesbase.tms_cstime = 0; #endif +#ifdef PERL_MAD + PL_curforce = -1; +#endif + ENTER; } @@ -895,7 +899,6 @@ perl_destruct(pTHXx) SvREFCNT_dec(PL_rs); /* $/ */ PL_rs = NULL; - PL_multiline = 0; /* $* */ Safefree(PL_osname); /* $^O */ PL_osname = NULL; @@ -1289,10 +1292,19 @@ void perl_free(pTHXx) { #ifdef PERL_TRACK_MEMPOOL - /* Emulate the PerlHost behaviour of free()ing all memory allocated in this - thread at thread exit. */ - while(aTHXx->Imemory_debug_header.next != &(aTHXx->Imemory_debug_header)) - safesysfree(sTHX + (char *)(aTHXx->Imemory_debug_header.next)); + { + /* + * Don't free thread memory if PERL_DESTRUCT_LEVEL is set to a non-zero + * value as we're probably hunting memory leaks then + */ + const char * const s = PerlEnv_getenv("PERL_DESTRUCT_LEVEL"); + if (!s || atoi(s) == 0) { + /* Emulate the PerlHost behaviour of free()ing all memory allocated in this + thread at thread exit. */ + while(aTHXx->Imemory_debug_header.next != &(aTHXx->Imemory_debug_header)) + safesysfree(sTHX + (char *)(aTHXx->Imemory_debug_header.next)); + } + } #endif #if defined(WIN32) || defined(NETWARE) @@ -1791,6 +1803,9 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit) # ifdef PERL_IMPLICIT_SYS " PERL_IMPLICIT_SYS" # endif +# ifdef PERL_MAD + " PERL_MAD" +# endif # ifdef PERL_MALLOC_WRAP " PERL_MALLOC_WRAP" # endif @@ -2164,6 +2179,25 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit) Perl_croak(aTHX_ "PERL_SIGNALS illegal: \"%s\"", s); } +#ifdef PERL_MAD + if ((s = PerlEnv_getenv("PERL_XMLDUMP"))) { + PL_madskills = 1; + PL_minus_c = 1; + if (!s || !s[0]) + PL_xmlfp = PerlIO_stdout(); + else { + PL_xmlfp = PerlIO_open(s, "w"); + if (!PL_xmlfp) + Perl_croak(aTHX_ "Can't open %s", s); + } + my_setenv("PERL_XMLDUMP", Nullch); /* hide from subprocs */ + } + if ((s = PerlEnv_getenv("PERL_MADSKILLS"))) { + PL_madskills = atoi(s); + my_setenv("PERL_MADSKILLS", Nullch); /* hide from subprocs */ + } +#endif + init_lexer(); /* now parse the script */ @@ -2289,6 +2323,12 @@ S_run_body(pTHX_ I32 oldscope) PL_sawampersand ? "Enabling" : "Omitting")); if (!PL_restartop) { +#ifdef PERL_MAD + if (PL_xmlfp) { + xmldump_all(); + exit(0); /* less likely to core dump than my_exit(0) */ + } +#endif DEBUG_x(dump_all()); #ifdef DEBUGGING if (!DEBUG_q_TEST) @@ -2998,8 +3038,7 @@ Perl_moreswitches(pTHX_ char *s) PL_minus_F = TRUE; PL_splitstr = ++s; while (*s && !isSPACE(*s)) ++s; - *s = '\0'; - PL_splitstr = savepv(PL_splitstr); + PL_splitstr = savepvn(PL_splitstr, s - PL_splitstr); return s; case 'a': PL_minus_a = TRUE; @@ -3068,13 +3107,17 @@ Perl_moreswitches(pTHX_ char *s) return s+1; } #endif /* __CYGWIN__ */ - PL_inplace = savepv(s+1); - for (s = PL_inplace; *s && !isSPACE(*s); s++) - ; + { + const char *start = ++s; + while (*s && !isSPACE(*s)) + ++s; + + PL_inplace = savepvn(start, s - start); + } if (*s) { - *s++ = '\0'; + ++s; if (*s == '-') /* Additional switches on #! line. */ - s++; + s++; } return s; case 'I': /* -I handled both here and in parse_body() */ @@ -5080,14 +5123,25 @@ Perl_call_list(pTHX_ I32 oldscope, AV *paramList) av_push(PL_checkav_save, (SV*)cv); } } else { - SAVEFREESV(cv); + if (!PL_madskills) + SAVEFREESV(cv); } JMPENV_PUSH(ret); switch (ret) { case 0: +#ifdef PERL_MAD + if (PL_madskills) + PL_madskills |= 16384; +#endif call_list_body(cv); +#ifdef PERL_MAD + if (PL_madskills) + PL_madskills &= ~16384; +#endif atsv = ERRSV; (void)SvPV_const(atsv, len); + if (PL_madskills && PL_minus_c && paramList == PL_beginav) + break; /* not really trying to run, so just wing it */ if (len) { PL_curcop = &PL_compiling; CopLINE_set(PL_curcop, oldline); @@ -5117,6 +5171,8 @@ Perl_call_list(pTHX_ I32 oldscope, AV *paramList) PL_curcop = &PL_compiling; CopLINE_set(PL_curcop, oldline); JMPENV_POP; + if (PL_madskills && PL_minus_c && paramList == PL_beginav) + return; /* not really trying to run, so just wing it */ if (PL_statusvalue && !(PL_exit_flags & PERL_EXIT_EXPECTED)) { if (paramList == PL_beginav) Perl_croak(aTHX_ "BEGIN failed--compilation aborted");