aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2012-05-03 13:04:29 -0700
committerPaul Eggert2012-05-03 13:04:29 -0700
commitab0fa4e4ba0b2b93a9ef007842523d8d5f9eb758 (patch)
tree9adfb1831b29c6f4d68b5d1ea6de54f05617bc6a
parentf7ae6719123ad5f4f505290621810318d9ee5484 (diff)
downloademacs-ab0fa4e4ba0b2b93a9ef007842523d8d5f9eb758.tar.gz
emacs-ab0fa4e4ba0b2b93a9ef007842523d8d5f9eb758.zip
Do not limit current-time-string to years 1000..9999.
* src/editfns.c (TM_YEAR_IN_ASCTIME_RANGE): Remove. (Fcurrent_time_string): Support any year that is supported by the underlying localtime representation. Don't use asctime, as it has undefined behavior for years outside the range -999..9999. * doc/lispref/os.texi (Time of Day): Do not limit current-time-string to years 1000..9999. * etc/NEWS: Do not limit current-time-string to years 1000..9999.
-rw-r--r--doc/lispref/ChangeLog5
-rw-r--r--doc/lispref/os.texi13
-rw-r--r--etc/ChangeLog4
-rw-r--r--etc/NEWS6
-rw-r--r--src/ChangeLog8
-rw-r--r--src/editfns.c39
6 files changed, 51 insertions, 24 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index c3eadfc8558..3be41afe975 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,8 @@
12012-05-03 Paul Eggert <eggert@cs.ucla.edu>
2
3 * os.texi (Time of Day): Do not limit current-time-string
4 to years 1000..9999.
5
12012-05-02 Chong Yidong <cyd@gnu.org> 62012-05-02 Chong Yidong <cyd@gnu.org>
2 7
3 * display.texi (Font Lookup): 8 * display.texi (Font Lookup):
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi
index d825a3f18c4..0fdb3e20694 100644
--- a/doc/lispref/os.texi
+++ b/doc/lispref/os.texi
@@ -1196,11 +1196,14 @@ sections.
1196 1196
1197@defun current-time-string &optional time-value 1197@defun current-time-string &optional time-value
1198This function returns the current time and date as a human-readable 1198This function returns the current time and date as a human-readable
1199string. The format of the string is unvarying; the number of 1199string. The format does not vary for the initial part of the string,
1200characters used for each part is always the same, so you can reliably 1200which contains the day of week, month, day of month, and time of day
1201use @code{substring} to extract pieces of it. You should count 1201in that order: the number of characters used for these fields is
1202always the same, so you can reliably
1203use @code{substring} to extract them. You should count
1202characters from the beginning of the string rather than from the end, 1204characters from the beginning of the string rather than from the end,
1203as additional information may some day be added at the end. 1205as the year might not have exactly four digits, and additional
1206information may some day be added at the end.
1204 1207
1205The argument @var{time-value}, if given, specifies a time to format 1208The argument @var{time-value}, if given, specifies a time to format
1206(represented as a list of integers), instead of the current time. 1209(represented as a list of integers), instead of the current time.
@@ -2301,7 +2304,7 @@ the notification never expires. Default value is -1.
2301@item :urgency @var{urgency} 2304@item :urgency @var{urgency}
2302The urgency level. It can be @code{low}, @code{normal}, or @code{critical}. 2305The urgency level. It can be @code{low}, @code{normal}, or @code{critical}.
2303 2306
2304@item :action-items 2307@item :action-items
2305When this keyword is given, the @var{title} string of the actions is 2308When this keyword is given, the @var{title} string of the actions is
2306interpreted as icon name. 2309interpreted as icon name.
2307 2310
diff --git a/etc/ChangeLog b/etc/ChangeLog
index f34e5d6d688..2a6cd719220 100644
--- a/etc/ChangeLog
+++ b/etc/ChangeLog
@@ -1,3 +1,7 @@
12012-05-03 Paul Eggert <eggert@cs.ucla.edu>
2
3 * NEWS: Do not limit current-time-string to years 1000..9999.
4
12012-04-27 Jambunathan K <kjambunathan@gmail.com> 52012-04-27 Jambunathan K <kjambunathan@gmail.com>
2 6
3 * org/OrgOdtStyles.xml (OrgDescriptionList): Modify style. With 7 * org/OrgOdtStyles.xml (OrgDescriptionList): Modify style. With
diff --git a/etc/NEWS b/etc/NEWS
index cd15273c3db..a9e4a7832ed 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -197,6 +197,12 @@ in the presence of quoting, such as file completion in shell buffers.
197 197
198*** New function `completion-table-subvert' to use an existing completion 198*** New function `completion-table-subvert' to use an existing completion
199table, but with a different prefix. 199table, but with a different prefix.
200
201** Time
202
203*** `current-time-string' no longer requires that its argument's year
204must be in the range 1000..9999. It now works with any year supported
205by the underlying C implementation.
200 206
201* Changes in Emacs 24.2 on non-free operating systems 207* Changes in Emacs 24.2 on non-free operating systems
202 208
diff --git a/src/ChangeLog b/src/ChangeLog
index bf297616e82..2c2902e937a 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
12012-05-03 Paul Eggert <eggert@cs.ucla.edu>
2
3 Do not limit current-time-string to years 1000..9999.
4 * editfns.c (TM_YEAR_IN_ASCTIME_RANGE): Remove.
5 (Fcurrent_time_string): Support any year that is supported by the
6 underlying localtime representation. Don't use asctime, as it
7 has undefined behavior for years outside the range -999..9999.
8
12012-05-02 Paul Eggert <eggert@cs.ucla.edu> 92012-05-02 Paul Eggert <eggert@cs.ucla.edu>
2 10
3 Fix race conditions involving setenv, gmtime, localtime, asctime. 11 Fix race conditions involving setenv, gmtime, localtime, asctime.
diff --git a/src/editfns.c b/src/editfns.c
index b52bc0c2a99..d266ca9951d 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -73,13 +73,6 @@ extern char **environ;
73 73
74#define TM_YEAR_BASE 1900 74#define TM_YEAR_BASE 1900
75 75
76/* Nonzero if TM_YEAR is a struct tm's tm_year value that causes
77 asctime to have well-defined behavior. */
78#ifndef TM_YEAR_IN_ASCTIME_RANGE
79# define TM_YEAR_IN_ASCTIME_RANGE(tm_year) \
80 (1000 - TM_YEAR_BASE <= (tm_year) && (tm_year) <= 9999 - TM_YEAR_BASE)
81#endif
82
83#ifdef WINDOWSNT 76#ifdef WINDOWSNT
84extern Lisp_Object w32_get_internal_run_time (void); 77extern Lisp_Object w32_get_internal_run_time (void);
85#endif 78#endif
@@ -1943,29 +1936,37 @@ but this is considered obsolete. */)
1943{ 1936{
1944 time_t value; 1937 time_t value;
1945 struct tm *tm; 1938 struct tm *tm;
1946 char *tem = NULL; 1939 char buf[sizeof "Mon Apr 30 12:49:17 " + INT_STRLEN_BOUND (int) + 1];
1947 char buf[sizeof "Mon Apr 30 12:49:17 2012" - 1]; 1940 int len IF_LINT (= 0);
1948 1941
1949 if (! lisp_time_argument (specified_time, &value, NULL)) 1942 if (! lisp_time_argument (specified_time, &value, NULL))
1950 error ("Invalid time specification"); 1943 error ("Invalid time specification");
1951 1944
1952 /* Convert to a string, checking for out-of-range time stamps. 1945 /* Convert to a string in ctime format, except without the trailing
1953 Omit the trailing newline. 1946 newline, and without the 4-digit year limit. Don't use asctime
1954 Don't use 'ctime', as that might dump core if VALUE is out of 1947 or ctime, as they might dump core if the year is outside the
1955 range. */ 1948 range -999 .. 9999. */
1956 BLOCK_INPUT; 1949 BLOCK_INPUT;
1957 tm = localtime (&value); 1950 tm = localtime (&value);
1958 if (tm && TM_YEAR_IN_ASCTIME_RANGE (tm->tm_year)) 1951 if (tm)
1959 { 1952 {
1960 tem = asctime (tm); 1953 static char const wday_name[][4] =
1961 if (tem) 1954 { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
1962 memcpy (buf, tem, sizeof buf); 1955 static char const mon_name[][4] =
1956 { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
1957 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
1958 printmax_t year_base = TM_YEAR_BASE;
1959
1960 len = sprintf (buf, "%s %s%3d %02d:%02d:%02d %"pMd,
1961 wday_name[tm->tm_wday], mon_name[tm->tm_mon], tm->tm_mday,
1962 tm->tm_hour, tm->tm_min, tm->tm_sec,
1963 tm->tm_year + year_base);
1963 } 1964 }
1964 UNBLOCK_INPUT; 1965 UNBLOCK_INPUT;
1965 if (! tem) 1966 if (! tm)
1966 time_overflow (); 1967 time_overflow ();
1967 1968
1968 return make_unibyte_string (buf, sizeof buf); 1969 return make_unibyte_string (buf, len);
1969} 1970}
1970 1971
1971/* Yield A - B, measured in seconds. 1972/* Yield A - B, measured in seconds.