changeset 1343:94bedeb289e5

[project @ 1995-09-04 00:29:21 by jwe]
author jwe
date Mon, 04 Sep 1995 00:42:19 +0000
parents 61bb2bdee11e
children c2ca372d3279
files liboctave/idx-vector.cc src/error.cc src/file-io.cc src/help.cc src/input.cc src/load-save.cc src/mappers.cc src/oct-hist.cc src/pager.cc src/pr-output.cc src/pt-base.cc src/pt-exp-base.cc src/pt-plot.cc src/sighandlers.cc src/sysdep.cc src/tc-rep.cc src/token.cc src/unwind-prot.cc src/user-prefs.cc src/utils.cc src/variables.cc src/xdiv.cc src/xpow.cc
diffstat 23 files changed, 149 insertions(+), 79 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/idx-vector.cc	Mon Sep 04 00:24:09 1995 +0000
+++ b/liboctave/idx-vector.cc	Mon Sep 04 00:42:19 1995 +0000
@@ -29,8 +29,9 @@
 #include <config.h>
 #endif
 
+#include <cstdlib>
+
 #include <iostream.h>
-#include <stdlib.h>
 
 #include "dMatrix.h"
 #include "Range.h"
--- a/src/error.cc	Mon Sep 04 00:24:09 1995 +0000
+++ b/src/error.cc	Mon Sep 04 00:42:19 1995 +0000
@@ -25,8 +25,9 @@
 #include <config.h>
 #endif
 
+#include <cstdarg>
+
 #include <strstream.h>
-#include <stdarg.h>
 
 #include "utils.h"
 #include "error.h"
--- a/src/file-io.cc	Mon Sep 04 00:24:09 1995 +0000
+++ b/src/file-io.cc	Mon Sep 04 00:42:19 1995 +0000
@@ -33,16 +33,20 @@
 #include <config.h>
 #endif
 
+#include <cstring>
+#include <cstdio>
+#include <cerrno>
+#include <cstdlib>
+#include <cctype>
+
 #include <sys/types.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
-#include <string.h>
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <strstream.h>
+#endif
 #include <sys/wait.h>
 #include <fcntl.h>
-#include <ctype.h>
+
+#include <strstream.h>
 
 #include <DLList.h>
 
--- a/src/help.cc	Mon Sep 04 00:24:09 1995 +0000
+++ b/src/help.cc	Mon Sep 04 00:42:19 1995 +0000
@@ -25,13 +25,15 @@
 #include <config.h>
 #endif
 
+#include <csignal>
+#include <cstdlib>
+#include <cstring>
+
 #include <sys/types.h>
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
-#include <signal.h>
-#include <stdlib.h>
-#include <string.h>
+
 #include <iostream.h>
 #include <strstream.h>
 
--- a/src/input.cc	Mon Sep 04 00:24:09 1995 +0000
+++ b/src/input.cc	Mon Sep 04 00:42:19 1995 +0000
@@ -37,18 +37,20 @@
 #include <config.h>
 #endif
 
+#include <ctime>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <cassert>
+#include <csignal>
+
 #include <sys/types.h>
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
-#include <time.h>
-#include <stdio.h>
-#include <stdlib.h>
+
 #include <iostream.h>
 #include <strstream.h>
-#include <string.h>
-#include <assert.h>
-#include <signal.h>
 
 // This must come before anything that includes iostream.h...
 extern "C"
--- a/src/load-save.cc	Mon Sep 04 00:24:09 1995 +0000
+++ b/src/load-save.cc	Mon Sep 04 00:42:19 1995 +0000
@@ -25,13 +25,14 @@
 #include <config.h>
 #endif
 
-#include <float.h>
-#include <limits.h>
-#include <string.h>
+#include <cfloat>
+#include <climits>
+#include <cstring>
+#include <cctype>
+
 #include <iostream.h>
 #include <fstream.h>
 #include <strstream.h>
-#include <ctype.h>
 
 #include "tree-base.h"
 #include "tree-expr.h"
--- a/src/mappers.cc	Mon Sep 04 00:24:09 1995 +0000
+++ b/src/mappers.cc	Mon Sep 04 00:42:19 1995 +0000
@@ -25,8 +25,9 @@
 #include <config.h>
 #endif
 
