Mercurial > hg > octave-terminal
changeset 3490:fc5eac74640d
[project @ 2000-01-28 10:13:25 by jwe]
author | jwe |
---|---|
date | Fri, 28 Jan 2000 10:13:26 +0000 |
parents | cbee5fbb696d |
children | 2c7524ffdbf5 |
files | src/ChangeLog src/error.cc src/pt-except.cc |
diffstat | 3 files changed, 37 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,16 @@ 2000-01-28 John W. Eaton <jwe@bevo.che.wisc.edu> + * pt-except.cc (do_catch_code): Unwind-protect buffer_error_messages. + Be sure to run all unwind-protects before returning. + (tree_try_catch_command::eval): Add do_catch_code cleanup function + to unwind-protect stack before resetting buffer_error_messages. + Use unwind-protect to save and restore buffer_error_messages. + If there is no catch code, discard the cleanup function and run + the unwind-protect for buffer_error_messages. + + * error.cc (bind_global_error_variable): Avoid dereferencing + error_message_buffer if it is NULL. + * parse.y (evaluating_function_body): New global flag. * ov-usr-fcn.cc (octave_user_function::do_index_op): Protect and set it here.
--- a/src/error.cc +++ b/src/error.cc @@ -375,17 +375,22 @@ void bind_global_error_variable (void) { - *error_message_buffer << ends; + if (error_message_buffer) + { + *error_message_buffer << ends; - char *error_text = error_message_buffer->str (); + char *error_text = error_message_buffer->str (); - bind_builtin_constant ("__error_text__", error_text, true); + bind_builtin_constant ("__error_text__", error_text, true); - delete [] error_text; + delete [] error_text; + + delete error_message_buffer; - delete error_message_buffer; - - error_message_buffer = 0; + error_message_buffer = 0; + } + else + bind_builtin_constant ("__error_text__", "", true); } void
--- a/src/pt-except.cc +++ b/src/pt-except.cc @@ -53,11 +53,16 @@ { tree_statement_list *list = static_cast<tree_statement_list *> (ptr); + unwind_protect::begin_frame ("do_catch_code"); + // Set up for letting the user print any messages from errors that // occurred in the body of the try_catch statement. + unwind_protect_bool (buffer_error_messages); buffer_error_messages = false; + bind_global_error_variable (); + unwind_protect::add (clear_global_error_variable, 0); // Similarly, if we have seen a return or break statement, allow all @@ -92,7 +97,7 @@ else unwind_protect::run (); - unwind_protect::run (); + unwind_protect::run_frame ("do_catch_code"); } void @@ -100,16 +105,14 @@ { unwind_protect::begin_frame ("tree_try_catch::eval"); - unwind_protect::add (do_catch_code, catch_code); - - bool old_buffer_error_messages = buffer_error_messages; - if (catch_code) { unwind_protect_bool (buffer_error_messages); buffer_error_messages = true; } + unwind_protect::add (do_catch_code, catch_code); + if (try_code) try_code->eval (); @@ -121,8 +124,12 @@ else { error_state = 0; - buffer_error_messages = old_buffer_error_messages; - unwind_protect::discard_frame ("tree_try_catch::eval"); + + // For clearing the do_catch_code cleanup function. + unwind_protect::discard (); + + // For restoring buffer_error_messages. + unwind_protect::run (); } }