changeset 2554:f7e3d23f0a8f

[project @ 1996-11-21 01:41:57 by jwe]
author jwe
date Thu, 21 Nov 1996 01:43:06 +0000
parents f57c52dcd5ed
children 97abf5d72929
files ChangeLog NEWS doc/ChangeLog scripts/ChangeLog scripts/specfun/gammai.m src/ChangeLog src/help.cc src/oct-hist.cc src/pager.cc src/sighandlers.cc src/sighandlers.h src/toplev.cc test/ChangeLog
diffstat 13 files changed, 213 insertions(+), 52 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 Wed Nov 20 00:33:03 1996  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
+	* Version 1.93.
+
 	* aclocal.m4 (OCTAVE_STRUCT_GR_PASSWD): New macro.
 	* configure.in: Use it.
 	* acconfig.h (HAVE_GR_PASSWD): Add undef.
--- a/NEWS
+++ b/NEWS
@@ -167,6 +167,10 @@
     to ring your terminal's bell before printing an error message.
     The default value is 0.
 
+  * For functions defined from files, the type command now prints the
+    text of the file.  You can still get the text reconstructed from
+    the parse tree by using the new option -t (-transformed).
+
   * New command-line argument --traditional sets the following
     preference variables for compatibility with Matlab:
 
@@ -329,12 +333,27 @@
 
   * Other new functions:
 
-      tmpnam              -- replaces octave_tmp_file_name
-      atexit              -- register functions to be called when Octave exits
-      putenv              -- define an environment variable
-      meshgrid            -- compatible with Matlab's meshgrid function
+      commutation_matrix  -- compute special matrix form
+      duplication_matrix  -- compute special matrix form
+      common_size.m       -- bring arguments to a common size
+      completion_matches  -- perform command completion on string
       tilde_expand        -- perform tilde expansion on string
-      completion_matches  -- perform command completion on string
+
+      meshgrid  -- compatible with Matlab's meshgrid function
+      tmpnam    -- replaces octave_tmp_file_name
+      atexit    -- register functions to be called when Octave exits
+      putenv    -- define an environment variable
+      bincoeff  -- compute binomial coefficients
+      nextpow2  -- compute the next power of 2 greater than a number
+      detrend   -- remove a best fit polynomial from data
+      erfinv    -- inverse error function
+      shift     -- perform a circular shift on the elements of a matrix
+      pow2      -- compute 2 .^ x
+      log2      -- compute base 2 logarithms
+      diff      -- compute differences of matrix elements
+      vech      -- stack columns of a matrix below the diagonal
+      vec       -- stack columns of a matrix to form a vector
+      xor       -- compute exclusive or
 
   * Functions for getting info from the password database on Unix systems:
 
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,7 @@
+Wed Nov 20 01:00:50 1996  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* Version 1.93.
+
 Thu Nov 14 00:07:25 1996  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* faq/Makefile.in (FAQ.dvi): Use $(TEXI2DVI), not just texi2dvi.
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,7 @@
+Wed Nov 20 01:00:24 1996  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* Version 1.93.
+
 Tue Nov 19 15:13:35 1996  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* linear-algebra/commutation_matrix.m, linear-algebra/cross.m,
--- a/scripts/specfun/gammai.m
+++ b/scripts/specfun/gammai.m
@@ -93,4 +93,4 @@
   
   y = reshape (y, r, c);
 
-endfunction
\ No newline at end of file
+endfunction
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,26 @@
 Wed Nov 20 00:35:57 1996  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
