diff options
| author | YAMAMOTO Mitsuharu | 2007-01-05 08:29:41 +0000 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu | 2007-01-05 08:29:41 +0000 |
| commit | bcda42c8fd19e385ee4b5abd03ac330ee2824db0 (patch) | |
| tree | 44c1dc9b12c95caf05a0dcba06eb82009c20afad /src | |
| parent | 014361d83bda93004cfec50436acf88673cb1015 (diff) | |
| download | emacs-bcda42c8fd19e385ee4b5abd03ac330ee2824db0.tar.gz emacs-bcda42c8fd19e385ee4b5abd03ac330ee2824db0.zip | |
(Fformat_time_string, Fdecode_time, Fencode_time)
(Fcurrent_time_string, Fcurrent_time_zone): Add BLOCK_INPUT around
gmtime/localtime/emacs_memftimeu/mktime.
Diffstat (limited to 'src')
| -rw-r--r-- | src/editfns.c | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/src/editfns.c b/src/editfns.c index 39f8f87c673..6089ee9a2e2 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -1678,7 +1678,9 @@ For example, to produce full ISO 8601 format, use "%Y-%m-%dT%T%z". */) | |||
| 1678 | /* This is probably enough. */ | 1678 | /* This is probably enough. */ |
| 1679 | size = SBYTES (format_string) * 6 + 50; | 1679 | size = SBYTES (format_string) * 6 + 50; |
| 1680 | 1680 | ||
| 1681 | BLOCK_INPUT; | ||
| 1681 | tm = ut ? gmtime (&value) : localtime (&value); | 1682 | tm = ut ? gmtime (&value) : localtime (&value); |
| 1683 | UNBLOCK_INPUT; | ||
| 1682 | if (! tm) | 1684 | if (! tm) |
| 1683 | error ("Specified time is not representable"); | 1685 | error ("Specified time is not representable"); |
| 1684 | 1686 | ||
| @@ -1690,18 +1692,22 @@ For example, to produce full ISO 8601 format, use "%Y-%m-%dT%T%z". */) | |||
| 1690 | int result; | 1692 | int result; |
| 1691 | 1693 | ||
| 1692 | buf[0] = '\1'; | 1694 | buf[0] = '\1'; |
| 1695 | BLOCK_INPUT; | ||
| 1693 | result = emacs_memftimeu (buf, size, SDATA (format_string), | 1696 | result = emacs_memftimeu (buf, size, SDATA (format_string), |
| 1694 | SBYTES (format_string), | 1697 | SBYTES (format_string), |
| 1695 | tm, ut); | 1698 | tm, ut); |
| 1699 | UNBLOCK_INPUT; | ||
| 1696 | if ((result > 0 && result < size) || (result == 0 && buf[0] == '\0')) | 1700 | if ((result > 0 && result < size) || (result == 0 && buf[0] == '\0')) |
| 1697 | return code_convert_string_norecord (make_unibyte_string (buf, result), | 1701 | return code_convert_string_norecord (make_unibyte_string (buf, result), |
| 1698 | Vlocale_coding_system, 0); | 1702 | Vlocale_coding_system, 0); |
| 1699 | 1703 | ||
| 1700 | /* If buffer was too small, make it bigger and try again. */ | 1704 | /* If buffer was too small, make it bigger and try again. */ |
| 1705 | BLOCK_INPUT; | ||
| 1701 | result = emacs_memftimeu (NULL, (size_t) -1, | 1706 | result = emacs_memftimeu (NULL, (size_t) -1, |
| 1702 | SDATA (format_string), | 1707 | SDATA (format_string), |
| 1703 | SBYTES (format_string), | 1708 | SBYTES (format_string), |
| 1704 | tm, ut); | 1709 | tm, ut); |
| 1710 | UNBLOCK_INPUT; | ||
| 1705 | size = result + 1; | 1711 | size = result + 1; |
| 1706 | } | 1712 | } |
| 1707 | } | 1713 | } |
| @@ -1732,7 +1738,9 @@ DOW and ZONE.) */) | |||
| 1732 | if (! lisp_time_argument (specified_time, &time_spec, NULL)) | 1738 | if (! lisp_time_argument (specified_time, &time_spec, NULL)) |
| 1733 | error ("Invalid time specification"); | 1739 | error ("Invalid time specification"); |
| 1734 | 1740 | ||
| 1741 | BLOCK_INPUT; | ||
| 1735 | decoded_time = localtime (&time_spec); | 1742 | decoded_time = localtime (&time_spec); |
| 1743 | UNBLOCK_INPUT; | ||
| 1736 | if (! decoded_time) | 1744 | if (! decoded_time) |
| 1737 | error ("Specified time is not representable"); | 1745 | error ("Specified time is not representable"); |
| 1738 | XSETFASTINT (list_args[0], decoded_time->tm_sec); | 1746 | XSETFASTINT (list_args[0], decoded_time->tm_sec); |
| @@ -1748,7 +1756,9 @@ DOW and ZONE.) */) | |||
| 1748 | 1756 | ||
| 1749 | /* Make a copy, in case gmtime modifies the struct. */ | 1757 | /* Make a copy, in case gmtime modifies the struct. */ |
| 1750 | save_tm = *decoded_time; | 1758 | save_tm = *decoded_time; |
| 1759 | BLOCK_INPUT; | ||
| 1751 | decoded_time = gmtime (&time_spec); | 1760 | decoded_time = gmtime (&time_spec); |
| 1761 | UNBLOCK_INPUT; | ||
| 1752 | if (decoded_time == 0) | 1762 | if (decoded_time == 0) |
| 1753 | list_args[8] = Qnil; | 1763 | list_args[8] = Qnil; |
| 1754 | else | 1764 | else |
| @@ -1804,7 +1814,11 @@ usage: (encode-time SECOND MINUTE HOUR DAY MONTH YEAR &optional ZONE) */) | |||
| 1804 | if (CONSP (zone)) | 1814 | if (CONSP (zone)) |
| 1805 | zone = Fcar (zone); | 1815 | zone = Fcar (zone); |
| 1806 | if (NILP (zone)) | 1816 | if (NILP (zone)) |
| 1807 | time = mktime (&tm); | 1817 | { |
| 1818 | BLOCK_INPUT; | ||
| 1819 | time = mktime (&tm); | ||
| 1820 | UNBLOCK_INPUT; | ||
| 1821 | } | ||
| 1808 | else | 1822 | else |
| 1809 | { | 1823 | { |
| 1810 | char tzbuf[100]; | 1824 | char tzbuf[100]; |
| @@ -1829,7 +1843,9 @@ usage: (encode-time SECOND MINUTE HOUR DAY MONTH YEAR &optional ZONE) */) | |||
| 1829 | value doesn't suffice, since that would mishandle leap seconds. */ | 1843 | value doesn't suffice, since that would mishandle leap seconds. */ |
| 1830 | set_time_zone_rule (tzstring); | 1844 | set_time_zone_rule (tzstring); |
| 1831 | 1845 | ||
| 1846 | BLOCK_INPUT; | ||
| 1832 | time = mktime (&tm); | 1847 | time = mktime (&tm); |
| 1848 | UNBLOCK_INPUT; | ||
| 1833 | 1849 | ||
| 1834 | /* Restore TZ to previous value. */ | 1850 | /* Restore TZ to previous value. */ |
| 1835 | newenv = environ; | 1851 | newenv = environ; |
| @@ -1873,7 +1889,9 @@ but this is considered obsolete. */) | |||
| 1873 | /* Convert to a string, checking for out-of-range time stamps. | 1889 | /* Convert to a string, checking for out-of-range time stamps. |
| 1874 | Don't use 'ctime', as that might dump core if VALUE is out of | 1890 | Don't use 'ctime', as that might dump core if VALUE is out of |
| 1875 | range. */ | 1891 | range. */ |
| 1892 | BLOCK_INPUT; | ||
| 1876 | tm = localtime (&value); | 1893 | tm = localtime (&value); |
| 1894 | UNBLOCK_INPUT; | ||
| 1877 | if (! (tm && TM_YEAR_IN_ASCTIME_RANGE (tm->tm_year) && (tem = asctime (tm)))) | 1895 | if (! (tm && TM_YEAR_IN_ASCTIME_RANGE (tm->tm_year) && (tem = asctime (tm)))) |
| 1878 | error ("Specified time is not representable"); | 1896 | error ("Specified time is not representable"); |
| 1879 | 1897 | ||
| @@ -1929,9 +1947,21 @@ the data it can't find. */) | |||
| 1929 | struct tm *t; | 1947 | struct tm *t; |
| 1930 | struct tm gmt; | 1948 | struct tm gmt; |
| 1931 | 1949 | ||
| 1932 | if (lisp_time_argument (specified_time, &value, NULL) | 1950 | if (!lisp_time_argument (specified_time, &value, NULL)) |
| 1933 | && (t = gmtime (&value)) != 0 | 1951 | t = NULL; |
| 1934 | && (gmt = *t, t = localtime (&value)) != 0) | 1952 | else |
| 1953 | { | ||
| 1954 | BLOCK_INPUT; | ||
| 1955 | t = gmtime (&value); | ||
| 1956 | if (t) | ||
| 1957 | { | ||
| 1958 | gmt = *t; | ||
| 1959 | t = localtime (&value); | ||
| 1960 | } | ||
| 1961 | UNBLOCK_INPUT; | ||
| 1962 | } | ||
| 1963 | |||
| 1964 | if (t) | ||
| 1935 | { | 1965 | { |
| 1936 | int offset = tm_diff (t, &gmt); | 1966 | int offset = tm_diff (t, &gmt); |
| 1937 | char *s = 0; | 1967 | char *s = 0; |