changeset 2795:14d07e4a0265

[project @ 1997-03-07 02:18:49 by jwe]
author jwe
date Fri, 07 Mar 1997 02:21:37 +0000
parents b836945228cc
children 74bc1ede3c3d
files liboctave/CMatrix.cc liboctave/ChangeLog liboctave/dMatrix.cc scripts/ChangeLog scripts/statistics/corrcoef.m src/ChangeLog src/load-save.cc src/pager.cc src/sighandlers.cc
diffstat 9 files changed, 98 insertions(+), 90 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/CMatrix.cc
+++ b/liboctave/CMatrix.cc
@@ -3760,7 +3760,7 @@
 	    if (is)
 	      a.elem (i, j) = tmp;
 	    else
-	      break;
+	      return;
 	  }
     }
 
--- a/liboctave/ChangeLog
+++ b/liboctave/ChangeLog
@@ -1,3 +1,9 @@
+Thu Mar  6 20:20:01 1997  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* dMatrix.cc (operator >>): Return if an error occurs instead of
+	just breaking out of the innermost loop.
+	* CMatrix.cc (operator >>): Likewise.
+
 Sat Mar  1 15:23:14 1997  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* Version 2.0.5 released.
--- a/liboctave/dMatrix.cc
+++ b/liboctave/dMatrix.cc
@@ -2626,10 +2626,12 @@
 	    if (is)
 	      a.elem (i, j) = tmp;
 	    else
-	      break;
+	      goto done;
 	  }
     }
 
+ done:
+
   return is;
 }
 
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,7 @@
+Thu Mar  6 12:36:30 1997  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* statistics/corrcoef.m: Don't fail if single argument is a vector.
+
 Sat Mar  1 15:23:14 1997  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* Version 2.0.5 released.
--- a/scripts/statistics/corrcoef.m
+++ b/scripts/statistics/corrcoef.m
@@ -17,31 +17,32 @@
 ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 ## 02111-1307, USA.
 
-## usage: corrcoef (X [, Y])
+## usage: corrcoef (x, y)
 ##
-## If each row of X and Y is an observation and each column is a variable,
-## the (i,j)-th entry of corrcoef(X, Y) is the correlation between the
-## i-th variable in X and the j-th variable in Y.
-## corrcoef(X) is corrcoef(X, X).
+## The (i,j)-th entry of corrcoef (x, y) is the correlation between the
+## i-th variable in x and the j-th variable in y.
+## For matrices, each row is an observation and each column a variable;
+## vectors are always observations and may be row or column vectors.
+## corrcoef (x) is corrcoef (x, x).
 
 ## Author: Kurt Hornik <hornik@ci.tuwien.ac.at>
 ## Created: March 1993
 ## Adapted-By: jwe
 
-function retval = corrcoef (X, Y)
+function retval = corrcoef (x, y)
 
   if (nargin < 1 || nargin > 2)
-    usage ("corrcoef (X [, Y])");
+    usage ("corrcoef (x, y)");
   endif
 
   if (nargin == 2)
-    C = cov (X, Y);
-    S = std (X)' * std (Y);
-    retval = C ./ S;
+    c = cov (x, y);
+    s = std (x)' * std (y);
+    retval = c ./ s;
   elseif (nargin == 1)
