changeset 3216:60a89a69a70a

[project @ 1998-11-11 20:47:03 by jwe]
author jwe
date Wed, 11 Nov 1998 20:47:43 +0000
parents bc3fdfe311a3
children 8b0cb8f79fdc
files src/load-save.cc src/octave.cc src/parse.y src/toplev.cc src/toplev.h
diffstat 5 files changed, 91 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/src/load-save.cc	Tue Nov 10 14:12:07 1998 +0000
+++ b/src/load-save.cc	Wed Nov 11 20:47:43 1998 +0000
@@ -946,6 +946,46 @@
   return name;
 }
 
+static string
+get_mat_data_input_line (istream& is)
+{
+  string retval;
+
+  bool have_data = false;
+
+  do
+    {
+      retval = "";
+
+      char c;
+      while (is.get (c))
+	{
+	  if (c == '\n')
+	    break;
+
+	  if (c == '%' || c == '#')
+	    {
+	      // skip to end of line
+	      while (is.get (c) && c != '\n')
+		;
+
+	      break;
+	    }
+
+	  if (! is.eof ())
+	    {
+	      if (! have_data && c != ' ' && c != '\t')
+		have_data = true;
+
+	      retval += c;
+	    }
+	}
+    }
+  while (! (have_data || is.eof ()));
+
+  return retval;
+}
+
 static void
 get_lines_and_columns (istream& is, const string& filename, int& nr, int& nc)
 {
@@ -958,16 +998,7 @@
 
   while (is && ! error_state)
     {
-      string buf;
-
-      char c;
-      while (is.get (c))
-	{
-	  if (c == '\n')
-	    break;
-
-	  buf += c;
-	}
+      string buf = get_mat_data_input_line (is);
 
       file_line_number++;
 
@@ -1051,7 +1082,29 @@
 	{
 	  Matrix tmp (nr, nc);
 
-	  is >> tmp;
+	  if (nr < 1 || nc < 1)
+	    is.clear (ios::badbit);
+	  else
+	    {
+	      double d;
+	      for (int i = 0; i < nr; i++)
+		{
+		  string buf = get_mat_data_input_line (is);
+
+		  istrstream tmp_stream (buf.c_str ());
+
+		  for (int j = 0; j < nc; j++)
+		    {
+		      tmp_stream >> d;
+		      if (is)
+			tmp.elem (i, j) = d;
+		      else
+			goto done;
+		    }
+		}
+	    }
+
+	done:
 
 	  if (is)
 	    {
--- a/src/octave.cc	Tue Nov 10 14:12:07 1998 +0000
+++ b/src/octave.cc	Wed Nov 11 20:47:43 1998 +0000
@@ -480,8 +480,6 @@
   // leave some junk files around if we exit abnormally.
 
   atexit (do_octave_atexit);
-
-  atexit (cleanup_tmp_files);
 #endif
 
   // These can come after command line args since none of them set any
--- a/src/parse.y	Tue Nov 10 14:12:07 1998 +0000
+++ b/src/parse.y	Wed Nov 11 20:47:43 1998 +0000
@@ -1674,7 +1674,7 @@
   int l = tok_val->line ();
   int c = tok_val->column ();
 
-  tree_constant *retval;
+  tree_constant *retval = 0;
 
   switch (op)
     {
--- a/src/toplev.cc	Tue Nov 10 14:12:07 1998 +0000
+++ b/src/toplev.cc	Wed Nov 11 20:47:43 1998 +0000
@@ -167,31 +167,9 @@
 // Fix up things before exiting.
 
 void
-clean_up_for_exit (void)
-{
-  command_editor::restore_terminal_state ();
-
-  // XXX FIXME XXX -- is this needed?  Can it cause any trouble?
-  raw_mode (0);
-
-  command_history::clean_up_and_save ();
-
-  close_plot_stream ();
-
-  close_files ();
-
-  cleanup_tmp_files ();
-
-  flush_octave_stdout ();
-
-  if (!quitting_gracefully && (interactive || forced_interactive))
-    cout << "\n";
-}
-
-void
 clean_up_and_exit (int retval)
 {
-  clean_up_for_exit ();
+  do_octave_atexit ();
 
   exit (retval == EOF ? 0 : retval);
 }
@@ -509,6 +487,8 @@
 void
 do_octave_atexit (void)
 {
+  static bool deja_vu = false;
+
   while (! octave_atexit_functions.empty ())
     {
       octave_value_list fcn = octave_atexit_functions.pop ();
@@ -517,6 +497,29 @@
 
       flush_octave_stdout ();
     }
+
+  if (! deja_vu)
+    {
+      deja_vu = true;
+
+      command_editor::restore_terminal_state ();
+
+      // XXX FIXME XXX -- is this needed?  Can it cause any trouble?
+      raw_mode (0);
+
+      command_history::clean_up_and_save ();
+
+      close_plot_stream ();
+
+      close_files ();
+
+      cleanup_tmp_files ();
+
+      flush_octave_stdout ();
+
+      if (!quitting_gracefully && (interactive || forced_interactive))
+	cout << "\n";
+    }
 }
 
 DEFUN (atexit, args, ,
--- a/src/toplev.h	Tue Nov 10 14:12:07 1998 +0000
+++ b/src/toplev.h	Wed Nov 11 20:47:43 1998 +0000
@@ -34,9 +34,6 @@
 #include <string>
 
 extern void
-clean_up_and_exit (void);
-
-extern void
 clean_up_and_exit (int) GCC_ATTR_NORETURN;
 
 extern int