Mercurial > hg > octave-max
changeset 2774:5ea69876b258
[project @ 1997-03-01 07:29:02 by jwe]
author | jwe |
---|---|
date | Sat, 01 Mar 1997 07:29:07 +0000 |
parents | c8505ac0327c |
children | c80d72d52385 |
files | src/ChangeLog src/time.cc |
diffstat | 2 files changed, 17 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +Sat Mar 1 01:17:21 1997 John W. Eaton <jwe@bevo.che.wisc.edu> + + * strftime.c: Update to current version from FSF. + * time.cc (Fstrftime): Call strftime with buf = 0 to get buffer + size, then call again to actually format the time struct. + Fri Feb 28 01:49:48 1997 John W. Eaton <jwe@bevo.che.wisc.edu> Implement switch statement:
--- a/src/time.cc +++ b/src/time.cc @@ -26,6 +26,8 @@ #include <string> +#include<iostream.h> + #include "defun-dld.h" #include "error.h" #include "help.h" @@ -247,6 +249,7 @@ %T time, 24-hour (hh:mm:ss)\n\ %X locale's time representation (%H:%M:%S)\n\ %Z time zone (EDT), or nothing if no time zone is determinable\n\ + %z offset from GMT\n\ \n\ Date fields:\n\ \n\ @@ -283,15 +286,15 @@ if (! error_state) { - int bufsize = 1024; - char *buf = new char [bufsize]; + const char *fmt_str = fmt.c_str (); + + size_t bufsize = strftime (0, (size_t) UINT_MAX, fmt_str, tm); - while (! strftime (buf, bufsize, fmt.c_str (), tm)) - { - delete [] buf; - bufsize *= 2; - buf = new char [bufsize]; - } + char *buf = new char [++bufsize]; + + buf[0] = '\0'; + + strftime (buf, bufsize, fmt_str, tm); retval = buf;