changeset 3322:8c6b4de3bdc8

[project @ 1999-10-26 21:33:27 by jwe]
author jwe
date Tue, 26 Oct 1999 21:33:28 +0000
parents 6923abb04e16
children 511caaa5e98e
files liboctave/CRowVector.cc liboctave/ChangeLog liboctave/dRowVector.cc liboctave/oct-time.cc src/ChangeLog src/data.cc src/mappers.cc
diffstat 7 files changed, 64 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/CRowVector.cc	Tue Oct 26 18:15:41 1999 +0000
+++ b/liboctave/CRowVector.cc	Tue Oct 26 21:33:28 1999 +0000
@@ -791,6 +791,20 @@
 	retval.elem (i) = x1 + 1.0 * i * delta;
       retval.elem (n-1) = x2;
     }
+  else if (n == 1)
+    {
+      if (x1 == x2)
+	{
+	  retval.resize (1);
+	  retval.elem (0) = x1;
+	}
+      else
+	(*current_liboctave_error_handler)
+	  ("linspace: npoints is 1, but x1 != x2");
+    }
+  else
+    (*current_liboctave_error_handler)
+      ("linspace: npoints must be greater than 0");
 
   return retval;
 }
--- a/liboctave/ChangeLog	Tue Oct 26 18:15:41 1999 +0000
+++ b/liboctave/ChangeLog	Tue Oct 26 21:33:28 1999 +0000
@@ -1,3 +1,11 @@
+1999-10-26  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* CRowVector.cc (linspace): Allow npoints == 1 if x1 == x2.
+	* dRowVector.cc (linspace): Ditto.
+
+	* oct-time.cc (Fstrftime): Don't save or delete tm_zone.
+	(octave_time::octave_time (const octave_base_tm&)): Likewise.
+
 1999-10-21  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* DASSL.cc (DASSL::do_integrate (double)): If we have a function
--- a/liboctave/dRowVector.cc	Tue Oct 26 18:15:41 1999 +0000
+++ b/liboctave/dRowVector.cc	Tue Oct 26 21:33:28 1999 +0000
@@ -343,7 +343,7 @@
 {
   RowVector retval;
 
-  if (n > 0)
+  if (n > 1)
     {
       retval.resize (n);
       double delta = (x2 - x1) / (n - 1);
@@ -352,6 +352,20 @@
 	retval.elem (i) = x1 + i * delta;
       retval.elem (n-1) = x2;
     }
+  else if (n == 1)
+    {
+      if (x1 == x2)
+	{
+	  retval.resize (1);
+	  retval.elem (0) = x1;
+	}
+      else
+	(*current_liboctave_error_handler)
+	  ("linspace: npoints is 1, but x1 != x2");
+    }
+  else
+    (*current_liboctave_error_handler)
+      ("linspace: npoints must be greater than 0");
 
   return retval;
 }
--- a/liboctave/oct-time.cc	Tue Oct 26 18:15:41 1999 +0000
+++ b/liboctave/oct-time.cc	Tue Oct 26 21:33:28 1999 +0000
@@ -47,16 +47,12 @@
 
 #if defined (HAVE_TM_ZONE)
   string s = tm.zone ();
-  t.tm_zone = strsave (s.c_str ());
+  t.tm_zone = s.c_str ();
 #endif
 
   ot_unix_time = mktime (&t);
 
   ot_usec = tm.usec ();
-
-#if defined (HAVE_TM_ZONE)
-  delete [] t.tm_zone;
-#endif
 }
 
 string
@@ -142,7 +138,7 @@
   t.tm_isdst = tm_isdst;
 
 #if defined (HAVE_TM_ZONE)
-  t.tm_zone = strsave (tm_zone.c_str ());
+  t.tm_zone = tm_zone.c_str ();
 #endif
 
   const char *fmt_str = fmt.c_str ();
@@ -166,10 +162,6 @@
 
   delete [] buf;
 
-#if defined (HAVE_TM_ZONE)
-  delete [] t.tm_zone;
-#endif
-
   return retval;
 }
 
--- a/src/ChangeLog	Tue Oct 26 18:15:41 1999 +0000
+++ b/src/ChangeLog	Tue Oct 26 21:33:28 1999 +0000
@@ -1,5 +1,7 @@
 1999-10-26  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
+	* data.cc (Flinspace): Let linspace functions handle errors.
+
 	* mkgendoc (print_doc_string): Handle quoted names.
 
 	* file-io.cc (symbols_of_file_io): Use DEFCONSTX for SEEK_SET,
--- a/src/data.cc	Tue Oct 26 18:15:41 1999 +0000
+++ b/src/data.cc	Tue Oct 26 21:33:28 1999 +0000
@@ -1140,40 +1140,35 @@
 
   if (! error_state)
     {
-      if (npoints > 1)
-	{
-	  octave_value arg_1 = args(0);
-	  octave_value arg_2 = args(1);
+      octave_value arg_1 = args(0);
+      octave_value arg_2 = args(1);
 
-	  if (arg_1.is_complex_type () || arg_2.is_complex_type ())
+      if (arg_1.is_complex_type () || arg_2.is_complex_type ())
+	{
+	  Complex x1 = arg_1.complex_value ();
+	  Complex x2 = arg_2.complex_value ();
+
+	  if (! error_state)
 	    {
-	      Complex x1 = arg_1.complex_value ();
-	      Complex x2 = arg_2.complex_value ();
+	      ComplexRowVector rv = linspace (x1, x2, npoints);
 
 	      if (! error_state)
-		{
-		  ComplexRowVector rv = linspace (x1, x2, npoints);
-
-		  if (! error_state)
-		    retval (0) = octave_value (rv, 0);
-		}
-	    }
-	  else
-	    {
-	      double x1 = arg_1.double_value ();
-	      double x2 = arg_2.double_value ();
-
-	      if (! error_state)
-		{
-		  RowVector rv = linspace (x1, x2, npoints);
-
-		  if (! error_state)
-		    retval (0) = octave_value (rv, 0);
-		}
+		retval (0) = octave_value (rv, 0);
 	    }
 	}
       else
-	error ("linspace: npoints must be greater than 2");
+	{
+	  double x1 = arg_1.double_value ();
+	  double x2 = arg_2.double_value ();
+
+	  if (! error_state)
+	    {
+	      RowVector rv = linspace (x1, x2, npoints);
+
+	      if (! error_state)
+		retval (0) = octave_value (rv, 0);
+	    }
+	}
     }
 
   return retval;
--- a/src/mappers.cc	Tue Oct 26 18:15:41 1999 +0000
+++ b/src/mappers.cc	Tue Oct 26 21:33:28 1999 +0000
@@ -167,7 +167,7 @@
 @end deftypefn");
 
   DEFUN_MAPPER (angle, 0, 0, 0, arg, arg, 0, 0.0, 0.0, 0,
-    "See arg.")
+    "See arg.");
 
   DEFUN_MAPPER (arg, 0, 0, 0, arg, arg, 0, 0.0, 0.0, 0,
     "-*- texinfo -*-\n\