comparison src/editfns.c @ 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 55e66496ae1a
children 1e68e7f3b824 e6bf73e43cf4
comparison
equal deleted inserted replaced
69672:e9eec692c5d8 69673:23a81b585dd1
1722 XSETFASTINT (list_args[0], decoded_time->tm_sec); 1722 XSETFASTINT (list_args[0], decoded_time->tm_sec);
1723 XSETFASTINT (list_args[1], decoded_time->tm_min); 1723 XSETFASTINT (list_args[1], decoded_time->tm_min);
1724 XSETFASTINT (list_args[2], decoded_time->tm_hour); 1724 XSETFASTINT (list_args[2], decoded_time->tm_hour);
1725 XSETFASTINT (list_args[3], decoded_time->tm_mday); 1725 XSETFASTINT (list_args[3], decoded_time->tm_mday);
1726 XSETFASTINT (list_args[4], decoded_time->tm_mon + 1); 1726 XSETFASTINT (list_args[4], decoded_time->tm_mon + 1);
1727 /* On 64-bit machines an int is narrower than EMACS_INT, thus the
1728 cast below avoids overflow in int arithmetics. */
1727 XSETINT (list_args[5], TM_YEAR_BASE + (EMACS_INT) decoded_time->tm_year); 1729 XSETINT (list_args[5], TM_YEAR_BASE + (EMACS_INT) decoded_time->tm_year);
1728 XSETFASTINT (list_args[6], decoded_time->tm_wday); 1730 XSETFASTINT (list_args[6], decoded_time->tm_wday);
1729 list_args[7] = (decoded_time->tm_isdst)? Qt : Qnil; 1731 list_args[7] = (decoded_time->tm_isdst)? Qt : Qnil;
1730 1732
1731 /* Make a copy, in case gmtime modifies the struct. */ 1733 /* Make a copy, in case gmtime modifies the struct. */
1849 struct tm *tm; 1851 struct tm *tm;
1850 register char *tem; 1852 register char *tem;
1851 1853
1852 if (! lisp_time_argument (specified_time, &value, NULL)) 1854 if (! lisp_time_argument (specified_time, &value, NULL))
1853 error ("Invalid time specification"); 1855 error ("Invalid time specification");
1856 /* Do not use ctime, since it has undefined behavior with
1857 out-of-range time stamps. This avoids a core dump triggered by
1858 (current-time-string '(2814749767106 0)) on 64-bit Solaris 8. See
1859 <http://www.opengroup.org/austin/mailarchives/ag/msg09294.html>
1860 for more details about this portability problem. */
1854 tm = localtime (&value); 1861 tm = localtime (&value);
1862 /* Checking for out-of-range time stamps avoids buffer overruns that
1863 cause core dump on some systems (e.g., 64-bit Solaris), and also
1864 preserves the historic behavior of always returning a fixed-size
1865 24-character string. */
1855 if (! (tm && -999 - TM_YEAR_BASE <= tm->tm_year 1866 if (! (tm && -999 - TM_YEAR_BASE <= tm->tm_year
1856 && tm->tm_year <= 9999 - TM_YEAR_BASE)) 1867 && tm->tm_year <= 9999 - TM_YEAR_BASE))
1857 error ("Specified time is not representable"); 1868 error ("Specified time is not representable");
1858 tem = asctime (tm); 1869 tem = asctime (tm);
1859 1870