Mercurial > emacs
comparison src/editfns.c @ 83552:d3099204c799
Merged from emacs@sv.gnu.org
Patches applied:
* emacs@sv.gnu.org/emacs--devo--0--patch-585
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-586
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-587
Update from erc--emacs--22
* emacs@sv.gnu.org/emacs--devo--0--patch-588
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-589
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-590
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-591
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-592
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Sat, 06 Jan 2007 15:25:16 +0000 |
parents | ca95b6ba52a9 |
children | ea255892b6fd |
comparison
equal
deleted
inserted
replaced
83551:d9dc7e67ad3f | 83552:d3099204c799 |
---|---|
1676 Vlocale_coding_system, 1); | 1676 Vlocale_coding_system, 1); |
1677 | 1677 |
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 |
1685 synchronize_system_time_locale (); | 1687 synchronize_system_time_locale (); |
1686 | 1688 |
1688 { | 1690 { |
1689 char *buf = (char *) alloca (size + 1); | 1691 char *buf = (char *) alloca (size + 1); |
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 } |
1708 | 1714 |
1709 DEFUN ("decode-time", Fdecode_time, Sdecode_time, 0, 1, 0, | 1715 DEFUN ("decode-time", Fdecode_time, Sdecode_time, 0, 1, 0, |
1730 Lisp_Object list_args[9]; | 1736 Lisp_Object list_args[9]; |
1731 | 1737 |
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); |
1739 XSETFASTINT (list_args[1], decoded_time->tm_min); | 1747 XSETFASTINT (list_args[1], decoded_time->tm_min); |
1740 XSETFASTINT (list_args[2], decoded_time->tm_hour); | 1748 XSETFASTINT (list_args[2], decoded_time->tm_hour); |
1746 XSETFASTINT (list_args[6], decoded_time->tm_wday); | 1754 XSETFASTINT (list_args[6], decoded_time->tm_wday); |
1747 list_args[7] = (decoded_time->tm_isdst)? Qt : Qnil; | 1755 list_args[7] = (decoded_time->tm_isdst)? Qt : Qnil; |
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 |
1755 XSETINT (list_args[8], tm_diff (&save_tm, decoded_time)); | 1765 XSETINT (list_args[8], tm_diff (&save_tm, decoded_time)); |
1756 return Flist (9, list_args); | 1766 return Flist (9, list_args); |
1802 tm.tm_isdst = -1; | 1812 tm.tm_isdst = -1; |
1803 | 1813 |
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]; |
1811 char *tzstring; | 1825 char *tzstring; |
1812 char **oldenv = environ, **newenv; | 1826 char **oldenv = environ, **newenv; |
1827 | 1841 |
1828 /* Set TZ before calling mktime; merely adjusting mktime's returned | 1842 /* Set TZ before calling mktime; merely adjusting mktime's returned |
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; |
1836 environ = oldenv; | 1852 environ = oldenv; |
1837 xfree (newenv); | 1853 xfree (newenv); |
1871 error ("Invalid time specification"); | 1887 error ("Invalid time specification"); |
1872 | 1888 |
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 |
1880 /* Remove the trailing newline. */ | 1898 /* Remove the trailing newline. */ |
1881 tem[strlen (tem) - 1] = '\0'; | 1899 tem[strlen (tem) - 1] = '\0'; |
1927 { | 1945 { |
1928 time_t value; | 1946 time_t value; |
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; |
1938 char buf[6]; | 1968 char buf[6]; |
1939 #ifdef HAVE_TM_ZONE | 1969 #ifdef HAVE_TM_ZONE |