diff options
| author | Paul Eggert | 2012-05-03 13:04:29 -0700 |
|---|---|---|
| committer | Paul Eggert | 2012-05-03 13:04:29 -0700 |
| commit | ab0fa4e4ba0b2b93a9ef007842523d8d5f9eb758 (patch) | |
| tree | 9adfb1831b29c6f4d68b5d1ea6de54f05617bc6a | |
| parent | f7ae6719123ad5f4f505290621810318d9ee5484 (diff) | |
| download | emacs-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/ChangeLog | 5 | ||||
| -rw-r--r-- | doc/lispref/os.texi | 13 | ||||
| -rw-r--r-- | etc/ChangeLog | 4 | ||||
| -rw-r--r-- | etc/NEWS | 6 | ||||
| -rw-r--r-- | src/ChangeLog | 8 | ||||
| -rw-r--r-- | src/editfns.c | 39 |
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 @@ | |||
| 1 | 2012-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 | |||
| 1 | 2012-05-02 Chong Yidong <cyd@gnu.org> | 6 | 2012-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 |
| 1198 | This function returns the current time and date as a human-readable | 1198 | This function returns the current time and date as a human-readable |
| 1199 | string. The format of the string is unvarying; the number of | 1199 | string. The format does not vary for the initial part of the string, |
| 1200 | characters used for each part is always the same, so you can reliably | 1200 | which contains the day of week, month, day of month, and time of day |
| 1201 | use @code{substring} to extract pieces of it. You should count | 1201 | in that order: the number of characters used for these fields is |
| 1202 | always the same, so you can reliably | ||
| 1203 | use @code{substring} to extract them. You should count | ||
| 1202 | characters from the beginning of the string rather than from the end, | 1204 | characters from the beginning of the string rather than from the end, |
| 1203 | as additional information may some day be added at the end. | 1205 | as the year might not have exactly four digits, and additional |
| 1206 | information may some day be added at the end. | ||
| 1204 | 1207 | ||
| 1205 | The argument @var{time-value}, if given, specifies a time to format | 1208 | The 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} |
| 2302 | The urgency level. It can be @code{low}, @code{normal}, or @code{critical}. | 2305 | The urgency level. It can be @code{low}, @code{normal}, or @code{critical}. |
| 2303 | 2306 | ||
| 2304 | @item :action-items | 2307 | @item :action-items |
| 2305 | When this keyword is given, the @var{title} string of the actions is | 2308 | When this keyword is given, the @var{title} string of the actions is |
| 2306 | interpreted as icon name. | 2309 | interpreted 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 @@ | |||
| 1 | 2012-05-03 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | * NEWS: Do not limit current-time-string to years 1000..9999. | ||
| 4 | |||
| 1 | 2012-04-27 Jambunathan K <kjambunathan@gmail.com> | 5 | 2012-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 |
| @@ -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 |
| 199 | table, but with a different prefix. | 199 | table, but with a different prefix. |
| 200 | |||
| 201 | ** Time | ||
| 202 | |||
| 203 | *** `current-time-string' no longer requires that its argument's year | ||
| 204 | must be in the range 1000..9999. It now works with any year supported | ||
| 205 | by 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 @@ | |||
| 1 | 2012-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 | |||
| 1 | 2012-05-02 Paul Eggert <eggert@cs.ucla.edu> | 9 | 2012-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 |
| 84 | extern Lisp_Object w32_get_internal_run_time (void); | 77 | extern 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. |