# HG changeset patch # User jwe # Date 940973608 0 # Node ID 8c6b4de3bdc89757d2af0b90889c5c68042a780a # Parent 6923abb04e16937f221bf64c6784236c92e09e11 [project @ 1999-10-26 21:33:27 by jwe] diff --git a/liboctave/CRowVector.cc b/liboctave/CRowVector.cc --- a/liboctave/CRowVector.cc +++ b/liboctave/CRowVector.cc @@ -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; } diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,11 @@ +1999-10-26 John W. Eaton + + * 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 * DASSL.cc (DASSL::do_integrate (double)): If we have a function diff --git a/liboctave/dRowVector.cc b/liboctave/dRowVector.cc --- a/liboctave/dRowVector.cc +++ b/liboctave/dRowVector.cc @@ -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; } diff --git a/liboctave/oct-time.cc b/liboctave/oct-time.cc --- a/liboctave/oct-time.cc +++ b/liboctave/oct-time.cc @@ -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; } diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,7 @@ 1999-10-26 John W. Eaton + * 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, diff --git a/src/data.cc b/src/data.cc --- a/src/data.cc +++ b/src/data.cc @@ -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; diff --git a/src/mappers.cc b/src/mappers.cc --- a/src/mappers.cc +++ b/src/mappers.cc @@ -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\