On 22-Feb-2005, Laurent Mazet <[EMAIL PROTECTED]> wrote: | On Tue, 22 Feb 2005 06:57:53 -0600 | Rafael Laboissiere <[EMAIL PROTECTED]> wrote: | > package octave2.1 | > forwarded 296375 [EMAIL PROTECTED] | > thank | > | > | > Dear Octave maintainers, | > | > I confirm that the problem reported below against the octave2.1 Debian | > package persists in Octave 2.1.65. | > | > tm.year = 2000; | > tm.mon = 1; | > tm.day = 1; | > | > strftime("%Y%m%d", tm) | | This patch fixs the uncomplet tm structure
Thanks for the patch. I chose a slightly different solution. jwe src/ChangeLog: 2005-02-22 John W. Eaton <[EMAIL PROTECTED]> * oct-map.cc (Octave_map::intfield, Octave_map::stringfield): New functions. * oct-map.h: Provide decls. * DLD-FUNCTIONS/time.cc (extract_tm): Use intfield and stringfield to access map elements. Index: src/oct-map.cc =================================================================== RCS file: /usr/local/cvsroot/octave/src/oct-map.cc,v retrieving revision 1.37 diff -u -r1.37 oct-map.cc --- src/oct-map.cc 9 Nov 2004 18:31:26 -0000 1.37 +++ src/oct-map.cc 22 Feb 2005 15:22:38 -0000 @@ -42,6 +42,33 @@ return p != end () ? p->second : Cell (); } +int +Octave_map::intfield (const std::string& k, int def_val) const +{ + int retval = def_val; + + Cell c = contents (k); + + if (! c.is_empty ()) + retval = c(0).int_value (); + + return retval; +} + +std::string +Octave_map::stringfield (const std::string& k, + const std::string& def_val) const +{ + std::string retval = def_val; + + Cell c = contents (k); + + if (! c.is_empty ()) + retval = c(0).string_value (); + + return retval; +} + string_vector Octave_map::keys (void) const { Index: src/oct-map.h =================================================================== RCS file: /usr/local/cvsroot/octave/src/oct-map.h,v retrieving revision 1.35 diff -u -r1.35 oct-map.h --- src/oct-map.h 9 Nov 2004 18:31:26 -0000 1.35 +++ src/oct-map.h 22 Feb 2005 15:22:38 -0000 @@ -99,6 +99,11 @@ Cell contents (const_iterator p) const { return contents (key(p)); } + int intfield (const std::string& k, int def_val = 0) const; + + std::string stringfield (const std::string& k, + const std::string& def_val = std::string ()) const; + const_iterator seek (const std::string& k) const { return map.find (k); } bool contains (const std::string& k) const Index: src/DLD-FUNCTIONS/time.cc =================================================================== RCS file: /usr/local/cvsroot/octave/src/DLD-FUNCTIONS/time.cc,v retrieving revision 1.18 diff -u -r1.18 time.cc --- src/DLD-FUNCTIONS/time.cc 22 Sep 2004 12:38:10 -0000 1.18 +++ src/DLD-FUNCTIONS/time.cc 22 Feb 2005 15:22:39 -0000 @@ -60,17 +60,17 @@ { octave_base_tm tm; - tm.usec (m.contents ("usec")(0) . int_value ()); - tm.sec (m.contents ("sec")(0) . int_value ()); - tm.min (m.contents ("min")(0) . int_value ()); - tm.hour (m.contents ("hour")(0) . int_value ()); - tm.mday (m.contents ("mday")(0) . int_value ()); - tm.mon (m.contents ("mon")(0) . int_value ()); - tm.year (m.contents ("year")(0) . int_value ()); - tm.wday (m.contents ("wday")(0) . int_value ()); - tm.yday (m.contents ("yday")(0) . int_value ()); - tm.isdst (m.contents ("isdst")(0) . int_value ()); - tm.zone (m.contents ("zone")(0) . string_value ()); + tm.usec (m.intfield ("usec")); + tm.sec (m.intfield ("sec")); + tm.min (m.intfield ("min")); + tm.hour (m.intfield ("hour")); + tm.mday (m.intfield ("mday")); + tm.mon (m.intfield ("mon")); + tm.year (m.intfield ("year")); + tm.wday (m.intfield ("wday")); + tm.yday (m.intfield ("yday")); + tm.isdst (m.intfield ("isdst")); + tm.zone (m.stringfield ("zone")); return tm; } -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]