diff options
| author | Paul Eggert | 2011-03-11 12:31:59 -0800 |
|---|---|---|
| committer | Paul Eggert | 2011-03-11 12:31:59 -0800 |
| commit | fe31d94c97a6a3702e301a14b84c1f293afe5efd (patch) | |
| tree | d79c6b6f1b324eb638f8600db0486d046fdc1e42 | |
| parent | 8be6f3188dd265704c5d19d09e84a36c5e33d403 (diff) | |
| download | emacs-fe31d94c97a6a3702e301a14b84c1f293afe5efd.tar.gz emacs-fe31d94c97a6a3702e301a14b84c1f293afe5efd.zip | |
* editfns.c (time_overflow): New function, refactoring common code.
(Fformat_time_string, Fdecode_time, Fencode_time):
(Fcurrent_time_string): Use it.
| -rw-r--r-- | src/ChangeLog | 4 | ||||
| -rw-r--r-- | src/editfns.c | 16 |
2 files changed, 16 insertions, 4 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 85100149c92..a0c4941ec1c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,9 @@ | |||
| 1 | 2011-03-11 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2011-03-11 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | * editfns.c (time_overflow): New function, refactoring common code. | ||
| 4 | (Fformat_time_string, Fdecode_time, Fencode_time): | ||
| 5 | (Fcurrent_time_string): Use it. | ||
| 6 | |||
| 3 | Move 'make_time' to be next to its inverse 'lisp_time_argument'. | 7 | Move 'make_time' to be next to its inverse 'lisp_time_argument'. |
| 4 | * dired.c (make_time): Move to ... | 8 | * dired.c (make_time): Move to ... |
| 5 | * editfns.c (make_time): ... here. | 9 | * editfns.c (make_time): ... here. |
diff --git a/src/editfns.c b/src/editfns.c index ec477f0e010..fe8541f718e 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -87,6 +87,7 @@ extern char **environ; | |||
| 87 | extern Lisp_Object w32_get_internal_run_time (void); | 87 | extern Lisp_Object w32_get_internal_run_time (void); |
| 88 | #endif | 88 | #endif |
| 89 | 89 | ||
| 90 | static void time_overflow (void) NO_RETURN; | ||
| 90 | static int tm_diff (struct tm *, struct tm *); | 91 | static int tm_diff (struct tm *, struct tm *); |
| 91 | static void find_field (Lisp_Object, Lisp_Object, Lisp_Object, | 92 | static void find_field (Lisp_Object, Lisp_Object, Lisp_Object, |
| 92 | EMACS_INT *, Lisp_Object, EMACS_INT *); | 93 | EMACS_INT *, Lisp_Object, EMACS_INT *); |
| @@ -1476,6 +1477,13 @@ on systems that do not provide resolution finer than a second. */) | |||
| 1476 | } | 1477 | } |
| 1477 | 1478 | ||
| 1478 | 1479 | ||
| 1480 | /* Report a time value that is out of range for Emacs. */ | ||
| 1481 | static void | ||
| 1482 | time_overflow (void) | ||
| 1483 | { | ||
| 1484 | error ("Specified time is not representable"); | ||
| 1485 | } | ||
| 1486 | |||
| 1479 | /* Make a Lisp list that represents the time T. */ | 1487 | /* Make a Lisp list that represents the time T. */ |
| 1480 | Lisp_Object | 1488 | Lisp_Object |
| 1481 | make_time (time_t t) | 1489 | make_time (time_t t) |
| @@ -1687,7 +1695,7 @@ For example, to produce full ISO 8601 format, use "%Y-%m-%dT%T%z". */) | |||
| 1687 | tm = ut ? gmtime (&value) : localtime (&value); | 1695 | tm = ut ? gmtime (&value) : localtime (&value); |
| 1688 | UNBLOCK_INPUT; | 1696 | UNBLOCK_INPUT; |
| 1689 | if (! tm) | 1697 | if (! tm) |
| 1690 | error ("Specified time is not representable"); | 1698 | time_overflow (); |
| 1691 | 1699 | ||
| 1692 | synchronize_system_time_locale (); | 1700 | synchronize_system_time_locale (); |
| 1693 | 1701 | ||
| @@ -1746,7 +1754,7 @@ DOW and ZONE.) */) | |||
| 1746 | decoded_time = localtime (&time_spec); | 1754 | decoded_time = localtime (&time_spec); |
| 1747 | UNBLOCK_INPUT; | 1755 | UNBLOCK_INPUT; |
| 1748 | if (! decoded_time) | 1756 | if (! decoded_time) |
| 1749 | error ("Specified time is not representable"); | 1757 | time_overflow (); |
| 1750 | XSETFASTINT (list_args[0], decoded_time->tm_sec); | 1758 | XSETFASTINT (list_args[0], decoded_time->tm_sec); |
| 1751 | XSETFASTINT (list_args[1], decoded_time->tm_min); | 1759 | XSETFASTINT (list_args[1], decoded_time->tm_min); |
| 1752 | XSETFASTINT (list_args[2], decoded_time->tm_hour); | 1760 | XSETFASTINT (list_args[2], decoded_time->tm_hour); |
| @@ -1859,7 +1867,7 @@ usage: (encode-time SECOND MINUTE HOUR DAY MONTH YEAR &optional ZONE) */) | |||
| 1859 | } | 1867 | } |
| 1860 | 1868 | ||
| 1861 | if (time == (time_t) -1) | 1869 | if (time == (time_t) -1) |
| 1862 | error ("Specified time is not representable"); | 1870 | time_overflow (); |
| 1863 | 1871 | ||
| 1864 | return make_time (time); | 1872 | return make_time (time); |
| 1865 | } | 1873 | } |
| @@ -1894,7 +1902,7 @@ but this is considered obsolete. */) | |||
| 1894 | tm = localtime (&value); | 1902 | tm = localtime (&value); |
| 1895 | UNBLOCK_INPUT; | 1903 | UNBLOCK_INPUT; |
| 1896 | if (! (tm && TM_YEAR_IN_ASCTIME_RANGE (tm->tm_year) && (tem = asctime (tm)))) | 1904 | if (! (tm && TM_YEAR_IN_ASCTIME_RANGE (tm->tm_year) && (tem = asctime (tm)))) |
| 1897 | error ("Specified time is not representable"); | 1905 | time_overflow (); |
| 1898 | 1906 | ||
| 1899 | /* Remove the trailing newline. */ | 1907 | /* Remove the trailing newline. */ |
| 1900 | tem[strlen (tem) - 1] = '\0'; | 1908 | tem[strlen (tem) - 1] = '\0'; |