+	* sighandlers.h (struct octave_interrupt_handler): Provide
+	forward declaration here.
+	* sighandlers.cc (octave_interrupt_handler): New struct.
+	(octave_catch_interrupts): Rename from catch_interrupts.
+	(octave_ignore_interrupts, octave_set_interrupt_handler):
+	New functions.
+	* help.cc, oct-hist.cc, pager.cc, toplev.cc: Use new functions for
+	handling interrupts so that we can hide the details of whether or
+	not we have to deal with SIGBREAK.
+
+	* pt-plot.cc [! HAVE_POSIX_SIGNALS] (open_plot_stream):
+	Simply ignore and restore the interrupt handler here.
+
+	* sighandlers.cc (MAYBE_REINSTALL_SIGHANDLER): New macro.  Use it
+	instead of always checking MUST_REINSTALL_SIGHANDLERS everywhere.
+	(sigchld_handler): If octave_child_list is empty, wait for any
+	child, but don't hang, and don't collect status info.
+	[__EMX__] (sigchld_handler): Save and restore handlers for SIGINT,
+	SIGBREAK, and SIGCHLD.  Ignore them while waiting on children.
+	(install_signal_handlers): If SIGBREAK exists, handle it like SIGINT.
+
 	* toplev.cc [USE_READLINE] (clean_up_and_exit):
 	Call rl_deprep_terminal() to restore terminal settings.
 
--- a/src/help.cc
+++ b/src/help.cc
@@ -552,12 +552,12 @@
 
   cmd_str = cmd_buf.str ();
 
-  volatile sig_handler *old_sigint_handler;
-  old_sigint_handler = octave_set_signal_handler (SIGINT, SIG_IGN);
+  volatile octave_interrupt_handler *old_interrupt_handler
+    = octave_ignore_interrupts ();
 
   status = system (cmd_str);
 
-  octave_set_signal_handler (SIGINT, old_sigint_handler);
+  octave_set_interrupt_handler (old_interrupt_handler);
 
   if ((status & 0xff) == 0)
     status = (signed char) ((status & 0xff00) >> 8);
--- a/src/oct-hist.cc
+++ b/src/oct-hist.cc
@@ -427,12 +427,12 @@
   // Ignore interrupts while we are off editing commands.  Should we
   // maybe avoid using system()?
 
-  volatile sig_handler *saved_sigint_handler
-    = octave_set_signal_handler (SIGINT, SIG_IGN);
+  volatile octave_interrupt_handler *old_interrupt_handler
+    = octave_ignore_interrupts ();
 
   system (cmd.c_str ());
 
-  octave_set_signal_handler (SIGINT, saved_sigint_handler);
+  octave_set_interrupt_handler (old_interrupt_handler);
 
   // Write the commands to the history file since parse_and_execute
   // disables command line history while it executes.
--- a/src/pager.cc
+++ b/src/pager.cc
@@ -72,7 +72,7 @@
 // through the pager.
 static bool Vpage_screen_output;
 
-static sig_handler *saved_sigint_handler = 0;
+static octave_interrupt_handler *saved_interrupt_handler = 0;
 
 static int really_flush_to_pager = 0;
 
@@ -88,10 +88,10 @@
   delete external_pager;
   external_pager = 0;
 
-  if (saved_sigint_handler)
+  if (saved_interrupt_handler)
     {
-      octave_set_signal_handler (SIGINT, saved_sigint_handler);
-      saved_sigint_handler = 0;
+      octave_set_interrupt_handler (saved_interrupt_handler);
+      saved_interrupt_handler = 0;
     }
 }
 
