From: Paul Eggert Date: Fri, 11 Mar 2011 20:31:59 +0000 (-0800) Subject: * editfns.c (time_overflow): New function, refactoring common code. X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~590^2^2~3 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=fe31d94c97a6a3702e301a14b84c1f293afe5efd;p=emacs.git * editfns.c (time_overflow): New function, refactoring common code. (Fformat_time_string, Fdecode_time, Fencode_time): (Fcurrent_time_string): Use it. --- diff --git a/src/ChangeLog b/src/ChangeLog index 85100149c92..a0c4941ec1c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2011-03-11 Paul Eggert + * editfns.c (time_overflow): New function, refactoring common code. + (Fformat_time_string, Fdecode_time, Fencode_time): + (Fcurrent_time_string): Use it. + Move 'make_time' to be next to its inverse 'lisp_time_argument'. * dired.c (make_time): Move to ... * 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; extern Lisp_Object w32_get_internal_run_time (void); #endif +static void time_overflow (void) NO_RETURN; static int tm_diff (struct tm *, struct tm *); static void find_field (Lisp_Object, Lisp_Object, Lisp_Object, EMACS_INT *, Lisp_Object, EMACS_INT *); @@ -1476,6 +1477,13 @@ on systems that do not provide resolution finer than a second. */) } +/* Report a time value that is out of range for Emacs. */ +static void +time_overflow (void) +{ + error ("Specified time is not representable"); +} + /* Make a Lisp list that represents the time T. */ Lisp_Object make_time (time_t t) @@ -1687,7 +1695,7 @@ For example, to produce full ISO 8601 format, use "%Y-%m-%dT%T%z". */) tm = ut ? gmtime (&value) : localtime (&value); UNBLOCK_INPUT; if (! tm) - error ("Specified time is not representable"); + time_overflow (); synchronize_system_time_locale (); @@ -1746,7 +1754,7 @@ DOW and ZONE.) */) decoded_time = localtime (&time_spec); UNBLOCK_INPUT; if (! decoded_time) - error ("Specified time is not representable"); + time_overflow (); XSETFASTINT (list_args[0], decoded_time->tm_sec); XSETFASTINT (list_args[1], decoded_time->tm_min); XSETFASTINT (list_args[2], decoded_time->tm_hour); @@ -1859,7 +1867,7 @@ usage: (encode-time SECOND MINUTE HOUR DAY MONTH YEAR &optional ZONE) */) } if (time == (time_t) -1) - error ("Specified time is not representable"); + time_overflow (); return make_time (time); } @@ -1894,7 +1902,7 @@ but this is considered obsolete. */) tm = localtime (&value); UNBLOCK_INPUT; if (! (tm && TM_YEAR_IN_ASCTIME_RANGE (tm->tm_year) && (tem = asctime (tm)))) - error ("Specified time is not representable"); + time_overflow (); /* Remove the trailing newline. */ tem[strlen (tem) - 1] = '\0';