-#include <math.h>
-#include <float.h>
+#include <cmath>
+#include <cfloat>
+
 #include <Complex.h>
 
 #include "missing-math.h"
--- a/src/oct-hist.cc	Mon Sep 04 00:24:09 1995 +0000
+++ b/src/oct-hist.cc	Mon Sep 04 00:42:19 1995 +0000
@@ -32,14 +32,16 @@
 #include <config.h>
 #endif
 
+#include <cstdlib>
+#include <cstring>
+#include <csignal>
+
 #include <sys/types.h>
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
 #include <fcntl.h>
-#include <stdlib.h>
-#include <string.h>
-#include <signal.h>
+
 #include <fstream.h>
 #include <strstream.h>
 
--- a/src/pager.cc	Mon Sep 04 00:24:09 1995 +0000
+++ b/src/pager.cc	Mon Sep 04 00:42:19 1995 +0000
@@ -25,11 +25,12 @@
 #include <config.h>
 #endif
 
-#include <signal.h>
+#include <csignal>
+#include <cstdlib>
+
 #include <iostream.h>
 #include <strstream.h>
 #include <fstream.h>
-#include <stdlib.h>
 
 #include "procstream.h"
 
--- a/src/pr-output.cc	Mon Sep 04 00:24:09 1995 +0000
+++ b/src/pr-output.cc	Mon Sep 04 00:42:19 1995 +0000
@@ -25,11 +25,13 @@
 #include <config.h>
 #endif
 
+#include <cstring>
+#include <cmath>
+#include <cfloat>
+
 #include <iostream.h>
 #include <strstream.h>
-#include <string.h>
-#include <math.h>
-#include <float.h>
+
 #include <Complex.h>
 
 #include "dMatrix.h"
@@ -41,6 +43,7 @@
 #include "user-prefs.h"
 #include "pr-output.h"
 #include "mappers.h"
+#include "oct-str.h"
 #include "sysdep.h"
 #include "pager.h"
 #include "help.h"
@@ -1389,7 +1392,6 @@
 
       if (pr_as_read_syntax)
 	{
-	  
 	  if (free_format)
 	    {
 	      os << base << " : ";
@@ -1451,6 +1453,32 @@
     }
 }
 
