aboutsummaryrefslogtreecommitdiffstats
path: root/src/editfns.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/editfns.c')
-rw-r--r--src/editfns.c66
1 files changed, 34 insertions, 32 deletions
diff --git a/src/editfns.c b/src/editfns.c
index c6744648bc5..fc6465a3d46 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -738,17 +738,18 @@ Field boundaries are not noticed if `inhibit-field-text-motion' is non-nil. */)
738DEFUN ("line-beginning-position", 738DEFUN ("line-beginning-position",
739 Fline_beginning_position, Sline_beginning_position, 0, 1, 0, 739 Fline_beginning_position, Sline_beginning_position, 0, 1, 0,
740 doc: /* Return the character position of the first character on the current line. 740 doc: /* Return the character position of the first character on the current line.
741With argument N not nil or 1, move forward N - 1 lines first. 741With optional argument N, scan forward N - 1 lines first.
742If scan reaches end of buffer, return that position. 742If the scan reaches the end of the buffer, return that position.
743 743
744The returned position is of the first character in the logical order, 744This function ignores text display directionality; it returns the
745i.e. the one that has the smallest character position. 745position of the first character in logical order, i.e. the smallest
746character position on the line.
746 747
747This function constrains the returned position to the current field 748This function constrains the returned position to the current field
748unless that would be on a different line than the original, 749unless that position would be on a different line than the original,
749unconstrained result. If N is nil or 1, and a front-sticky field 750unconstrained result. If N is nil or 1, and a front-sticky field
750starts at point, the scan stops as soon as it starts. To ignore field 751starts at point, the scan stops as soon as it starts. To ignore field
751boundaries bind `inhibit-field-text-motion' to t. 752boundaries, bind `inhibit-field-text-motion' to t.
752 753
753This function does not move point. */) 754This function does not move point. */)
754 (Lisp_Object n) 755 (Lisp_Object n)
@@ -782,8 +783,9 @@ DEFUN ("line-end-position", Fline_end_position, Sline_end_position, 0, 1, 0,
782With argument N not nil or 1, move forward N - 1 lines first. 783With argument N not nil or 1, move forward N - 1 lines first.
783If scan reaches end of buffer, return that position. 784If scan reaches end of buffer, return that position.
784 785
785The returned position is of the last character in the logical order, 786This function ignores text display directionality; it returns the
786i.e. the character whose buffer position is the largest one. 787position of the last character in logical order, i.e. the largest
788character position on the line.
787 789
788This function constrains the returned position to the current field 790This function constrains the returned position to the current field
789unless that would be on a different line than the original, 791unless that would be on a different line than the original,
@@ -1217,9 +1219,9 @@ of the user with that uid, or nil if there is no such user. */)
1217 return Vuser_login_name; 1219 return Vuser_login_name;
1218 1220
1219 CONS_TO_INTEGER (uid, uid_t, id); 1221 CONS_TO_INTEGER (uid, uid_t, id);
1220 BLOCK_INPUT; 1222 block_input ();
1221 pw = getpwuid (id); 1223 pw = getpwuid (id);
1222 UNBLOCK_INPUT; 1224 unblock_input ();
1223 return (pw ? build_string (pw->pw_name) : Qnil); 1225 return (pw ? build_string (pw->pw_name) : Qnil);
1224} 1226}
1225 1227
@@ -1277,15 +1279,15 @@ name, or nil if there is no such user. */)
1277 { 1279 {
1278 uid_t u; 1280 uid_t u;
1279 CONS_TO_INTEGER (uid, uid_t, u); 1281 CONS_TO_INTEGER (uid, uid_t, u);
1280 BLOCK_INPUT; 1282 block_input ();
1281 pw = getpwuid (u); 1283 pw = getpwuid (u);
1282 UNBLOCK_INPUT; 1284 unblock_input ();
1283 } 1285 }
1284 else if (STRINGP (uid)) 1286 else if (STRINGP (uid))
1285 { 1287 {
1286 BLOCK_INPUT; 1288 block_input ();
1287 pw = getpwnam (SSDATA (uid)); 1289 pw = getpwnam (SSDATA (uid));
1288 UNBLOCK_INPUT; 1290 unblock_input ();
1289 } 1291 }
1290 else 1292 else
1291 error ("Invalid UID specification"); 1293 error ("Invalid UID specification");
@@ -1761,14 +1763,14 @@ format_time_string (char const *format, ptrdiff_t formatlen,
1761 while (1) 1763 while (1)
1762 { 1764 {
1763 time_t *taddr = emacs_secs_addr (&t); 1765 time_t *taddr = emacs_secs_addr (&t);
1764 BLOCK_INPUT; 1766 block_input ();
1765 1767
1766 synchronize_system_time_locale (); 1768 synchronize_system_time_locale ();
1767 1769
1768 tm = ut ? gmtime (taddr) : localtime (taddr); 1770 tm = ut ? gmtime (taddr) : localtime (taddr);
1769 if (! tm) 1771 if (! tm)
1770 { 1772 {
1771 UNBLOCK_INPUT; 1773 unblock_input ();
1772 time_overflow (); 1774 time_overflow ();
1773 } 1775 }
1774 *tmp = *tm; 1776 *tmp = *tm;
@@ -1780,14 +1782,14 @@ format_time_string (char const *format, ptrdiff_t formatlen,
1780 1782
1781 /* Buffer was too small, so make it bigger and try again. */ 1783 /* Buffer was too small, so make it bigger and try again. */
1782 len = emacs_nmemftime (NULL, SIZE_MAX, format, formatlen, tm, ut, ns); 1784 len = emacs_nmemftime (NULL, SIZE_MAX, format, formatlen, tm, ut, ns);
1783 UNBLOCK_INPUT; 1785 unblock_input ();
1784 if (STRING_BYTES_BOUND <= len) 1786 if (STRING_BYTES_BOUND <= len)
1785 string_overflow (); 1787 string_overflow ();
1786 size = len + 1; 1788 size = len + 1;
1787 buf = SAFE_ALLOCA (size); 1789 buf = SAFE_ALLOCA (size);
1788 } 1790 }
1789 1791
1790 UNBLOCK_INPUT; 1792 unblock_input ();
1791 bufstring = make_unibyte_string (buf, len); 1793 bufstring = make_unibyte_string (buf, len);
1792 SAFE_FREE (); 1794 SAFE_FREE ();
1793 return code_convert_string_norecord (bufstring, Vlocale_coding_system, 0); 1795 return code_convert_string_norecord (bufstring, Vlocale_coding_system, 0);
@@ -1815,11 +1817,11 @@ DOW and ZONE.) */)
1815 struct tm *decoded_time; 1817 struct tm *decoded_time;
1816 Lisp_Object list_args[9]; 1818 Lisp_Object list_args[9];
1817 1819
1818 BLOCK_INPUT; 1820 block_input ();
1819 decoded_time = localtime (&time_spec); 1821 decoded_time = localtime (&time_spec);
1820 if (decoded_time) 1822 if (decoded_time)
1821 save_tm = *decoded_time; 1823 save_tm = *decoded_time;
1822 UNBLOCK_INPUT; 1824 unblock_input ();
1823 if (! (decoded_time 1825 if (! (decoded_time
1824 && MOST_NEGATIVE_FIXNUM - TM_YEAR_BASE <= save_tm.tm_year 1826 && MOST_NEGATIVE_FIXNUM - TM_YEAR_BASE <= save_tm.tm_year
1825 && save_tm.tm_year <= MOST_POSITIVE_FIXNUM - TM_YEAR_BASE)) 1827 && save_tm.tm_year <= MOST_POSITIVE_FIXNUM - TM_YEAR_BASE))
@@ -1835,13 +1837,13 @@ DOW and ZONE.) */)
1835 XSETFASTINT (list_args[6], save_tm.tm_wday); 1837 XSETFASTINT (list_args[6], save_tm.tm_wday);
1836 list_args[7] = save_tm.tm_isdst ? Qt : Qnil; 1838 list_args[7] = save_tm.tm_isdst ? Qt : Qnil;
1837 1839
1838 BLOCK_INPUT; 1840 block_input ();
1839 decoded_time = gmtime (&time_spec); 1841 decoded_time = gmtime (&time_spec);
1840 if (decoded_time == 0) 1842 if (decoded_time == 0)
1841 list_args[8] = Qnil; 1843 list_args[8] = Qnil;
1842 else 1844 else
1843 XSETINT (list_args[8], tm_diff (&save_tm, decoded_time)); 1845 XSETINT (list_args[8], tm_diff (&save_tm, decoded_time));
1844 UNBLOCK_INPUT; 1846 unblock_input ();
1845 return Flist (9, list_args); 1847 return Flist (9, list_args);
1846} 1848}
1847 1849
@@ -1899,9 +1901,9 @@ usage: (encode-time SECOND MINUTE HOUR DAY MONTH YEAR &optional ZONE) */)
1899 zone = XCAR (zone); 1901 zone = XCAR (zone);
1900 if (NILP (zone)) 1902 if (NILP (zone))
1901 { 1903 {
1902 BLOCK_INPUT; 1904 block_input ();
1903 value = mktime (&tm); 1905 value = mktime (&tm);
1904 UNBLOCK_INPUT; 1906 unblock_input ();
1905 } 1907 }
1906 else 1908 else
1907 { 1909 {
@@ -1926,7 +1928,7 @@ usage: (encode-time SECOND MINUTE HOUR DAY MONTH YEAR &optional ZONE) */)
1926 else 1928 else
1927 error ("Invalid time zone specification"); 1929 error ("Invalid time zone specification");
1928 1930
1929 BLOCK_INPUT; 1931 block_input ();
1930 1932
1931 /* Set TZ before calling mktime; merely adjusting mktime's returned 1933 /* Set TZ before calling mktime; merely adjusting mktime's returned
1932 value doesn't suffice, since that would mishandle leap seconds. */ 1934 value doesn't suffice, since that would mishandle leap seconds. */
@@ -1940,7 +1942,7 @@ usage: (encode-time SECOND MINUTE HOUR DAY MONTH YEAR &optional ZONE) */)
1940#ifdef LOCALTIME_CACHE 1942#ifdef LOCALTIME_CACHE
1941 tzset (); 1943 tzset ();
1942#endif 1944#endif
1943 UNBLOCK_INPUT; 1945 unblock_input ();
1944 1946
1945 xfree (newenv); 1947 xfree (newenv);
1946 } 1948 }
@@ -1976,7 +1978,7 @@ but this is considered obsolete. */)
1976 newline, and without the 4-digit year limit. Don't use asctime 1978 newline, and without the 4-digit year limit. Don't use asctime
1977 or ctime, as they might dump core if the year is outside the 1979 or ctime, as they might dump core if the year is outside the
1978 range -999 .. 9999. */ 1980 range -999 .. 9999. */
1979 BLOCK_INPUT; 1981 block_input ();
1980 tm = localtime (&value); 1982 tm = localtime (&value);
1981 if (tm) 1983 if (tm)
1982 { 1984 {
@@ -1992,7 +1994,7 @@ but this is considered obsolete. */)
1992 tm->tm_hour, tm->tm_min, tm->tm_sec, 1994 tm->tm_hour, tm->tm_min, tm->tm_sec,
1993 tm->tm_year + year_base); 1995 tm->tm_year + year_base);
1994 } 1996 }
1995 UNBLOCK_INPUT; 1997 unblock_input ();
1996 if (! tm) 1998 if (! tm)
1997 time_overflow (); 1999 time_overflow ();
1998 2000
@@ -2048,11 +2050,11 @@ the data it can't find. */)
2048 zone_offset = Qnil; 2050 zone_offset = Qnil;
2049 value = make_emacs_time (lisp_seconds_argument (specified_time), 0); 2051 value = make_emacs_time (lisp_seconds_argument (specified_time), 0);
2050 zone_name = format_time_string ("%Z", sizeof "%Z" - 1, value, 0, &localtm); 2052 zone_name = format_time_string ("%Z", sizeof "%Z" - 1, value, 0, &localtm);
2051 BLOCK_INPUT; 2053 block_input ();
2052 t = gmtime (emacs_secs_addr (&value)); 2054 t = gmtime (emacs_secs_addr (&value));
2053 if (t) 2055 if (t)
2054 offset = tm_diff (&localtm, t); 2056 offset = tm_diff (&localtm, t);
2055 UNBLOCK_INPUT; 2057 unblock_input ();
2056 2058
2057 if (t) 2059 if (t)
2058 { 2060 {
@@ -2099,7 +2101,7 @@ only the former. */)
2099 if (! (NILP (tz) || EQ (tz, Qt))) 2101 if (! (NILP (tz) || EQ (tz, Qt)))
2100 CHECK_STRING (tz); 2102 CHECK_STRING (tz);
2101 2103
2102 BLOCK_INPUT; 2104 block_input ();
2103 2105
2104 /* When called for the first time, save the original TZ. */ 2106 /* When called for the first time, save the original TZ. */
2105 old_environbuf = environbuf; 2107 old_environbuf = environbuf;
@@ -2116,7 +2118,7 @@ only the former. */)
2116 set_time_zone_rule (tzstring); 2118 set_time_zone_rule (tzstring);
2117 environbuf = environ; 2119 environbuf = environ;
2118 2120
2119 UNBLOCK_INPUT; 2121 unblock_input ();
2120 2122
2121 xfree (old_environbuf); 2123 xfree (old_environbuf);
2122 return Qnil; 2124 return Qnil;