X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=perly.c;h=c8ee62ffc62dfcd4f5a7079f97775fa70562b6e8;hb=29469fa673ae2b707c0e65eb6190f2fab11938b1;hp=8ce76abf7a54df36e5eb6d19e6bd85b21ac56572;hpb=7c197c94dc644853d0512a443fd0e99a5f287ad0;p=p5sagit%2Fp5-mst-13.2.git diff --git a/perly.c b/perly.c index 8ce76ab..c8ee62f 100644 --- a/perly.c +++ b/perly.c @@ -111,7 +111,7 @@ yy_stack_print (pTHX_ const yy_parser *parser) PerlIO_printf(Perl_debug_log, "\nindex:"); for (ps = min; ps <= parser->ps; ps++) - PerlIO_printf(Perl_debug_log, " %8d", ps - parser->stack); + PerlIO_printf(Perl_debug_log, " %8d", (int)(ps - parser->stack)); PerlIO_printf(Perl_debug_log, "\nstate:"); for (ps = min; ps <= parser->ps; ps++) @@ -258,8 +258,17 @@ S_clear_yystack(pTHX_ const yy_parser *parser) * * a CV * but this would involve reworking all code (core and external) that * manipulate op trees. - */ + * + * XXX DAPM 17/1/07 I've decided its too fragile for now, and so have + * disabled it */ + +#define DISABLE_STACK_FREE + +#ifdef DISABLE_STACK_FREE + ps -= parser->yylen; + PERL_UNUSED_VAR(i); +#else /* clear any reducing ops (1st pass) */ for (i=0; i< parser->yylen; i++) { @@ -275,6 +284,7 @@ S_clear_yystack(pTHX_ const yy_parser *parser) } } } +#endif /* now free whole the stack, including the just-reduced ops */ @@ -286,8 +296,10 @@ S_clear_yystack(pTHX_ const yy_parser *parser) PAD_RESTORE_LOCAL(ps->comppad); } YYDPRINTF ((Perl_debug_log, "(freeing op)\n")); +#ifndef DISABLE_STACK_FREE ps->val.opval->op_latefree = 0; if (!(ps->val.opval->op_attached && !ps->val.opval->op_latefreed)) +#endif op_free(ps->val.opval); } ps--; @@ -302,7 +314,10 @@ Perl_parser_free(pTHX_ const yy_parser *parser) { S_clear_yystack(aTHX_ parser); Safefree(parser->stack); + Safefree(parser->lex_brackstack); + Safefree(parser->lex_casestack); PL_parser = parser->old_parser; + Safefree(parser); } #endif @@ -359,10 +374,12 @@ Perl_yyparse (pTHX) YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate)); +#ifndef DISABLE_STACK_FREE if (yy_type_tab[yystos[yystate]] == toketype_opval && ps->val.opval) { ps->val.opval->op_latefree = 1; ps->val.opval->op_latefreed = 0; } +#endif parser->yylen = 0; @@ -372,7 +389,7 @@ Perl_yyparse (pTHX) /* grow the stack? We always leave 1 spare slot, * in case of a '' -> 'foo' reduction */ - if (size >= parser->stack_size - 1) { + if (size >= (size_t)parser->stack_size - 1) { /* this will croak on insufficient memory */ parser->stack_size *= 2; Renew(parser->stack, parser->stack_size, yy_stack_frame); @@ -519,6 +536,7 @@ Perl_yyparse (pTHX) } +#ifndef DISABLE_STACK_FREE /* any just-reduced ops with the op_latefreed flag cleared need to be * freed; the rest need the flag resetting */ { @@ -533,6 +551,7 @@ Perl_yyparse (pTHX) } } } +#endif parser->ps = ps -= (parser->yylen-1);