Mercurial > hg > octave-nkf
changeset 16115:4f6c37cfbdce
cleanup lexical_feedback objects
* lex.h (lexical_feedback::cleanup): New static member function.
* oct-parse.yy (eval_string, parse_fcn_file): Put new clenup function
on unwind-protect stack to delete lexer object.
* input.cc (get_debug_input): Likewise.
* toplev.cc (main_loop): Likewise.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 26 Feb 2013 10:58:33 -0500 |
parents | 73a21ade0b6b |
children | 67f71e2a6190 |
files | libinterp/interpfcn/input.cc libinterp/interpfcn/toplev.cc libinterp/parse-tree/lex.h libinterp/parse-tree/oct-parse.yy |
diffstat | 4 files changed, 8 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/interpfcn/input.cc +++ b/libinterp/interpfcn/input.cc @@ -680,6 +680,7 @@ frame.protect_var (curr_lexer); curr_lexer = new lexical_feedback (); + frame.add_fcn (lexical_feedback::cleanup, curr_lexer); while (Vdebugging) {
--- a/libinterp/interpfcn/toplev.cc +++ b/libinterp/interpfcn/toplev.cc @@ -561,6 +561,7 @@ frame.protect_var (curr_lexer); curr_lexer = new lexical_feedback (); + frame.add_fcn (lexical_feedback::cleanup, curr_lexer); // The big loop.
--- a/libinterp/parse-tree/lex.h +++ b/libinterp/parse-tree/lex.h @@ -377,6 +377,9 @@ // information. std::stack <token*> token_stack; + // For unwind protect. + static void cleanup (lexical_feedback *lexer) { delete lexer; } + private: // No copying!
--- a/libinterp/parse-tree/oct-parse.yy +++ b/libinterp/parse-tree/oct-parse.yy @@ -3500,8 +3500,8 @@ bool eof; frame.protect_var (curr_lexer); - curr_lexer = new lexical_feedback (); + frame.add_fcn (lexical_feedback::cleanup, curr_lexer); reset_parser (); @@ -4306,6 +4306,8 @@ unwind_protect frame; frame.protect_var (curr_lexer); + curr_lexer = new lexical_feedback (); + frame.add_fcn (lexical_feedback::cleanup, curr_lexer); frame.protect_var (get_input_from_eval_string); frame.protect_var (line_editing); @@ -4319,8 +4321,6 @@ frame.protect_var (reading_script_file); frame.protect_var (reading_classdef_file); - curr_lexer = new lexical_feedback (); - get_input_from_eval_string = true; line_editing = false; current_function_depth = 0;