summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Mitchell <davem@fdisolutions.com>2007-04-01 01:27:57 +0000
committerDave Mitchell <davem@fdisolutions.com>2007-04-01 01:27:57 +0000
commite3abe207f764929a97eafa503a3780d5b7636ed2 (patch)
tree84f144eb96d5794911b2fc5ef5487e419f76caf9
parent90e3715fae5c61e6e1833dc9ad520176419400f4 (diff)
downloadperl-e3abe207f764929a97eafa503a3780d5b7636ed2.tar.gz
Make parser_free() be called slightly later,
i.e. at the point where lexer vars are being restored in a LEAVE, rather than at the end of yyparse() p4raw-id: //depot/perl@30822
-rw-r--r--perly.c20
-rw-r--r--toke.c20
2 files changed, 21 insertions, 19 deletions
diff --git a/perly.c b/perly.c
index c8ee62ffc6..95779a014d 100644
--- a/perly.c
+++ b/perly.c
@@ -306,20 +306,6 @@ S_clear_yystack(pTHX_ const yy_parser *parser)
}
}
-/* delete a parser object */
-
-#ifndef PERL_IN_MADLY_C
-void
-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
/*----------.
| yyparse. |
@@ -362,8 +348,8 @@ Perl_yyparse (pTHX)
parser = PL_parser;
ps = parser->ps;
- ENTER; /* force parser free before we return */
- SAVEPARSER(parser);
+ ENTER; /* force parser stack cleanup before we return */
+ SAVEDESTRUCTOR_X(S_clear_yystack, parser);
/*------------------------------------------------------------.
| yynewstate -- Push a new state, which is found in yystate. |
@@ -691,7 +677,7 @@ Perl_yyparse (pTHX)
goto yyreturn;
yyreturn:
- LEAVE; /* force parser free before we return */
+ LEAVE; /* force parser stack cleanup before we return */
return yyresult;
}
diff --git a/toke.c b/toke.c
index a9e3d880a0..d11cdcc9b8 100644
--- a/toke.c
+++ b/toke.c
@@ -615,8 +615,7 @@ S_cr_textfilter(pTHX_ int idx, SV *sv, int maxlen)
/*
* Perl_lex_start
- * Initialize variables. Uses the Perl save_stack to save its state (for
- * recursive calls to the parser).
+ * Create a parser object and initialise its parser and lexer fields
*/
void
@@ -641,6 +640,9 @@ Perl_lex_start(pTHX_ SV *line)
parser->yyerrstatus = 0;
parser->yychar = YYEMPTY; /* Cause a token to be read. */
+ /* on scope exit, free this parser and restore any outer one */
+ SAVEPARSER(parser);
+
/* initialise lexer state */
SAVEI32(PL_lex_state);
@@ -713,6 +715,20 @@ Perl_lex_start(pTHX_ SV *line)
PL_rsfp = 0;
}
+
+/* delete a parser object */
+
+void
+Perl_parser_free(pTHX_ const yy_parser *parser)
+{
+ Safefree(parser->stack);
+ Safefree(parser->lex_brackstack);
+ Safefree(parser->lex_casestack);
+ PL_parser = parser->old_parser;
+ Safefree(parser);
+}
+
+
/*
* Perl_lex_end
* Finalizer for lexing operations. Must be called when the parser is