From bug-request at octave dot org Tue Dec 20 10:59:24 2005 Subject: Re: Time Function Docstrings From: William Poetra Yoga Hadisoeseno To: Bill Denney , bug@octave.org Date: Wed, 21 Dec 2005 00:57:50 +0800 ------=_Part_12625_16693522.1135097870123 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 12/20/05, Bill Denney wrote: > Here is a diff for several time function docstrings. It adds see alsos t= o > all the ones that I found. > Actually, I think this is more appropriate for octave-bug. Bill, would you like to combine your patch with mine (it's attached)? I've only made it today. John: I've changed the meaning of nchars (returned from strptime) in my patch (attached). I hope it's useful ;) -- William Poetra Yoga Hadisoeseno ------=_Part_12625_16693522.1135097870123 Content-Type: text/plain; name=time.diff.txt; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="time.diff.txt" Index: liboctave/oct-time.cc =================================================================== RCS file: /cvs/octave/liboctave/oct-time.cc,v retrieving revision 1.20 diff -u -r1.20 oct-time.cc --- liboctave/oct-time.cc 26 Apr 2005 19:24:29 -0000 1.20 +++ liboctave/oct-time.cc 20 Dec 2005 16:53:23 -0000 at @ -347,7 +347,10 @@ char *q = oct_strptime (p, fmt.c_str (), &t); - nchars = p - q; + if (q) + nchars = q - p + 1; + else + nchars = 0; delete [] p; Index: src/DLD-FUNCTIONS/time.cc =================================================================== RCS file: /cvs/octave/src/DLD-FUNCTIONS/time.cc,v retrieving revision 1.20 diff -u -r1.20 time.cc --- src/DLD-FUNCTIONS/time.cc 26 Apr 2005 19:24:35 -0000 1.20 +++ src/DLD-FUNCTIONS/time.cc 20 Dec 2005 16:53:24 -0000 at @ -217,8 +217,9 @@ DEFUN_DLD (strftime, args, , "-*- texinfo -*-\n\ - at deftypefn {Loadable Function} {} strftime (@var{tm_struct})\n\ -Format a time structure in a flexible way using at samp{%} substitutions\n\ + at deftypefn {Loadable Function} {} strftime (@var{fmt}, @var{tm_struct})\n\ +Format the time structure at var{tm_struct} in a flexible way using the\n\ +format string at var{fmt}, which contains @samp{%} substitutions\n\ similar to those in at code{printf} dot Except where noted, substituted\n\ fields have a fixed size; numeric fields are padded if necessary.\n\ Padding is with zeros by default; for fields that display a single\n\ at @ -364,7 +365,9 @@ at item %Y\n\ Year (1970-).\n\ at end table\n\ - at end deftypefn\n") + at end deftypefn\n\ +\n\ + at seealso{strptime, localtime, time}") { octave_value retval; at @ -400,9 +403,15 @@ DEFUN_DLD (strptime, args, , "-*- texinfo -*-\n\ at deftypefn {Loadable Function} {[@var{tm_struct}, @var{nchars}] =} strptime (@var{str}, @var{fmt})\n\ -Convert the string at var{str} to a time structure under the control of\n\ -the format at var{fmt} dot \n\ - at end deftypefn") +Convert the string at var{str} to the time structure @var{tm_struct} under\n\ +the control of the format string at var{fmt} dot \n\ +\n\ +If at var{fmt} fails to match, @var{nchars} is 0; otherwise it is set to the\n\ +position of last matched character plus 1. Always check for this unless\n\ +you're absolutely sure the date string will be parsed correctly.\n\ + at end deftypefn\n\ +\n\ + at seealso{strftime, localtime, time}") { octave_value_list retval; ------=_Part_12625_16693522.1135097870123-- ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------