Mercurial > octave
changeset 3018:5708b8bb4f06
[project @ 1997-06-03 21:48:05 by jwe]
author | jwe |
---|---|
date | Tue, 03 Jun 1997 21:57:33 +0000 |
parents | d7edf1442471 |
children | 92aa3d651723 |
files | src/error.cc src/error.h src/help.cc src/oct-hist.cc src/oct-hist.h src/ov.cc src/pager.cc src/pr-output.cc src/pt-check.cc src/pt-except.cc src/pt-pr-code.cc src/sighandlers.cc src/sighandlers.h src/unwind-prot.cc |
diffstat | 14 files changed, 79 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/src/error.cc Tue Jun 03 17:15:39 1997 +0000 +++ b/src/error.cc Tue Jun 03 21:57:33 1997 +0000 @@ -49,7 +49,7 @@ // Tell the error handler whether to print messages, or just store // them for later. Used for handling errors in eval() and // the `unwind_protect' statement. -int buffer_error_messages; +bool buffer_error_messages; // The message buffer ostrstream *error_message_buffer = 0; @@ -279,6 +279,31 @@ return handle_message (usage, "unknown", args); } +void +bind_global_error_variable (void) +{ + *error_message_buffer << ends; + + char *error_text = error_message_buffer->str (); + + bind_builtin_variable ("__error_text__", error_text, 1); + + delete [] error_text; + + delete error_message_buffer; + + error_message_buffer = 0; +} + +void +clear_global_error_variable (void *) +{ + delete error_message_buffer; + error_message_buffer = 0; + + bind_builtin_variable ("__error_text__", "", 1); +} + static int beep_on_error (void) { @@ -292,6 +317,13 @@ { DEFVAR (beep_on_error, 0.0, 0, beep_on_error, "if true, beep before printing error messages"); + + DEFCONST (error_text, "", 0, 0, + "the text of error messages that would have been printed in the\n\ +body of the most recent unwind_protect statement or the TRY part of\n\ +the most recent eval() command. Outside of unwind_protect and\n\ +eval(), or if no error has ocurred within them, the value of\n\ +__error_text__ is guaranteed to be the empty string."); } /*
--- a/src/error.h Tue Jun 03 17:15:39 1997 +0000 +++ b/src/error.h Tue Jun 03 21:57:33 1997 +0000 @@ -42,7 +42,7 @@ // Tell the error handler whether to print messages, or just store // them for later. Used for handling errors in eval() and // the `unwind_protect' statement. -extern int buffer_error_messages; +extern bool buffer_error_messages; // The message buffer extern ostrstream *error_message_buffer;
--- a/src/help.cc Tue Jun 03 17:15:39 1997 +0000 +++ b/src/help.cc Tue Jun 03 21:57:33 1997 +0000 @@ -55,6 +55,7 @@ #include "oct-obj.h" #include "ov-usr-fcn.h" #include "pager.h" +#include "parse.h" #include "pathsearch.h" #include "pt-pr-code.h" #include "sighandlers.h"
--- a/src/oct-hist.cc Tue Jun 03 17:15:39 1997 +0000 +++ b/src/oct-hist.cc Tue Jun 03 21:57:33 1997 +0000 @@ -64,6 +64,7 @@ #include "oct-hist.h" #include "oct-obj.h" #include "pager.h" +#include "parse.h" #include "sighandlers.h" #include "sysdep.h" #include "toplev.h" @@ -71,8 +72,8 @@ #include "utils.h" #include "variables.h" -// Nonzero means input is coming from temporary history file. -int input_from_tmp_history_file = 0; +// TRUE means input is coming from temporary history file. +bool input_from_tmp_history_file = false; // Where history is saved. static string Vhistory_file; @@ -81,7 +82,7 @@ static int Vhistory_size; // TRUE if we are saving history. -int Vsaving_history; +bool Vsaving_history = true; // Get some default values, possibly reading them from the // environment. @@ -485,10 +486,12 @@ // sense. unwind_protect::begin_frame ("do_edit_history"); + unwind_protect_int (Vecho_executing_commands); - unwind_protect_int (input_from_tmp_history_file); + unwind_protect_bool (input_from_tmp_history_file); + Vecho_executing_commands = ECHO_CMD_LINE; - input_from_tmp_history_file = 1; + input_from_tmp_history_file = true; parse_and_execute (name); @@ -512,10 +515,12 @@ // sense. unwind_protect::begin_frame ("do_run_history"); + unwind_protect_int (Vecho_executing_commands); - unwind_protect_int (input_from_tmp_history_file); + unwind_protect_bool (input_from_tmp_history_file); + Vecho_executing_commands = ECHO_CMD_LINE; - input_from_tmp_history_file = 1; + input_from_tmp_history_file = true; parse_and_execute (name);
--- a/src/oct-hist.h Tue Jun 03 17:15:39 1997 +0000 +++ b/src/oct-hist.h Tue Jun 03 21:57:33 1997 +0000 @@ -30,11 +30,11 @@ extern int default_history_size (void); extern string default_history_file (void); -// Nonzero means input is coming from temporary history file. -extern int input_from_tmp_history_file; +// TRUE means input is coming from temporary history file. +extern bool input_from_tmp_history_file; // TRUE if we are saving history. -extern int Vsaving_history; +extern bool Vsaving_history; #endif
--- a/src/ov.cc Tue Jun 03 17:15:39 1997 +0000 +++ b/src/ov.cc Tue Jun 03 21:57:33 1997 +0000 @@ -909,7 +909,7 @@ // Current indentation. int octave_value::curr_print_indent_level = 0; -// Nonzero means we are at the beginning of a line. +// TRUE means we are at the beginning of a line. bool octave_value::beginning_of_line = true; // Each print() function should call this before printing anything.
--- a/src/pager.cc Tue Jun 03 17:15:39 1997 +0000 +++ b/src/pager.cc Tue Jun 03 21:57:33 1997 +0000 @@ -51,8 +51,8 @@ // Our actual connection to the external pager. static oprocstream *external_pager = 0; -// Nonzero means we write to the diary file. -static int write_to_diary_file = 0; +// TRUE means we write to the diary file. +static bool write_to_diary_file = false; // The name of the current diary file. static string diary_file; @@ -77,9 +77,9 @@ static octave_interrupt_handler saved_interrupt_handler; static bool interrupt_handler_saved = false; -static int really_flush_to_pager = 0; +static bool really_flush_to_pager = false; -static int flushing_output_to_pager = 0; +static bool flushing_output_to_pager = false; static void clear_external_pager (void) @@ -306,11 +306,11 @@ { unwind_protect::begin_frame ("flush_octave_stdout"); - unwind_protect_int (really_flush_to_pager); - unwind_protect_int (flushing_output_to_pager); + unwind_protect_bool (really_flush_to_pager); + unwind_protect_bool (flushing_output_to_pager); - really_flush_to_pager = 1; - flushing_output_to_pager = 1; + really_flush_to_pager = true; + flushing_output_to_pager = true; octave_stdout.flush (); @@ -373,13 +373,13 @@ if (arg == "on") { - write_to_diary_file = 1; + write_to_diary_file = true; open_diary_file (); } else if (arg == "off") { close_diary_file (); - write_to_diary_file = 0; + write_to_diary_file = false; } else {
--- a/src/pr-output.cc Tue Jun 03 17:15:39 1997 +0000 +++ b/src/pr-output.cc Tue Jun 03 21:57:33 1997 +0000 @@ -77,28 +77,28 @@ // Current format string for the imaginary part of complex numbers. static char *curr_imag_fmt = 0; -// Nonzero means don't do any fancy formatting. +// TRUE means don't do any fancy formatting. static bool free_format = false; -// Nonzero means print plus sign for nonzero, blank for zero. +// TRUE means print plus sign for nonzero, blank for zero. static bool plus_format = false; -// Nonzero means always print like dollars and cents. +// TRUE means always print like dollars and cents. static bool bank_format = false; -// Nonzero means print data in hexadecimal format. +// TRUE means print data in hexadecimal format. static bool hex_format = false; -// Nonzero means print data in binary-bit-pattern format. +// TRUE means print data in binary-bit-pattern format. static int bit_format = 0; -// Nonzero means don't put newlines around the column number headers. +// TRUE means don't put newlines around the column number headers. static bool compact_format = false; -// Nonzero means use an e format. +// TRUE means use an e format. static bool print_e = false; -// Nonzero means print E instead of e for exponent field. +// TRUE means print E instead of e for exponent field. static bool print_big_e = false; // XXX FIXME XXX -- these should probably be somewhere else.
--- a/src/pt-check.cc Tue Jun 03 17:15:39 1997 +0000 +++ b/src/pt-check.cc Tue Jun 03 21:57:33 1997 +0000 @@ -165,7 +165,7 @@ { int len = lhs->length (); - if (len == 0 || lhs > 2) + if (len == 0 || len > 2) gripe ("invalid number of output arguments in for command", cmd.line ());
--- a/src/pt-except.cc Tue Jun 03 17:15:39 1997 +0000 +++ b/src/pt-except.cc Tue Jun 03 21:57:33 1997 +0000 @@ -56,7 +56,7 @@ // Set up for letting the user print any messages from errors that // occurred in the body of the try_catch statement. - buffer_error_messages = 0; + buffer_error_messages = false; bind_global_error_variable (); unwind_protect::add (clear_global_error_variable, 0); @@ -104,8 +104,8 @@ if (catch_code) { - unwind_protect_int (buffer_error_messages); - buffer_error_messages = 1; + unwind_protect_bool (buffer_error_messages); + buffer_error_messages = true; } if (try_code)
--- a/src/pt-pr-code.cc Tue Jun 03 17:15:39 1997 +0000 +++ b/src/pt-pr-code.cc Tue Jun 03 21:57:33 1997 +0000 @@ -1062,7 +1062,7 @@ // Current indentation. int tree_print_code::curr_print_indent_level = 0; -// Nonzero means we are at the beginning of a line. +// TRUE means we are at the beginning of a line. bool tree_print_code::beginning_of_line = true; // Each print_code() function should call this before printing
--- a/src/sighandlers.cc Tue Jun 03 17:15:39 1997 +0000 +++ b/src/sighandlers.cc Tue Jun 03 21:57:33 1997 +0000 @@ -50,8 +50,8 @@ // SIGPIPES. We assume that the writer will eventually give up. int pipe_handler_error_count = 0; -// Nonzero means we can be interrupted. -int can_interrupt = 0; +// TRUE means we can be interrupted. +bool can_interrupt = false; // Allow us to save the signal mask and then restore it to the most // recently saved value. This is necessary when using the POSIX
--- a/src/sighandlers.h Tue Jun 03 17:15:39 1997 +0000 +++ b/src/sighandlers.h Tue Jun 03 21:57:33 1997 +0000 @@ -83,8 +83,8 @@ // SIGPIPES. We assume that the writer will eventually give up. extern int pipe_handler_error_count; -// Nonzero means we can be interrupted. -extern int can_interrupt; +// TRUE means we can be interrupted. +extern bool can_interrupt; extern sig_handler *octave_set_signal_handler (int, sig_handler *);
--- a/src/unwind-prot.cc Tue Jun 03 17:15:39 1997 +0000 +++ b/src/unwind-prot.cc Tue Jun 03 21:57:33 1997 +0000 @@ -105,7 +105,7 @@ saved_variable::saved_variable (bool *p, bool v) { - type_tag = integer; + type_tag = boolean; ptr_to_bool = p; bool_value = v; size = sizeof (bool); // Is this necessary?