changeset 69673:23a81b585dd1

Move explanations from ChangeLog to the source.
author Eli Zaretskii <eliz@gnu.org>
date Sat, 25 Mar 2006 08:56:07 +0000
parents e9eec692c5d8
children 1d0de172f9fa
files src/ChangeLog src/editfns.c
diffstat 2 files changed, 16 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Sat Mar 25 07:40:46 2006 +0000
+++ b/src/ChangeLog	Sat Mar 25 08:56:07 2006 +0000
@@ -1,22 +1,11 @@
 2006-03-24  Paul Eggert  <eggert@cs.ucla.edu>
 
-	* editfns.c: Do not use ctime, since it has undefined behavior
-	with out-of-range time stamps.  This fixes a bug where
-	(current-time-string '(2814749767106 0)) would make Emacs dump
-	core on 64-bit Solaris 8.  The fix is to use localtime+asctime
-	(checking for in-range results) instead of ctime.  Please see
-	<http://www.opengroup.org/austin/mailarchives/ag/msg09294.html>
-	for more details about this portability problem.
-	(TM_YEAR_BASE): Move up, so the changes below can use it.
+	* editfns.c (TM_YEAR_BASE): Move up, so the changes below can use it.
 	(Fdecode_time, Fencode_time): Use TM_YEAR_BASE instead of 1900.
-	(Fdecode_time): Cast tm_year to EMACS_INT, to avoid overflow when
-	int is narrower than EMACS_INT.
-	(Fcurrent_time_string): As with Fformat_time_string, report an
-	invalid time specification if the argument is invalid.  Also,
-	check for out-of-range time stamps; this prevents a buffer overrun
-	that causes Emacs to dump core on 64-bit Solaris sparc, and it
-	preserves the historic behavior of always returning a fixed-size
-	string.
+	(Fdecode_time): Cast tm_year to EMACS_INT.
+	(Fcurrent_time_string): Report an invalid time specification if
+	the argument is invalid.  Also, check for out-of-range time
+	stamps.
 
 2006-03-24  Kim F. Storm  <storm@cua.dk>
 
--- a/src/editfns.c	Sat Mar 25 07:40:46 2006 +0000
+++ b/src/editfns.c	Sat Mar 25 08:56:07 2006 +0000
@@ -1724,6 +1724,8 @@
   XSETFASTINT (list_args[2], decoded_time->tm_hour);
   XSETFASTINT (list_args[3], decoded_time->tm_mday);
   XSETFASTINT (list_args[4], decoded_time->tm_mon + 1);
+  /* On 64-bit machines an int is narrower than EMACS_INT, thus the
+     cast below avoids overflow in int arithmetics.  */
   XSETINT (list_args[5], TM_YEAR_BASE + (EMACS_INT) decoded_time->tm_year);
   XSETFASTINT (list_args[6], decoded_time->tm_wday);
   list_args[7] = (decoded_time->tm_isdst)? Qt : Qnil;
@@ -1851,7 +1853,16 @@
 
   if (! lisp_time_argument (specified_time, &value, NULL))
     error ("Invalid time specification");
+  /* Do not use ctime, since it has undefined behavior with
+     out-of-range time stamps.  This avoids a core dump triggered by
+     (current-time-string '(2814749767106 0)) on 64-bit Solaris 8. See
+     <http://www.opengroup.org/austin/mailarchives/ag/msg09294.html>
+     for more details about this portability problem.  */
   tm = localtime (&value);
+  /* Checking for out-of-range time stamps avoids buffer overruns that
+     cause core dump on some systems (e.g., 64-bit Solaris), and also
+     preserves the historic behavior of always returning a fixed-size
+     24-character string.  */
   if (! (tm && -999 - TM_YEAR_BASE <= tm->tm_year
 	 && tm->tm_year <= 9999 - TM_YEAR_BASE))
     error ("Specified time is not representable");