Mercurial > hg > octave-avbm
changeset 2206:9be05ffc288a
[project @ 1996-05-15 07:32:58 by jwe]
author | jwe |
---|---|
date | Wed, 15 May 1996 07:35:42 +0000 |
parents | bd389b53befa |
children | 4cc4d8fb861a |
files | src/pager.cc src/sighandlers.cc |
diffstat | 2 files changed, 48 insertions(+), 48 deletions(-) [+] |
line wrap: on
line diff
--- a/src/pager.cc +++ b/src/pager.cc @@ -75,6 +75,8 @@ static int really_flush_to_pager = 0; +static int flushing_output_to_pager = 0; + static void clear_external_pager (void) { @@ -93,50 +95,47 @@ static void do_sync (const char *msg, bool bypass_pager) { - if (! error_state) + if (msg && *msg) { - if (msg && *msg) + if (bypass_pager) + cout << msg; + else { - if (bypass_pager) - cout << msg; - else + if (! external_pager) { - if (! external_pager) - { - string pgr = Vpager_binary; + string pgr = Vpager_binary; - if (! pgr.empty ()) - { - saved_sigint_handler - = octave_set_signal_handler (SIGINT, SIG_IGN); + if (! pgr.empty ()) + { + saved_sigint_handler + = octave_set_signal_handler (SIGINT, SIG_IGN); - external_pager = new oprocstream (pgr.c_str ()); + external_pager = new oprocstream (pgr.c_str ()); - if (external_pager) - octave_pager_pid = external_pager->pid (); - } + if (external_pager) + octave_pager_pid = external_pager->pid (); } + } - if (external_pager) + if (external_pager) + { + if (octave_pager_pid > 0 && external_pager->good ()) { - if (octave_pager_pid > 0 && external_pager->good ()) - { - *external_pager << msg; + *external_pager << msg; - // These checks are needed if a signal handler - // invoked since the last set of checks attempts - // to flush output and then returns + // These checks are needed if a signal handler + // invoked since the last set of checks attempts + // to flush output and then returns - if (octave_pager_pid > 0 - && external_pager - && external_pager->good ()) - external_pager->flush (); - } - clear_external_pager (); + if (octave_pager_pid > 0 + && external_pager + && external_pager->good ()) + external_pager->flush (); } - else - cout << msg; + clear_external_pager (); } + else + cout << msg; } } } @@ -258,18 +257,23 @@ void flush_octave_stdout (void) { - begin_unwind_frame ("flush_octave_stdout"); + if (! flushing_output_to_pager) + { + begin_unwind_frame ("flush_octave_stdout"); - unwind_protect_int (really_flush_to_pager); - - really_flush_to_pager = 1; + unwind_protect_int (really_flush_to_pager); + unwind_protect_int (flushing_output_to_pager); - octave_stdout.flush (); + really_flush_to_pager = 1; + flushing_output_to_pager = 1; + + octave_stdout.flush (); - if (external_pager) - clear_external_pager (); + if (external_pager) + clear_external_pager (); - run_unwind_frame ("flush_octave_stdout"); + run_unwind_frame ("flush_octave_stdout"); + } } static void
--- a/src/sighandlers.cc +++ b/src/sighandlers.cc @@ -157,15 +157,11 @@ { octave_pager_pid = -1; - // XXX FIXME XXX -- I'm not sure that this is the right - // thing to do here, but it seems to work. + // Don't call error() here because we don't want to set + // the error state. - // Don't call error() here because that tries to flush - // pending output, which isn't going to do anything - // anyway. - - cerr << "error: connection to external pager lost --\n"; - cerr << "error: pending computations and output have been discarded\n"; + warning ("connection to external pager lost --"); + warning ("pending computations and output have been discarded"); } } } @@ -228,7 +224,7 @@ octave_set_signal_handler (SIGPIPE, sigpipe_handler); if (pipe_handler_error_count++ == 0) - message (0, "broken pipe"); + warning ("broken pipe"); // Don't loop forever on account of this.