diff options
author | Richard M. Stallman <rms@gnu.org> | 1997-07-29 02:29:32 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1997-07-29 02:29:32 +0000 |
commit | bfbcc5eed0a53ef546ff422212114bb48677aeff (patch) | |
tree | b9f5922c3b457d2fc1efc5957b4eb6d754fa61e7 /src/editfns.c | |
parent | 9a2fe7b2040ff4736f731ba546b15de3d9db82e1 (diff) | |
download | emacs-bfbcc5eed0a53ef546ff422212114bb48677aeff.tar.gz |
(Fformat_time_string): Don't hang if strftime produces
an empty string. Fix arguments of second call to strftime.
Remove check for result being negative, this cannot happen.
Diffstat (limited to 'src/editfns.c')
-rw-r--r-- | src/editfns.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/editfns.c b/src/editfns.c index fa4f486c699..e49f53ff6b3 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -874,16 +874,15 @@ DEFUN ("format-time-string", Fformat_time_string, Sformat_time_string, 1, 3, 0, char *buf = (char *) alloca (size + 1); int result; + buf[0] = '\1'; result = emacs_strftime (buf, size, XSTRING (format_string)->data, (NILP (universal) ? localtime (&value) : gmtime (&value))); - if (result > 0 && result < size) + if ((result > 0 && result < size) || (result == 0 && buf[0] == '\0')) return build_string (buf); - if (result < 0) - error ("Invalid time format specification"); /* If buffer was too small, make it bigger and try again. */ - result = emacs_strftime (buf, 0, XSTRING (format_string)->data, + result = emacs_strftime (NULL, 0x7fffffff, XSTRING (format_string)->data, (NILP (universal) ? localtime (&value) : gmtime (&value))); size = result + 1; |