# HG changeset patch # User jwe # Date 1193291456 0 # Node ID 97db94ae2cf09eda8dc817597155cd06093cb550 # Parent faff87ff9d5a2fd33cb0aa0a21dcc2f0edd82a76 [project @ 2007-10-25 05:50:55 by jwe] diff -r faff87ff9d5a -r 97db94ae2cf0 liboctave/ChangeLog --- a/liboctave/ChangeLog Wed Oct 24 21:09:44 2007 +0000 +++ b/liboctave/ChangeLog Thu Oct 25 05:50:56 2007 +0000 @@ -1,3 +1,12 @@ +2007-10-25 John W. Eaton + + * oct-time.cc (octave_gmtime::init, octave_localtime::init): + Call unix_time on arg instead of relying on conversion operator. + + * oct-time.h (octave_time::double_value): New function. + (octave_time::operator double () const): Delete. + (octave_time::operator time_t () const): Delete. + 2007-10-24 John W. Eaton * strptime.c: Also compile if OCTAVE_HAVE_BROKEN_STRPTIME is defined. diff -r faff87ff9d5a -r 97db94ae2cf0 liboctave/oct-time.cc --- a/liboctave/oct-time.cc Wed Oct 24 21:09:44 2007 +0000 +++ b/liboctave/oct-time.cc Thu Oct 25 05:50:56 2007 +0000 @@ -316,7 +316,7 @@ { tm_usec = ot.usec (); - time_t t = ot; + time_t t = ot.unix_time (); octave_base_tm::init (localtime (&t)); } @@ -326,7 +326,7 @@ { tm_usec = ot.usec (); - time_t t = ot; + time_t t = ot.unix_time (); octave_base_tm::init (gmtime (&t)); } diff -r faff87ff9d5a -r 97db94ae2cf0 liboctave/oct-time.h --- a/liboctave/oct-time.h Wed Oct 24 21:09:44 2007 +0000 +++ b/liboctave/oct-time.h Thu Oct 25 05:50:56 2007 +0000 @@ -70,9 +70,7 @@ void stamp (void); - operator double () const { return ot_unix_time + ot_usec / 1e6; } - - operator time_t () const { return ot_unix_time; } + double double_value (void) const { return ot_unix_time + ot_usec / 1e6; } time_t unix_time (void) const { return ot_unix_time; } diff -r faff87ff9d5a -r 97db94ae2cf0 src/ChangeLog --- a/src/ChangeLog Wed Oct 24 21:09:44 2007 +0000 +++ b/src/ChangeLog Thu Oct 25 05:50:56 2007 +0000 @@ -1,3 +1,20 @@ +2007-10-25 John W. Eaton + + * Makefile.in (graphics.h): Use $(AWK) instead of awk. + + * DLD-FUNCTIONS/time.cc (Ftime, Fmktime): Avoid unnecessary cast. + + * data.cc (Ftic, Ftoc): Call double_value on octave_time objects + instead of relying on conversion operator. + * ov.cc (octave_value::octave_value (octave_time)): Likewise. + + * variables.cc (symbol_out_of_date): Use explicit conversion to + time_t instead of relying on conversion operator. + * ov-fcn-handle.cc (octave_fcn_handle::subsref): Likewise. + + * data.cc (tic_toc_timestamp): Rename from __tic_toc_timestamp__. + Change all uses. + 2007-10-24 David Bateman * ov-intx.h (OCTAVE_VALUE_INT_MATRIX_T::OCTAVE_VALUE_INT_MATRIX_T diff -r faff87ff9d5a -r 97db94ae2cf0 src/DLD-FUNCTIONS/sort.cc --- a/src/DLD-FUNCTIONS/sort.cc Wed Oct 24 21:09:44 2007 +0000 +++ b/src/DLD-FUNCTIONS/sort.cc Thu Oct 25 05:50:56 2007 +0000 @@ -1240,8 +1240,10 @@ } } - // FIXME Perhaps sort should be made a method of the octave_value classes - // and then the mess of if statements both might be replaced with + // FIXME -- Perhaps sort should be made a method of the octave_value + // classes and then the mess of if statements below might be + // replaced with + // // retval = arg.sort (dim, smode, return_idx); if (arg.is_real_type ()) diff -r faff87ff9d5a -r 97db94ae2cf0 src/DLD-FUNCTIONS/time.cc --- a/src/DLD-FUNCTIONS/time.cc Wed Oct 24 21:09:44 2007 +0000 +++ b/src/DLD-FUNCTIONS/time.cc Thu Oct 25 05:50:56 2007 +0000 @@ -89,7 +89,7 @@ octave_value retval; if (args.length () == 0) - retval = static_cast (octave_time ()); + retval = octave_time (); else print_usage (); @@ -206,7 +206,7 @@ octave_base_tm tm = extract_tm (map); if (! error_state) - retval = static_cast (octave_time (tm)); + retval = octave_time (tm); else error ("mktime: invalid TMSTRUCT argument"); } diff -r faff87ff9d5a -r 97db94ae2cf0 src/Makefile.in --- a/src/Makefile.in Wed Oct 24 21:09:44 2007 +0000 +++ b/src/Makefile.in Thu Oct 25 05:50:56 2007 +0000 @@ -369,7 +369,7 @@ graphics.h: graphics.h.in genprops.awk @echo making $@ - @awk -f $(srcdir)/genprops.awk $< > $@-t + @$(AWK) -f $(srcdir)/genprops.awk $< > $@-t @$(simple-move-if-change-rule) PKG_ADD: $(DLD_DEF_FILES) diff -r faff87ff9d5a -r 97db94ae2cf0 src/data.cc --- a/src/data.cc Wed Oct 24 21:09:44 2007 +0000 +++ b/src/data.cc Thu Oct 25 05:50:56 2007 +0000 @@ -2964,7 +2964,7 @@ BINARY_OP_DEFUN_BODY (op_el_or); } -static double __tic_toc_timestamp__ = -1.0; +static double tic_toc_timestamp = -1.0; DEFUN (tic, args, nargout, "-*- texinfo -*-\n\ @@ -3019,15 +3019,20 @@ @end deftypefn") { octave_value retval; + int nargin = args.length (); if (nargin != 0) warning ("tic: ignoring extra arguments"); + octave_time now; + + double tmp = now.double_value (); + if (nargout > 0) - retval = static_cast (static_cast (octave_time ()) * 1.0e6); + retval = static_cast (1e6 * tmp); else - __tic_toc_timestamp__= static_cast(octave_time ()); + tic_toc_timestamp = tmp; return retval; } @@ -3038,24 +3043,30 @@ See tic.\n\ @end deftypefn") { - double sec = static_cast(octave_time ()); octave_value retval; + int nargin = args.length (); if (nargin != 0) warning ("tic: ignoring extra arguments"); - if (__tic_toc_timestamp__ < 0) + if (tic_toc_timestamp < 0) { warning ("toc called before timer set"); if (nargout > 0) - retval = Matrix(); + retval = Matrix (); } - else if (nargout > 0) - retval = sec - __tic_toc_timestamp__; else - octave_stdout << "Elapsed time is " << sec - __tic_toc_timestamp__ - << " seconds.\n"; + { + octave_time now; + + double tmp = now.double_value () - tic_toc_timestamp; + + if (nargout > 0) + retval = tmp; + else + octave_stdout << "Elapsed time is " << tmp << " seconds.\n"; + } return retval; } diff -r faff87ff9d5a -r 97db94ae2cf0 src/ov-fcn-handle.cc --- a/src/ov-fcn-handle.cc Wed Oct 24 21:09:44 2007 +0000 +++ b/src/ov-fcn-handle.cc Thu Oct 25 05:50:56 2007 +0000 @@ -92,7 +92,8 @@ { std::string ff_nm = f->fcn_file_name (); - time_t tp = f->time_parsed (); + octave_time ottp = f->time_parsed (); + time_t tp = ottp.unix_time (); if (ff_nm.empty ()) { diff -r faff87ff9d5a -r 97db94ae2cf0 src/ov.cc --- a/src/ov.cc Wed Oct 24 21:09:44 2007 +0000 +++ b/src/ov.cc Thu Oct 25 05:50:56 2007 +0000 @@ -348,7 +348,7 @@ #endif octave_value::octave_value (octave_time t) - : rep (new octave_scalar (t)) + : rep (new octave_scalar (t.double_value ())) { } diff -r faff87ff9d5a -r 97db94ae2cf0 src/variables.cc --- a/src/variables.cc Wed Oct 24 21:09:44 2007 +0000 +++ b/src/variables.cc Thu Oct 25 05:50:56 2007 +0000 @@ -1008,7 +1008,8 @@ if (tc < Vlast_prompt_time || (relative && tc < Vlast_chdir_time)) { - time_t tp = fcn->time_parsed (); + octave_time ottp = fcn->time_parsed (); + time_t tp = ottp.unix_time (); std::string nm = fcn->is_nested_function () ? fcn->parent_fcn_name () : fcn->name ();