aboutsummaryrefslogtreecommitdiffstats
path: root/src/editfns.c
diff options
context:
space:
mode:
authorPaul Eggert2011-03-11 12:31:59 -0800
committerPaul Eggert2011-03-11 12:31:59 -0800
commitfe31d94c97a6a3702e301a14b84c1f293afe5efd (patch)
treed79c6b6f1b324eb638f8600db0486d046fdc1e42 /src/editfns.c
parent8be6f3188dd265704c5d19d09e84a36c5e33d403 (diff)
downloademacs-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.
Diffstat (limited to 'src/editfns.c')
-rw-r--r--src/editfns.c16
1 files changed, 12 insertions, 4 deletions
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;
87extern Lisp_Object w32_get_internal_run_time (void); 87extern Lisp_Object w32_get_internal_run_time (void);
88#endif 88#endif
89 89
90static void time_overflow (void) NO_RETURN;
90static int tm_diff (struct tm *, struct tm *); 91static int tm_diff (struct tm *, struct tm *);
91static void find_field (Lisp_Object, Lisp_Object, Lisp_Object, 92static 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. */
1481static void
1482time_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. */
1480Lisp_Object 1488Lisp_Object
1481make_time (time_t t) 1489make_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';