-    C = cov (X);
-    s = diag (C);
-    retval = C ./ sqrt (s*s');
+    c = cov (x);
+    s = reshape (sqrt (diag (c)), 1, columns (c));
+    retval = c ./ sqrt (s * s');
   endif
 
 endfunction
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,18 @@
+Thu Mar  6 20:07:24 1997  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* sighandlers.cc (my_friendly_exit, octave_new_handler,
+	sigfpe_handler, sigpipe_handler): Don't all error() or warning().
+
+	* pager.cc (pager_death_handler): Don't try to clear pager, just
+	print message to cerr.
+	(do_sync): If the status of the pager is bad or it looks like it
+	is dead, restore the interrupt handler.
+
+	* load-save.cc (extract_keyword (istream&, char*, int&)):
+	Move declaration of buf inside loop, to avoid deleting its guts
+	and then trying to reuse it.
+	(extract_keyword (istream&, char*)): Likewise.
+
 Tue Mar  4 20:36:53 1997  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* pt-fcn.cc (tree_function::eval): Protect function from being
--- a/src/load-save.cc
+++ b/src/load-save.cc
@@ -253,8 +253,6 @@
 static char *
 extract_keyword (istream& is, char *keyword)
 {
-  ostrstream buf;
-
   char *retval = 0;
 
   char c;
@@ -262,6 +260,8 @@
     {
       if (c == '#')
 	{
+	  ostrstream buf;
+	
 	  while (is.get (c) && (c == ' ' || c == '\t' || c == '#'))
 	    ; // Skip whitespace and comment characters.
 
@@ -320,8 +320,6 @@
 static int
 extract_keyword (istream& is, char *keyword, int& value)
 {
-  ostrstream buf;
-
   int status = 0;
   value = 0;
 
@@ -330,6 +328,8 @@
     {
       if (c == '#')
 	{
+	  ostrstream buf;
+
 	  while (is.get (c) && (c == ' ' || c == '\t' || c == '#'))
 	    ; // Skip whitespace and comment characters.
 
@@ -910,36 +910,6 @@
   return name;
 }
 
-// Get a complete line of input.
-
-static string
-get_complete_line (istream& is)
-{
-  string retval;
-
-  ostrstream buf;
-
-  char c;
-
-  while (is.get (c))
-    {
-      if (c == '\n')
-	break;
-
-      buf << c;
-    }
-
-  buf << ends;
-
-  char *tmp = buf.str ();
-
-  retval = tmp;
-
-  delete [] tmp;
-
-  return retval;
-}
-
 static void
 get_lines_and_columns (istream& is, const string& filename, int& nr, int& nc)
 {
@@ -950,30 +920,39 @@
   nr = 0;
   nc = 0;
 
-  while (! (is.eof () || error_state))
+  while (is && ! error_state)
     {
-      string line = get_complete_line (is);
+      string buf;
+
+      char c;
+      while (is.get (c))
+	{
+	  if (c == '\n')
+	    break;
+
+	  buf += c;
+	}
 
       file_line_number++;
 
-      size_t beg = line.find_first_not_of (" \t");
-
-      if (beg != NPOS)
+      size_t beg = buf.find_first_not_of (" \t");
+
+      int tmp_nc = 0;
+
+      while (beg != NPOS)
 	{
-	  int tmp_nc = 0;
-
-	  while (beg != NPOS)
-	    {
-	      tmp_nc++;
-
-	      size_t end = line.find_first_of (" \t", beg);
-
-	      if (end != NPOS)
-		beg = line.find_first_not_of (" \t", end);
-	      else
-		break;
-	    }
-
+	  tmp_nc++;
+
+	  size_t end = buf.find_first_of (" \t", beg);
+
+	  if (end != NPOS)
+	    beg = buf.find_first_not_of (" \t", end);
+	  else
+	    break;
+	}
+
+      if (tmp_nc > 0)
+	{
 	  if (nc == 0)
 	    {
 	      nc = tmp_nc;
@@ -1027,10 +1006,8 @@
 
       get_lines_and_columns (is, filename, nr, nc);
 
-      if (! error_state)
+      if (! error_state && nr > 0 && nc > 0)
 	{
-	  // NR and NC must be greater than zero if we end up here.
-
 	  Matrix tmp (nr, nc);
 
 	  is >> tmp;
--- a/src/pager.cc
+++ b/src/pager.cc
@@ -105,21 +105,12 @@
     {
       if (WIFEXITED (status) || WIFSIGNALLED (status))
 	{
-	  if (external_pager)
-	    clear_external_pager ();
-
-	  // Don't call error() here because we don't want to set
-	  // the error state.
+	  // Avoid warning() or error(), since that will put us back in
+	  // the pager, which would be bad news.
 
-	  // XXX FIXME XXX -- something is wrong with the way that
-	  // we are cleaning up the pager in the event of a SIGCHLD.
-	  // If this message is printed with warning(), we eventually
-	  // crash.
-
-	  cout << "warning: connection to external pager (pid = "
-	       << pid << ") lost --" << endl
-	       << "warning: pending computations and output may be lost"
-	       << endl;
+	  cerr << "warning: connection to external pager (pid = "
+	       << pid << ") lost --\n"
+	       << "warning: attempting to finish pending computations...\n";
 	}
     }
 }
@@ -172,6 +163,18 @@
 		      && external_pager->good ())
 		    external_pager->flush ();
 		}
+	      else
+		{
+		  // We had a pager, but it must have died.  Restore
+		  // the interrupt state so we can escape back to the
+		  // prompt if there are lots of computations pending.
+
+		  if (interrupt_handler_saved)
+		    {
+		      octave_set_interrupt_handler (saved_interrupt_handler);
+		      interrupt_handler_saved = false;
+		    }
+		}
 	    }
 	  else
 	    {
--- a/src/sighandlers.cc
+++ b/src/sighandlers.cc
@@ -114,7 +114,7 @@
       octave_set_signal_handler (SIGABRT, SIG_DFL);
 #endif
 
-      error ("attempted clean up seems to have failed -- aborting...");
+      cerr << "error: attempted clean up apparently failed -- aborting...\n";
 
       abort ();
     }
@@ -122,7 +122,7 @@
     {
       been_there_done_that = true;
 
-      error ("%s -- stopping myself...", sig_name);
+      cerr << "error: " << sig_name << " -- stopping myself...\n";
 
       save_user_variables ();
 
@@ -135,7 +135,7 @@
 static void
 octave_new_handler (void)
 {
-  error ("memory exhausted -- trying to return to prompt");
+  cerr << "error: memory exhausted -- trying to return to prompt\n";
 
   if (can_interrupt)
     {
@@ -247,7 +247,7 @@
 
   MAYBE_REINSTALL_SIGHANDLER (SIGFPE, sigfpe_handler);
 
-  error ("floating point exception -- trying to return to prompt");
+  cerr << "error: floating point exception -- trying to return to prompt\n";
 
   if (can_interrupt)
     {
@@ -289,7 +289,7 @@
   MAYBE_REINSTALL_SIGHANDLER (SIGPIPE, sigpipe_handler);
 
   if (pipe_handler_error_count++ == 0)
-    warning ("broken pipe");
+    cerr << "warning: broken pipe\n";
 
   // Don't loop forever on account of this.