Mercurial > hg > octave-terminal
changeset 4182:4d1d7c51205c
[project @ 2002-11-15 20:33:47 by jwe]
author | jwe |
---|---|
date | Fri, 15 Nov 2002 20:33:47 +0000 |
parents | dd2abf428f5d |
children | 4427d432e220 |
files | ChangeLog configure.in libcruft/ChangeLog libcruft/misc/f77-fcn.h libcruft/misc/quit.cc libcruft/misc/quit.h src/ChangeLog src/lex.h src/sighandlers.cc src/toplev.cc src/utils.cc |
diffstat | 11 files changed, 50 insertions(+), 95 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2002-11-15 John W. Eaton <jwe@bevo.che.wisc.edu> + + * configure.in (USE_EXCEPTIONS_FOR_INTERRUPTS): No need to define. + 2002-11-14 John W. Eaton <jwe@bevo.che.wisc.edu> * configure.in: Check for sigsetjmp and siglongjmp.
--- a/configure.in +++ b/configure.in @@ -22,7 +22,7 @@ ### 02111-1307, USA. AC_INIT -AC_REVISION($Revision: 1.389 $) +AC_REVISION($Revision: 1.390 $) AC_PREREQ(2.52) AC_CONFIG_SRCDIR([src/octave.cc]) AC_CONFIG_HEADER(config.h) @@ -1332,8 +1332,6 @@ #define OCTAVE_USE_WINDOWS_API 1 #endif -#define USE_EXCEPTIONS_FOR_INTERRUPTS 1 - /* sigsetjmp is a macro, not a function. */ #if defined (sigsetjmp) && defined (HAVE_SIGLONGJMP) #define OCTAVE_HAVE_SIG_JUMP
--- a/libcruft/ChangeLog +++ b/libcruft/ChangeLog @@ -1,3 +1,16 @@ +2002-11-15 John W. Eaton <jwe@bevo.che.wisc.edu> + + * misc/quit.h, misc/quit.cc [! USE_EXCEPTIONS_FOR_INTERRUPTS]): + Always use exceptions for handling interrupts. + (BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE): + + * misc/quit.h (OCTAVE_TRY_WITH_INTERRUPTS, OCTAVE_THROW_BAD_ALLOC, + OCTAVE_CATCH_INTERRUPTS, SAVE_OCTAVE_INTERRUPT_IMMEDIATELY, + INCREMENT_OCTAVE_INTERRUPT_IMMEDIATELY, OCTAVE_THROW_TO_TOP_LEVEL, + DECREMENT_OCTAVE_INTERRUPT_IMMEDIATELY, OCTAVE_JUMP_TO_TOP_LEVEL, + SET_OCTAVE_INTERRUPT_IMMEDIATELY): Replace all uses with + definitions, delete macros. + 2002-11-14 John W. Eaton <jwe@bevo.che.wisc.edu> * misc/quit.cc (octave_allocation_error): New variable.
--- a/libcruft/misc/f77-fcn.h +++ b/libcruft/misc/f77-fcn.h @@ -51,7 +51,7 @@ #define F77_XFCN(f, F, args) \ do \ { \ - jmp_buf saved_context; \ + octave_jmp_buf saved_context; \ f77_exception_encountered = 0; \ octave_save_current_context ((char *) saved_context); \ if (octave_set_current_context) \ @@ -60,15 +60,15 @@ if (f77_exception_encountered) \ F77_XFCN_ERROR (f, F); \ else if (octave_allocation_error) \ - OCTAVE_THROW_BAD_ALLOC; \ + octave_throw_bad_alloc (); \ else \ - OCTAVE_THROW_TO_TOP_LEVEL; \ + octave_throw_interrupt_exception (); \ } \ else \ { \ - INCREMENT_OCTAVE_INTERRUPT_IMMEDIATELY; \ + octave_interrupt_immediately++; \ F77_FUNC (f, F) args; \ - DECREMENT_OCTAVE_INTERRUPT_IMMEDIATELY; \ + octave_interrupt_immediately--; \ octave_restore_current_context ((char *) saved_context); \ } \ } \
--- a/libcruft/misc/quit.cc +++ b/libcruft/misc/quit.cc @@ -87,8 +87,6 @@ #endif } -#if defined (USE_EXCEPTIONS_FOR_INTERRUPTS) - sig_atomic_t octave_interrupt_immediately = 0; sig_atomic_t octave_interrupt_state = 0; @@ -107,8 +105,6 @@ throw std::bad_alloc (); } -#endif - /* ;;; Local Variables: *** ;;; mode: C++ ***
--- a/libcruft/misc/quit.h +++ b/libcruft/misc/quit.h @@ -58,8 +58,6 @@ extern void octave_restore_signal_mask (void); -#if defined (USE_EXCEPTIONS_FOR_INTERRUPTS) - #ifdef __cplusplus class octave_interrupt_exception @@ -88,106 +86,51 @@ } \ while (0) -#define OCTAVE_JUMP_TO_TOP_LEVEL \ - do { octave_interrupt_state = 1; } while (0) - -#define OCTAVE_THROW_TO_TOP_LEVEL octave_throw_interrupt_exception () - -#define OCTAVE_THROW_BAD_ALLOC octave_throw_bad_alloc () - -#define OCTAVE_TRY_WITH_INTERRUPTS try - -#define OCTAVE_CATCH_INTERRUPTS catch (octave_interrupt_exception) - -#define SAVE_OCTAVE_INTERRUPT_IMMEDIATELY(var) \ - sig_atomic_t var = octave_interrupt_immediately - -#define INCREMENT_OCTAVE_INTERRUPT_IMMEDIATELY \ - do { octave_interrupt_immediately++; } while (0) - -#define DECREMENT_OCTAVE_INTERRUPT_IMMEDIATELY \ - do { octave_interrupt_immediately--; } while (0) - -#define SET_OCTAVE_INTERRUPT_IMMEDIATELY(x) \ - do { octave_interrupt_immediately = x; } while (0) - #define BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE \ do \ { \ - jmp_buf saved_context; \ + octave_jmp_buf saved_context; \ \ octave_save_current_context ((char *) saved_context); \ \ if (octave_set_current_context) \ { \ octave_restore_current_context ((char *) saved_context); \ - OCTAVE_THROW_TO_TOP_LEVEL; \ + octave_throw_interrupt_exception (); \ } \ else \ { \ - INCREMENT_OCTAVE_INTERRUPT_IMMEDIATELY + octave_interrupt_immediately++ #define END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE \ - DECREMENT_OCTAVE_INTERRUPT_IMMEDIATELY; \ + octave_interrupt_immediately--; \ octave_restore_current_context ((char *) saved_context); \ } \ } \ while (0) #define BEGIN_INTERRUPT_WITH_EXCEPTIONS \ - SAVE_OCTAVE_INTERRUPT_IMMEDIATELY (saved_octave_interrupt_immediately); \ + sig_atomic_t saved_octave_interrupt_immediately = octave_interrupt_immediately; \ \ - OCTAVE_TRY_WITH_INTERRUPTS \ + try \ { \ - SET_OCTAVE_INTERRUPT_IMMEDIATELY (0) + octave_interrupt_immediately = 0; #define END_INTERRUPT_WITH_EXCEPTIONS \ } \ - OCTAVE_CATCH_INTERRUPTS \ + catch (octave_interrupt_exception) \ { \ - SET_OCTAVE_INTERRUPT_IMMEDIATELY (saved_octave_interrupt_immediately); \ + octave_interrupt_immediately = saved_octave_interrupt_immediately; \ octave_jump_to_enclosing_context (); \ } \ catch (std::bad_alloc) \ { \ - SET_OCTAVE_INTERRUPT_IMMEDIATELY (saved_octave_interrupt_immediately); \ + octave_interrupt_immediately = saved_octave_interrupt_immediately; \ octave_allocation_error = 1; \ octave_jump_to_enclosing_context (); \ } \ \ - SET_OCTAVE_INTERRUPT_IMMEDIATELY (saved_octave_interrupt_immediately) - -#else - -#define OCTAVE_QUIT do { } while (0) - -#define OCTAVE_JUMP_TO_TOP_LEVEL octave_jump_to_enclosing_context () - -#define OCTAVE_THROW_TO_TOP_LEVEL OCTAVE_JUMP_TO_TOP_LEVEL - -#define OCTAVE_THROW_BAD_ALLOC OCTAVE_JUMP_TO_TOP_LEVEL - -#define OCTAVE_TRY_WITH_INTERRUPTS - -#define OCTAVE_CATCH_INTERRUPTS if (0) - -#define SAVE_OCTAVE_INTERRUPT_IMMEDIATELY(var) do { } while (0) - -#define SET_OCTAVE_INTERRUPT_IMMEDIATELY(x) do { } while (0) - -#define INCREMENT_OCTAVE_INTERRUPT_IMMEDIATELY do { } while (0) - -#define DECREMENT_OCTAVE_INTERRUPT_IMMEDIATELY do { } while (0) - -#define BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE do { } while (0) - -#define END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE do { } while (0) - -#define BEGIN_INTERRUPT_WITH_EXCEPTIONS do { } while (0) - -#define END_INTERRUPT_WITH_EXCEPTIONS do { } while (0) - -#endif + octave_interrupt_immediately = saved_octave_interrupt_immediately #ifdef __cplusplus }
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2002-11-15 John W. Eaton <jwe@bevo.che.wisc.edu> + * lex.h (YY_FATAL_ERROR): Use OCTAVE_QUIT here. + + * utils.cc (toplevel): Delete variable. + * sighandlers.cc (OCTAVE_MEMORY_EXHAUSTED_ERROR): Delete. 2002-11-14 John W. Eaton <jwe@bevo.che.wisc.edu>
--- a/src/lex.h +++ b/src/lex.h @@ -43,7 +43,7 @@ do \ { \ error (msg); \ - OCTAVE_JUMP_TO_TOP_LEVEL; \ + OCTAVE_QUIT; \ yy_fatal_error (msg); \ } \ while (0)
--- a/src/sighandlers.cc +++ b/src/sighandlers.cc @@ -217,14 +217,11 @@ std::cerr << "error: floating point exception -- trying to return to prompt\n"; + // XXX FIXME XXX -- will setting octave_interrupt_state really help + // here? + if (can_interrupt) - { - // XXX FIXME XXX -- this may simply set the interrupt state. We - // can only hope for the best after returning? We probably need - // to throw an exception. - - OCTAVE_OCTAVE_JUMP_TO_TOP_LEVEL; - } + octave_interrupt_state = 1; SIGHANDLER_RETURN (0); } @@ -275,7 +272,7 @@ if (octave_interrupt_immediately) octave_jump_to_enclosing_context (); #else - OCTAVE_JUMP_TO_TOP_LEVEL; + octave_interrupt_state = 1; panic_impossible (); #endif } @@ -296,8 +293,11 @@ // Don't loop forever on account of this. + // XXX FIXME XXX -- will setting octave_interrupt_state really help + // here? + if (pipe_handler_error_count > 100) - OCTAVE_JUMP_TO_TOP_LEVEL; + octave_interrupt_state = 1; SIGHANDLER_RETURN (0); }
--- a/src/toplev.cc +++ b/src/toplev.cc @@ -95,7 +95,7 @@ { unwind_protect::run_all (); can_interrupt = true; - SET_OCTAVE_INTERRUPT_IMMEDIATELY (0); + octave_interrupt_immediately = 0; octave_interrupt_state = 0; octave_allocation_error = 0; octave_restore_signal_mask (); @@ -186,7 +186,7 @@ break; } } - OCTAVE_CATCH_INTERRUPTS + catch (octave_interrupt_exception) { recover_from_exception (); std::cout << "\n";