changeset 3709:c73bea82af94

[project @ 2000-08-02 02:23:26 by jwe]
author jwe
date Wed, 02 Aug 2000 02:23:30 +0000
parents 9b9efdcbdfd3
children 9a77deefb8c9
files doc/interpreter/io.txi liboctave/Array2-idx.h liboctave/ChangeLog liboctave/oct-time.cc scripts/ChangeLog scripts/plot/meshgrid.m src/ChangeLog src/load-save.cc test/octave.test/string/str2mat-3.m test/octave.test/string/string.exp
diffstat 10 files changed, 123 insertions(+), 72 deletions(-) [+]
line wrap: on
line diff
--- a/doc/interpreter/io.txi	Fri Jul 28 20:53:40 2000 +0000
+++ b/doc/interpreter/io.txi	Wed Aug 02 02:23:30 2000 +0000
@@ -129,7 +129,7 @@
 
 @DOCSTRING(save)
 
-There are two variables that modify the behavior of @code{save} and one
+There are three variables that modify the behavior of @code{save} and one
 that controls whether variables are saved when Octave exits unexpectedly.
 
 @DOCSTRING(crash_dumps_octave_core)
@@ -138,6 +138,8 @@
 
 @DOCSTRING(save_precision)
 
+@DOCSTRING(save_header_format_string)
+
 @DOCSTRING(load)
 
 @node C-Style I/O Functions,  , Basic Input and Output, Input and Output
