aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/editfns.c7
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,
874 char *buf = (char *) alloca (size + 1); 874 char *buf = (char *) alloca (size + 1);
875 int result; 875 int result;
876 876
877 buf[0] = '\1';
877 result = emacs_strftime (buf, size, XSTRING (format_string)->data, 878 result = emacs_strftime (buf, size, XSTRING (format_string)->data,
878 (NILP (universal) ? localtime (&value) 879 (NILP (universal) ? localtime (&value)
879 : gmtime (&value))); 880 : gmtime (&value)));
880 if (result > 0 && result < size) 881 if ((result > 0 && result < size) || (result == 0 && buf[0] == '\0'))
881 return build_string (buf); 882 return build_string (buf);
882 if (result < 0)
883 error ("Invalid time format specification");
884 883
885 /* If buffer was too small, make it bigger and try again. */ 884 /* If buffer was too small, make it bigger and try again. */
886 result = emacs_strftime (buf, 0, XSTRING (format_string)->data, 885 result = emacs_strftime (NULL, 0x7fffffff, XSTRING (format_string)->data,
887 (NILP (universal) ? localtime (&value) 886 (NILP (universal) ? localtime (&value)
888 : gmtime (&value))); 887 : gmtime (&value)));
889 size = result + 1; 888 size = result + 1;