]> git.eshelyaron.com Git - emacs.git/commitdiff
Move explanations from ChangeLog to the source.
authorEli Zaretskii <eliz@gnu.org>
Sat, 25 Mar 2006 08:56:07 +0000 (08:56 +0000)
committerEli Zaretskii <eliz@gnu.org>
Sat, 25 Mar 2006 08:56:07 +0000 (08:56 +0000)
src/ChangeLog
src/editfns.c

index ccc1f3923c45d0ad333b079d2f6a2164f0bbea90..15267b42d4562237627919f1ae578e45217af935 100644 (file)
@@ -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>
 
index c4f8b95d81036dc56fa8494d8fc0228c0c478f56..888bbe3062b2adcbe212c6b1d603dc012774a52e 100644 (file)
@@ -1724,6 +1724,8 @@ DOW and ZONE.)  */)
   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 @@ but this is considered obsolete.  */)
 
   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");