--- a/liboctave/Array2-idx.h	Fri Jul 28 20:53:40 2000 +0000
+++ b/liboctave/Array2-idx.h	Wed Aug 02 02:23:30 2000 +0000
@@ -70,17 +70,7 @@
     {
       Array<T> tmp = Array<T>::index (idx_arg);
 
-      int len = tmp.length ();
-
-      if (len == 0)
-	retval = Array2<T> (0, 0);
-      else
-	{
-	  if (liboctave_pcv_flag)
-	    retval = Array2<T> (tmp, len, 1);
-	  else
-	    retval = Array2<T> (tmp, 1, len);
-	}
+      retval = Array2<T> (tmp, idx_orig_rows, idx_orig_columns);
     }
   else if (nr == 1 || nc == 1)
     {
--- a/liboctave/ChangeLog	Fri Jul 28 20:53:40 2000 +0000
+++ b/liboctave/ChangeLog	Wed Aug 02 02:23:30 2000 +0000
@@ -1,3 +1,11 @@
+2000-08-01  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* Array2-idx.h (Array2<T>::index (idx_vector&)): If a scalar is
+	indexed, always return an object the same size as the index arg.
+
+	* oct-time.cc (octave_base_tm::strftime): Return empty string for
+	empty format.
+
 2000-07-25  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* lo-cutils.c (oct_strptime): New function.
--- a/liboctave/oct-time.cc	Fri Jul 28 20:53:40 2000 +0000
+++ b/liboctave/oct-time.cc	Wed Aug 02 02:23:30 2000 +0000
@@ -137,47 +137,50 @@
 {
   std::string retval;
 
-  struct tm t;
+  if (! fmt.empty ())
+    {
+      struct tm t;
   
-  t.tm_sec = tm_sec;
-  t.tm_min = tm_min;
-  t.tm_hour = tm_hour;
-  t.tm_mday = tm_mday;
-  t.tm_mon = tm_mon;
-  t.tm_year = tm_year;
-  t.tm_wday = tm_wday;
-  t.tm_yday = tm_yday;
-  t.tm_isdst = tm_isdst;
+      t.tm_sec = tm_sec;
+      t.tm_min = tm_min;
+      t.tm_hour = tm_hour;
+      t.tm_mday = tm_mday;
+      t.tm_mon = tm_mon;
+      t.tm_year = tm_year;
+      t.tm_wday = tm_wday;
+      t.tm_yday = tm_yday;
+      t.tm_isdst = tm_isdst;
 
 #if defined (HAVE_TM_ZONE)
-  char *ps = strsave (tm_zone.c_str ());
-  t.tm_zone = ps;
+      char *ps = strsave (tm_zone.c_str ());
+      t.tm_zone = ps;
 #endif
 
-  const char *fmt_str = fmt.c_str ();
+      const char *fmt_str = fmt.c_str ();
 
-  char *buf = 0;
-  size_t bufsize = STRFTIME_BUF_INITIAL_SIZE;
-  size_t chars_written = 0;
+      char *buf = 0;
+      size_t bufsize = STRFTIME_BUF_INITIAL_SIZE;
+      size_t chars_written = 0;
 
-  while (chars_written == 0)
-    {
-      delete [] buf;
-      buf = new char[bufsize];
-      buf[0] = '\0';
+      while (chars_written == 0)
+	{
+	  delete [] buf;
+	  buf = new char[bufsize];
+	  buf[0] = '\0';
 
-      chars_written = ::strftime (buf, bufsize, fmt_str, &t);
+	  chars_written = ::strftime (buf, bufsize, fmt_str, &t);
 
-      bufsize *= 2;
-    }
+	  bufsize *= 2;
+	}
 
 #if defined (HAVE_TM_ZONE)
-  delete [] ps;
+      delete [] ps;
 #endif
 
-  retval = buf;
+      retval = buf;
 
-  delete [] buf;
+      delete [] buf;
+    }
 
   return retval;
 }
--- a/scripts/ChangeLog	Fri Jul 28 20:53:40 2000 +0000
+++ b/scripts/ChangeLog	Wed Aug 02 02:23:30 2000 +0000
@@ -1,3 +1,8 @@
+2000-08-01  Rolf Fabian  <fabian@tu-cottbus.de>
+
+	* plot/meshgrid.m: Use transpose to reorient vectors, not complex
+	conjugate transpose.
+
 2000-07-21  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* strings/str2mat.m: Apply setstr to each argument.
--- a/scripts/plot/meshgrid.m	Fri Jul 28 20:53:40 2000 +0000
+++ b/scripts/plot/meshgrid.m	Wed Aug 02 02:23:30 2000 +0000
@@ -41,10 +41,10 @@
       xx = zeros (ylen, xlen);
       yy = zeros (ylen, xlen);
       if (columns (x) == 1)
-        x = x';
+        x = x.';
       endif
       if (rows (y) == 1)
-        y = y';
+        y = y.';
       endif
       for i = 1:ylen
         xx(i,:) = x;
--- a/src/ChangeLog	Fri Jul 28 20:53:40 2000 +0000
+++ b/src/ChangeLog	Wed Aug 02 02:23:30 2000 +0000
@@ -1,3 +1,10 @@
+2000-08-01  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* load-save.cc (Vsave_header_format_string): New variable.
+	(symbols_of_load_save): DEFVAR it.
+	(save_header_format, default_save_header_format): New functions.
+	(write_header): Use Vsave_header_format_string here.
+
 2000-07-28  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* pt-pr-code.h (tree_print_code::curr_print_indent_level,
--- a/src/load-save.cc	Fri Jul 28 20:53:40 2000 +0000
+++ b/src/load-save.cc	Wed Aug 02 02:23:30 2000 +0000
@@ -77,6 +77,11 @@
 // "mat-binary", or "hdf5".
 static std::string Vdefault_save_format;
 
+// The format string for the comment line at the top of text-format
+// save files.  Passed to strftime.  Should begin with `#' and contain
+// no newline characters.
+static std::string Vsave_header_format_string;
+
 // The number of decimal digits to use when writing ascii data.
 static int Vsave_precision;
 
@@ -4717,38 +4722,22 @@
 #endif /* HAVE_HDF5 */
     case LS_ASCII:
       {
-	octave_gmtime now;
-	std::string time_string = now.asctime ();
-	time_string = time_string.substr (0, time_string.length () - 1);
-	std::ostream *s = &os;
+	octave_localtime now;
+
+	std::string comment_string = now.strftime (Vsave_header_format_string);
+
+	if (! comment_string.empty ())
+	  {
 #ifdef HAVE_HDF5
-	// for HDF5, write data to a string instead of to os,
-	// and then save the string as the HDF5 file's "comment" field.
-	std::ostrstream ss;
-	if (format == LS_HDF5)
-	  s = &ss;
+	    if (format == LS_HDF5)
+	      {
+		hdf5_ofstream& hs = (hdf5_ofstream&) os;
+		H5Gset_comment (hs.file_id, "/", comment_string.c_str ());
+	      }
+	    else
 #endif /* HAVE_HDF5 */
-	
-	*s << "# Created by Octave " OCTAVE_VERSION ", "
-	   << time_string
-	   << " <"
-	   << octave_env::get_user_name ()
-	   << "@"
-	   << octave_env::get_host_name ()
-	   << ">";
-	
-#ifdef HAVE_HDF5
-	if (format != LS_HDF5)  // don't append newline for HDF5
-#endif /* HAVE_HDF5 */
-	  *s << "\n";
-
-#ifdef HAVE_HDF5
-	if (format == LS_HDF5)
-	  {
-	    hdf5_ofstream& hs = (hdf5_ofstream&) os;
-	    H5Gset_comment (hs.file_id, "/", ss.str ());
+	      os << comment_string << "\n";
 	  }
-#endif /* HAVE_HDF5 */
       }
     break;
 
@@ -5174,6 +5163,35 @@
   return status;
 }
 
+static string
+default_save_header_format (void)
+{
+  return
+    std::string ("# Created by Octave " OCTAVE_VERSION ", %a %b %d %H:%M:%S %Y %Z <")
+    + octave_env::get_user_name ()
+    + std::string ("@")
+    + octave_env::get_host_name ()
+    + std::string (">");
+}
+
+static int
+save_header_format_string (void)
+{
+  int status = 0;
+
+  octave_value v = builtin_any_variable ("save_header_format_string");
+
+  if (v.is_string ())
+    Vsave_header_format_string = v.string_value ();
+  else
+    {
+      gripe_invalid_value_specified ("save_header_format_string");
+      status = -1;
+    }
+
+  return status;
+}
+
 static int
 save_precision (void)
 {
@@ -5212,6 +5230,24 @@
 initial default save format is Octave's text format.\n\
 @end defvr");
 
+  DEFVAR (save_header_format_string, default_save_header_format (),
+	  save_header_format_string,
+    "-*- texinfo -*-\n\
+@defvr {Built-in Variable} save_header_format_string\n\
+This variable specifies the the format string for the comment line\n\
+that is written at the beginning of text-format data files saved by\n\
+Octave.  The format string is passed to @code{strftime} and should\n\
+begin with the character @samp{#} and contain no newline characters.\n\
+If the value of @code{save_header_format_string} is the empty string,\n\
+the header comment is omitted from text-format data files.  The\n\
+default value is\n\
+\n\
+@example\n\
+\"# Created by Octave VERSION, %a %b %d %H:%M:%S %Y %Z <USER@@HOST>\"\n\
+@end example\n\
+@seealso{strftime}\n\
+@end defvr");
+
   DEFVAR (save_precision, 15.0, save_precision,
     "-*- texinfo -*-\n\
 @defvr {Built-in Variable} save_precision\n\
--- a/test/octave.test/string/str2mat-3.m	Fri Jul 28 20:53:40 2000 +0000
+++ b/test/octave.test/string/str2mat-3.m	Wed Aug 02 02:23:30 2000 +0000
@@ -1,1 +1,1 @@
-str2mat (1, 2, 3)
+all (str2mat (1, 2, 3) == setstr ([1; 2; 3]))
--- a/test/octave.test/string/string.exp	Fri Jul 28 20:53:40 2000 +0000
+++ b/test/octave.test/string/string.exp	Wed Aug 02 02:23:30 2000 +0000
@@ -171,7 +171,7 @@
 do_test str2mat-2.m
 
 set test str2mat-3
-set prog_output "error:.*"
+set prog_output "ans = 1"
 do_test str2mat-3.m
 
 set test deblank-1