+void
+octave_print_internal (ostream& os, Octave_str_obj& s,
+		       int pr_as_read_syntax)
+{
+  int nstr = s.num_strings ();
+
+  if (pr_as_read_syntax && nstr > 1)
+    os << "[ ";
+
+  for (int i = 0; i < nstr; i++)
+    {
+      if (pr_as_read_syntax)
+	{
+	  os << "\"" << s.elem (i) << "\"";
+
+	  if (i < nstr - 1)
+	    os << "; ";
+	}
+      else
+	os << s.elem (i) << "\n";
+    }
+
+  if (pr_as_read_syntax && nstr > 1)
+    os << " ]";
+}
+
 DEFUN ("disp", Fdisp, Sdisp, 1, 1,
   "disp (X): display value without name tag")
 {
--- a/src/pt-base.cc	Mon Sep 04 00:24:09 1995 +0000
+++ b/src/pt-base.cc	Mon Sep 04 00:42:19 1995 +0000
@@ -29,8 +29,9 @@
 #include <config.h>
 #endif
 
+#include <cassert>
+
 #include <iostream.h>
-#include <assert.h>
 
 #include "tree-base.h"
 
--- a/src/pt-exp-base.cc	Mon Sep 04 00:24:09 1995 +0000
+++ b/src/pt-exp-base.cc	Mon Sep 04 00:42:19 1995 +0000
@@ -29,6 +29,11 @@
 #include <config.h>
 #endif
 
+#include <cstring>
+#include <climits>
+#include <cctype>
+#include <cstdio>
+
 #include <sys/types.h>
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
@@ -36,10 +41,6 @@
 
 #include <iostream.h>
 #include <strstream.h>
-#include <string.h>
-#include <limits.h>
-#include <ctype.h>
-#include <stdio.h>
 
 #include "variables.h"
 #include "user-prefs.h"
@@ -336,8 +337,7 @@
   Matrix m;
   ComplexMatrix cm;
 
-  char *string = 0;
-  char *str_ptr = 0;
+  Octave_str_obj string;
 
 // Eliminate empties and gather stats.
 
@@ -450,7 +450,7 @@
 
 	    case md_down:
 	      {
-		if (cols_this_row != col_total)
+		if (cols_this_row != col_total && ! all_strings)
 		  {
 		    ::error ("number of columns must match");
 		    goto done;
@@ -471,7 +471,7 @@
 
 // Don\'t forget to check to see if the last element will fit.
 
-  if (cols_this_row != col_total)
+  if (cols_this_row != col_total && ! all_strings)
     {
       ::error ("number of columns must match");
       goto done;
@@ -480,11 +480,8 @@
 // Now, extract the values from the individual elements and insert
 // them in the result matrix.
 
-  if (all_strings && row_total == 1 && col_total > 0)
-    {
-      string = str_ptr = new char [col_total + 1];
-      string[col_total] = '\0';
-    }
+  if (all_strings)
+    string.resize (row_total);
   else if (found_complex)
     cm.resize (row_total, col_total, 0.0);
   else
@@ -554,10 +551,26 @@
 	    {
 	      m (put_row, put_col) = tmp.double_value ();
 	    }
-	  else if (tmp.is_string () && all_strings && str_ptr)
+	  else if (tmp.is_string () && all_strings)
 	    {
-	      memcpy (str_ptr, tmp.string_value (), nc);
-	      str_ptr += nc;
+	      switch (list[i].direction)
+		{
+		case md_right:
+		  if (nr == 1)
+		    string.append_right (put_row, tmp.string_value ());
+		  else
+		    string.append_right (tmp.all_strings ());
+		  break;
+
+		case md_none:
+		case md_down:
+		  string.append_down (put_row, tmp.all_strings ());
+		  break;
+		  
+		default:
+		  panic_impossible ();
+		  break;
+		}
 	    }
 	  else
 	    {
@@ -574,12 +587,12 @@
       prev_nc = nc;
     }
 
-  if (all_strings && string)
-    retval = tree_constant (string);
+  if (all_strings && string.num_strings () > 0)
+    retval = string;
   else if (found_complex)
-    retval = tree_constant (cm);
+    retval = cm;
   else
-    retval = tree_constant (m);
+    retval = m;
 
  done:
   delete [] list;
--- a/src/pt-plot.cc	Mon Sep 04 00:24:09 1995 +0000
+++ b/src/pt-plot.cc	Mon Sep 04 00:42:19 1995 +0000
@@ -29,11 +29,12 @@
 #include <config.h>
 #endif
 
+#include <cstring>
+
 #include <sys/types.h>
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
-#include <string.h>
 #include <iostream.h>
 #include <strstream.h>
 #include <fstream.h>
--- a/src/sighandlers.cc	Mon Sep 04 00:24:09 1995 +0000
+++ b/src/sighandlers.cc	Mon Sep 04 00:42:19 1995 +0000
@@ -25,13 +25,15 @@
 #include <config.h>
 #endif
 
+#include <cnew>
+#include <csignal>
+
 #include <sys/types.h>
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
 #include <sys/wait.h>
-#include <new.h>
-#include <signal.h>
+
 #include <iostream.h>
 
 #include "sighandlers.h"
--- a/src/sysdep.cc	Mon Sep 04 00:24:09 1995 +0000
+++ b/src/sysdep.cc	Mon Sep 04 00:42:19 1995 +0000
@@ -33,16 +33,17 @@
 #include <config.h>
 #endif
 
+#include <cmath>
+#include <cfloat>
+#include <cstddef>
+#include <cstdlib>
+#include <cstring>
+#include <cstdio>
+
 #include <sys/types.h>
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
-#include <math.h>
-#include <float.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
 
 #include "tree-const.h"
 #include "octave.h"
--- a/src/tc-rep.cc	Mon Sep 04 00:24:09 1995 +0000
+++ b/src/tc-rep.cc	Mon Sep 04 00:42:19 1995 +0000
@@ -25,8 +25,9 @@
 #include <config.h>
 #endif
 
-#include <ctype.h>
-#include <string.h>
+#include <cctype>
+#include <cstring>
+
 #include <fstream.h>
 #include <iostream.h>
 
--- a/src/token.cc	Mon Sep 04 00:24:09 1995 +0000
+++ b/src/token.cc	Mon Sep 04 00:42:19 1995 +0000
@@ -29,7 +29,7 @@
 #include <config.h>
 #endif
 
-#include <assert.h>
+#include <cassert>
 
 #include "error.h"
 #include "token.h"
--- a/src/unwind-prot.cc	Mon Sep 04 00:24:09 1995 +0000
+++ b/src/unwind-prot.cc	Mon Sep 04 00:42:19 1995 +0000
@@ -29,7 +29,7 @@
 #include <config.h>
 #endif
 
-#include <stddef.h>
+#include <cstddef>
 
 #include "SLStack.h"
 
--- a/src/user-prefs.cc	Mon Sep 04 00:24:09 1995 +0000
+++ b/src/user-prefs.cc	Mon Sep 04 00:42:19 1995 +0000
@@ -25,7 +25,7 @@
 #include <config.h>
 #endif
 
-#include <string.h>
+#include <cstring>
 
 #include "user-prefs.h"
 #include "mappers.h"
--- a/src/utils.cc	Mon Sep 04 00:24:09 1995 +0000
+++ b/src/utils.cc	Mon Sep 04 00:42:19 1995 +0000
@@ -25,13 +25,14 @@
 #include <config.h>
 #endif
 
+#include <cstring>
+#include <climits>
+
 #include <sys/types.h>
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
 #include <sys/param.h>
-#include <string.h>
-#include <limits.h>
 #include <iostream.h>
 #include <strstream.h>
 #include <fstream.h>
--- a/src/variables.cc	Mon Sep 04 00:24:09 1995 +0000
+++ b/src/variables.cc	Mon Sep 04 00:42:19 1995 +0000
@@ -25,19 +25,13 @@
 #include <config.h>
 #endif
 
-#if 0
-#include <ctype.h>
-#include <iostream.h>
-
-#include "mappers.h"
-#endif
+#include <cfloat>
+#include <cstring>
 
 #include <sys/types.h>
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
-#include <float.h>
-#include <string.h>
 #include <strstream.h>
 
 #include "defaults.h"
@@ -1556,6 +1550,9 @@
   DEFVAR ("ans", SBV_ans, , 0, 0, 1, 0,
     "");
 
+  DEFVAR ("argv", SBV_argv, , 0, 1, 1, 0,
+    "the command line arguments this program was invoked with");
+
   DEFVAR ("automatic_replot", SBV_automatic_replot, "false",
 	  0, 0, 1, automatic_replot,
     "if true, auto-insert a replot command when a plot changes");
@@ -1651,6 +1648,14 @@
 	  0, 0, 1, print_empty_dimensions,
     "also print dimensions of empty matrices");
 
+  DEFVAR ("program_invocation_name", SBV_program_invocation_name,
+	  raw_prog_name, 0, 1, 1, 0,
+    "the full name of the current program or script, including the\n\
+directory specification");
+
+  DEFVAR ("program_name", SBV_program_name, prog_name, 0, 1, 1, 0,
+    "the name of the current program or script");
+
   DEFVAR ("propagate_empty_matrices", SBV_propagate_empty_matrices,
 	  "true", 0, 0, 1, propagate_empty_matrices,
     "operations on empty matrices return an empty matrix, not an error");
--- a/src/xdiv.cc	Mon Sep 04 00:24:09 1995 +0000
+++ b/src/xdiv.cc	Mon Sep 04 00:42:19 1995 +0000
@@ -25,7 +25,8 @@
 #include <config.h>
 #endif
 
-#include <assert.h>
+#include <cassert>
+
 #include <Complex.h>
 
 #include "xdiv.h"
--- a/src/xpow.cc	Mon Sep 04 00:24:09 1995 +0000
+++ b/src/xpow.cc	Mon Sep 04 00:42:19 1995 +0000
@@ -25,7 +25,8 @@
 #include <config.h>
 #endif
 
-#include <assert.h>
+#include <cassert>
+
 #include <Complex.h>
 
 #include "xpow.h"