@@ -136,8 +136,7 @@
 
 	      if (! pgr.empty ())
 		{
-		  saved_sigint_handler
-		    = octave_set_signal_handler (SIGINT, SIG_IGN);
+		  saved_interrupt_handler = octave_ignore_interrupts ();
 
 		  external_pager = new oprocstream (pgr.c_str ());
 
--- a/src/sighandlers.cc
+++ b/src/sighandlers.cc
@@ -71,6 +71,22 @@
 #define SIGHANDLER_RETURN(status) return status
 #endif
 
+#if defined (MUST_REINSTALL_SIGHANDLERS)
+#define MAYBE_REINSTALL_SIGHANDLER(sig, handler) \
+  octave_set_signal_handler (sig, handler)
+#else
+#define MAYBE_REINSTALL_SIGHANDLER(sig, handler) \
+  do { } while (0)
+#endif
+
+#if defined (__EMX__)
+#define MAYBE_UNBLOCK_SIGNAL(sig) \
+  octave_set_signal_handler (sig, SIG_ACK)
+#else
+#define MAYBE_UNBLOCK_SIGNAL(sig) \
+  do { } while (0)
+#endif
+
 void
 octave_save_signal_mask (void)
 {
@@ -87,6 +103,20 @@
 #endif
 }
 
+struct
+octave_interrupt_handler
+{
+#ifdef SIGINT
+  sig_handler *int_handler;
+#endif
+
+#ifdef SIGBREAK
+  sig_handler *brk_handler;
+#endif
+};
+
+static octave_interrupt_handler the_interrupt_handler;
+
 static void
 my_friendly_exit (const char *sig_name, int sig_number)
 {
@@ -94,7 +124,7 @@
 
   if (been_there_done_that)
     {
-#ifdef SIGABRT
+#if defined (SIGABRT)
       octave_set_signal_handler (SIGABRT, SIG_DFL);
 #endif
 
@@ -159,36 +189,57 @@
 static RETSIGTYPE
 sigchld_handler (int /* sig */)
 {
+#if defined (__EMX__)
+  volatile octave_interrupt_handler *saved_interrupt_handler
+     = octave_ignore_interrupts ();
+
+  volatile sig_handler *saved_sigchld_handler
+    = octave_set_sighanlder (SIGCHLD, SIG_IGN);
+#endif
+
   int n = octave_child_list::length ();
 
-  for (int i = 0; i < n; i++)
+  if (n == 0)
     {
-      octave_child& elt = octave_child_list::elem (i);
+      waitpid (-1, 0, WNOHANG);
+    }
+  else
+    {
+      for (int i = 0; i < n; i++)
+	{
+	  octave_child& elt = octave_child_list::elem (i);
 
-      pid_t pid = elt.pid;
-
-      if (pid > 0)
-	{
-	  int status;
+	  pid_t pid = elt.pid;
 
-	  if (waitpid (pid, &status, WNOHANG) > 0)
+	  if (pid > 0)
 	    {
-	      elt.pid = -1;
+	      int status;
+
+	      if (waitpid (pid, &status, WNOHANG) > 0)
+		{
+		  elt.pid = -1;
 
-	      octave_child::dead_child_handler f = elt.handler;
+		  octave_child::dead_child_handler f = elt.handler;
 
-	      if (f)
-		f (pid, status);
+		  if (f)
+		    f (pid, status);
 
-	      break;
+		  break;
+		}
 	    }
 	}
     }
 
-#ifdef MUST_REINSTALL_SIGHANDLERS
-  octave_set_signal_handler (SIGCHLD, sigchld_handler);
+#if defined (__EMX__)
+  octave_set_inerrupt_handler (saved_interrupt_handler);
+
+  octave_set_signal_handler (SIGCHLD, saved_sigchld_handler);
 #endif
 
+  MAYBE_UNBLOCK_SIGNAL (SIGCHLD);
+
+  MAYBE_REINSTALL_SIGHANDLER (SIGCHLD, sigchld_handler);
+
   SIGHANDLER_RETURN (0);
 }
 
@@ -196,9 +247,9 @@
 static RETSIGTYPE
 sigfpe_handler (int /* sig */)
 {
-#ifdef MUST_REINSTALL_SIGHANDLERS
-  octave_set_signal_handler (SIGFPE, sigfpe_handler);
-#endif
+  MAYBE_UNBLOCK_SIGNAL (SIGFPE);
+
+  MAYBE_REINSTALL_SIGHANDLER (SIGFPE, sigfpe_handler);
 
   error ("floating point exception -- trying to return to prompt");
 
@@ -213,13 +264,17 @@
 #endif
 
 // Handle SIGINT by restarting the parser (see octave.cc).
+//
+// This also has to work for SIGBREAK (on systems that have it), so we
+// use the value of sig, instead of just assuming that it is called
+// for SIGINT only.
 
 static RETSIGTYPE
-sigint_handler (int /* sig */)
+sigint_handler (int sig)
 {
-#ifdef MUST_REINSTALL_SIGHANDLERS
-  octave_set_signal_handler (SIGINT, sigint_handler);
-#endif
+  MAYBE_UNBLOCK_SIGNAL (sig);
+
+  MAYBE_REINSTALL_SIGHANDLER (sig, sigint_handler);
 
   if (can_interrupt)
     {
@@ -233,9 +288,9 @@
 static RETSIGTYPE
 sigpipe_handler (int /* sig */)
 {
-#ifdef MUST_REINSTALL_SIGHANDLERS
-  octave_set_signal_handler (SIGPIPE, sigpipe_handler);
-#endif
+  MAYBE_UNBLOCK_SIGNAL (SIGPIPE);
+
+  MAYBE_REINSTALL_SIGHANDLER (SIGPIPE, sigpipe_handler);
 
   if (pipe_handler_error_count++ == 0)
     warning ("broken pipe");
@@ -249,9 +304,54 @@
 }
 
 void
-catch_interrupts (void)
+octave_catch_interrupts (void)
+{
+#ifdef SIGINT
+  octave_set_signal_handler (SIGINT, sigint_handler);
+
+  the_interrupt_handler.int_handler = sigint_handler;
+#endif
+
+#ifdef SIGBREAK
+  octave_set_signal_handler (SIGBREAK, sigint_handler);
+
+  the_interrupt_handler.brk_handler = sigint_handler;
+#endif
+}
+
+octave_interrupt_handler *
+octave_ignore_interrupts (void)
 {
-  octave_set_signal_handler (SIGINT, sigint_handler);
+#ifdef SIGINT
+  the_interrupt_handler.int_handler
+    = octave_set_signal_handler (SIGINT, SIG_IGN);
+#endif
+
+#ifdef SIGBREAK
+  the_interrupt_handler.int_handler
+    = octave_set_signal_handler (SIGBREAK, SIG_IGN);
+#endif
+  
+  return &the_interrupt_handler;
+}
+
+octave_interrupt_handler *
+octave_set_interrupt_handler (const volatile octave_interrupt_handler *h)
+{
+  if (h)
+    {
+#ifdef SIGINT
+      the_interrupt_handler.int_handler
+	= octave_set_signal_handler (SIGINT, h->int_handler);
+#endif
+
+#ifdef SIGBREAK
+      the_interrupt_handler.int_handler
+	= octave_set_signal_handler (SIGBREAK, h->brk_handler);
+#endif
+    }
+  
+  return &the_interrupt_handler;
 }
 
 // Install all the handlers for the signals we might care about.
@@ -261,6 +361,8 @@
 {
   set_new_handler (octave_new_handler);
 
+  octave_catch_interrupts ();
+
 #ifdef SIGABRT
   octave_set_signal_handler (SIGABRT, generic_sig_handler);
 #endif
@@ -297,10 +399,6 @@
   octave_set_signal_handler (SIGILL, generic_sig_handler);
 #endif
 
-#ifdef SIGINT
-  octave_set_signal_handler (SIGINT, sigint_handler);
-#endif
-
 #ifdef SIGIOT
   octave_set_signal_handler (SIGIOT, generic_sig_handler);
 #endif
--- a/src/sighandlers.h
+++ b/src/sighandlers.h
@@ -39,6 +39,11 @@
 
 typedef RETSIGTYPE sig_handler (int);
 
+// All we need to do is declare pointers to this, so we don't need to
+// have the whole declaration here.
+
+struct octave_interrupt_handler;
+
 // Nonzero means we have already printed a message for this series of
 // SIGPIPES.  We assume that the writer will eventually give up.
 extern int pipe_handler_error_count;
@@ -50,7 +55,12 @@
 
 extern void install_signal_handlers (void);
 
-extern void catch_interrupts (void);
+extern void octave_catch_interrupts (void);
+
+extern octave_interrupt_handler *octave_ignore_interrupts (void);
+
+extern octave_interrupt_handler *
+octave_set_interrupt_handler (const volatile octave_interrupt_handler *);
 
 extern void octave_save_signal_mask (void);
 
--- a/src/toplev.cc
+++ b/src/toplev.cc
@@ -235,7 +235,7 @@
 
   can_interrupt = 1;
 
-  catch_interrupts ();
+  octave_catch_interrupts ();
 
   // The big loop.
 
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,7 @@
+Wed Nov 20 01:00:02 1996  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* Version 1.93.
+
 Thu Nov 14 00:05:57 1996  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* Version 1.92