diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 29 | ||||
| -rw-r--r-- | src/bidi.c | 13 | ||||
| -rw-r--r-- | src/editfns.c | 5 | ||||
| -rw-r--r-- | src/indent.c | 31 | ||||
| -rw-r--r-- | src/keyboard.c | 101 | ||||
| -rw-r--r-- | src/lisp.h | 7 | ||||
| -rw-r--r-- | src/search.c | 51 | ||||
| -rw-r--r-- | src/sheap.c | 4 | ||||
| -rw-r--r-- | src/xdisp.c | 21 |
9 files changed, 104 insertions, 158 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index ff059cf1a3c..d39336f11e6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,32 @@ | |||
| 1 | 2013-02-20 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * sheap.c (report_sheap_usage): Prefer message1_nolog. | ||
| 4 | |||
| 5 | * keyboard.c (Qcommand_execute): New var. | ||
| 6 | (command_loop_1, read_char): Use it. | ||
| 7 | (Fcommand_execute): Remove, replace by an Elisp implementation. | ||
| 8 | (syms_of_keyboard): Adjust accordingly. | ||
| 9 | |||
| 10 | 2013-02-19 Daniel Colascione <dancol@dancol.org> | ||
| 11 | |||
| 12 | * sheap.c (report_sheap_usage): Use message, not message1, so | ||
| 13 | that we don't try to create a buffer while we're in the middle | ||
| 14 | of dumping Emacs. Explain why. | ||
| 15 | |||
| 16 | 2013-02-20 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 17 | * search.c (find_newline): Return byte position in bytepos. | ||
| 18 | Adjust comment. | ||
| 19 | (find_next_newline_no_quit, find_before_next_newline): | ||
| 20 | Add bytepos argument. | ||
| 21 | * lisp.h (find_newline, find_next_newline_no_quit) | ||
| 22 | (find_before_next_newline): Adjust prototypes. | ||
| 23 | * bidi.c (bidi_find_paragraph_start): | ||
| 24 | * editfns.c (Fconstrain_to_field, Fline_end_position): | ||
| 25 | * indent.c (compute_motion, vmotion): | ||
| 26 | * xdisp.c (back_to_previous_line_start, forward_to_next_line_start): | ||
| 27 | (get_visually_first_element, move_it_vertically_backward): | ||
| 28 | Adjust users and avoid calls to CHAR_TO_BYTE where appropriate. | ||
| 29 | |||
| 1 | 2013-02-19 Eli Zaretskii <eliz@gnu.org> | 30 | 2013-02-19 Eli Zaretskii <eliz@gnu.org> |
| 2 | 31 | ||
| 3 | * w32proc.c (new_child): Avoid leaking handles if the subprocess | 32 | * w32proc.c (new_child): Avoid leaking handles if the subprocess |
diff --git a/src/bidi.c b/src/bidi.c index db2e48a2ca7..364d7e500ba 100644 --- a/src/bidi.c +++ b/src/bidi.c | |||
| @@ -1104,14 +1104,11 @@ bidi_find_paragraph_start (ptrdiff_t pos, ptrdiff_t pos_byte) | |||
| 1104 | while (pos_byte > BEGV_BYTE | 1104 | while (pos_byte > BEGV_BYTE |
| 1105 | && n++ < MAX_PARAGRAPH_SEARCH | 1105 | && n++ < MAX_PARAGRAPH_SEARCH |
| 1106 | && fast_looking_at (re, pos, pos_byte, limit, limit_byte, Qnil) < 0) | 1106 | && fast_looking_at (re, pos, pos_byte, limit, limit_byte, Qnil) < 0) |
| 1107 | { | 1107 | /* FIXME: What if the paragraph beginning is covered by a |
| 1108 | /* FIXME: What if the paragraph beginning is covered by a | 1108 | display string? And what if a display string covering some |
| 1109 | display string? And what if a display string covering some | 1109 | of the text over which we scan back includes |
| 1110 | of the text over which we scan back includes | 1110 | paragraph_start_re? */ |
| 1111 | paragraph_start_re? */ | 1111 | pos = find_next_newline_no_quit (pos - 1, -1, &pos_byte); |
| 1112 | pos = find_next_newline_no_quit (pos - 1, -1); | ||
| 1113 | pos_byte = CHAR_TO_BYTE (pos); | ||
| 1114 | } | ||
| 1115 | if (n >= MAX_PARAGRAPH_SEARCH) | 1112 | if (n >= MAX_PARAGRAPH_SEARCH) |
| 1116 | pos_byte = BEGV_BYTE; | 1113 | pos_byte = BEGV_BYTE; |
| 1117 | return pos_byte; | 1114 | return pos_byte; |
diff --git a/src/editfns.c b/src/editfns.c index bee0bcc158d..831c8359fab 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -736,7 +736,7 @@ Field boundaries are not noticed if `inhibit-field-text-motion' is non-nil. */) | |||
| 736 | FIELD_BOUND are on the same line by seeing whether | 736 | FIELD_BOUND are on the same line by seeing whether |
| 737 | there's an intervening newline or not. */ | 737 | there's an intervening newline or not. */ |
| 738 | || (find_newline (XFASTINT (new_pos), XFASTINT (field_bound), | 738 | || (find_newline (XFASTINT (new_pos), XFASTINT (field_bound), |
| 739 | fwd ? -1 : 1, &shortage, 1), | 739 | fwd ? -1 : 1, &shortage, NULL, 1), |
| 740 | shortage != 0))) | 740 | shortage != 0))) |
| 741 | /* Constrain NEW_POS to FIELD_BOUND. */ | 741 | /* Constrain NEW_POS to FIELD_BOUND. */ |
| 742 | new_pos = field_bound; | 742 | new_pos = field_bound; |
| @@ -821,7 +821,8 @@ This function does not move point. */) | |||
| 821 | CHECK_NUMBER (n); | 821 | CHECK_NUMBER (n); |
| 822 | 822 | ||
| 823 | clipped_n = clip_to_bounds (PTRDIFF_MIN + 1, XINT (n), PTRDIFF_MAX); | 823 | clipped_n = clip_to_bounds (PTRDIFF_MIN + 1, XINT (n), PTRDIFF_MAX); |
| 824 | end_pos = find_before_next_newline (orig, 0, clipped_n - (clipped_n <= 0)); | 824 | end_pos = find_before_next_newline (orig, 0, clipped_n - (clipped_n <= 0), |
| 825 | NULL); | ||
| 825 | 826 | ||
| 826 | /* Return END_POS constrained to the current input field. */ | 827 | /* Return END_POS constrained to the current input field. */ |
| 827 | return Fconstrain_to_field (make_number (end_pos), make_number (orig), | 828 | return Fconstrain_to_field (make_number (end_pos), make_number (orig), |
diff --git a/src/indent.c b/src/indent.c index ce1639eae1e..9bf75bc6d95 100644 --- a/src/indent.c +++ b/src/indent.c | |||
| @@ -1328,8 +1328,7 @@ compute_motion (ptrdiff_t from, EMACS_INT fromvpos, EMACS_INT fromhpos, | |||
| 1328 | TO (we need to go back below). */ | 1328 | TO (we need to go back below). */ |
| 1329 | if (pos <= to) | 1329 | if (pos <= to) |
| 1330 | { | 1330 | { |
| 1331 | pos = find_before_next_newline (pos, to, 1); | 1331 | pos = find_before_next_newline (pos, to, 1, &pos_byte); |
| 1332 | pos_byte = CHAR_TO_BYTE (pos); | ||
| 1333 | hpos = width; | 1332 | hpos = width; |
| 1334 | /* If we just skipped next_boundary, | 1333 | /* If we just skipped next_boundary, |
| 1335 | loop around in the main while | 1334 | loop around in the main while |
| @@ -1583,10 +1582,9 @@ compute_motion (ptrdiff_t from, EMACS_INT fromvpos, EMACS_INT fromhpos, | |||
| 1583 | /* Skip any number of invisible lines all at once */ | 1582 | /* Skip any number of invisible lines all at once */ |
| 1584 | do | 1583 | do |
| 1585 | { | 1584 | { |
| 1586 | pos = find_before_next_newline (pos, to, 1); | 1585 | pos = find_before_next_newline (pos, to, 1, &pos_byte); |
| 1587 | if (pos < to) | 1586 | if (pos < to) |
| 1588 | pos++; | 1587 | INC_BOTH (pos, pos_byte); |
| 1589 | pos_byte = CHAR_TO_BYTE (pos); | ||
| 1590 | } | 1588 | } |
| 1591 | while (pos < to | 1589 | while (pos < to |
| 1592 | && indented_beyond_p (pos, pos_byte, | 1590 | && indented_beyond_p (pos, pos_byte, |
| @@ -1622,10 +1620,7 @@ compute_motion (ptrdiff_t from, EMACS_INT fromvpos, EMACS_INT fromhpos, | |||
| 1622 | everything from a ^M to the end of the line is invisible. | 1620 | everything from a ^M to the end of the line is invisible. |
| 1623 | Stop *before* the real newline. */ | 1621 | Stop *before* the real newline. */ |
| 1624 | if (pos < to) | 1622 | if (pos < to) |
| 1625 | { | 1623 | pos = find_before_next_newline (pos, to, 1, &pos_byte); |
| 1626 | pos = find_before_next_newline (pos, to, 1); | ||
| 1627 | pos_byte = CHAR_TO_BYTE (pos); | ||
| 1628 | } | ||
| 1629 | /* If we just skipped next_boundary, | 1624 | /* If we just skipped next_boundary, |
| 1630 | loop around in the main while | 1625 | loop around in the main while |
| 1631 | and handle it. */ | 1626 | and handle it. */ |
| @@ -1845,21 +1840,20 @@ vmotion (register ptrdiff_t from, register EMACS_INT vtarget, struct window *w) | |||
| 1845 | 1840 | ||
| 1846 | while ((vpos > vtarget || first) && from > BEGV) | 1841 | while ((vpos > vtarget || first) && from > BEGV) |
| 1847 | { | 1842 | { |
| 1843 | ptrdiff_t bytepos; | ||
| 1848 | Lisp_Object propval; | 1844 | Lisp_Object propval; |
| 1849 | 1845 | ||
| 1850 | prevline = find_next_newline_no_quit (from - 1, -1); | 1846 | prevline = find_next_newline_no_quit (from - 1, -1, &bytepos); |
| 1851 | while (prevline > BEGV | 1847 | while (prevline > BEGV |
| 1852 | && ((selective > 0 | 1848 | && ((selective > 0 |
| 1853 | && indented_beyond_p (prevline, | 1849 | && indented_beyond_p (prevline, bytepos, selective)) |
| 1854 | CHAR_TO_BYTE (prevline), | ||
| 1855 | selective)) | ||
| 1856 | /* Watch out for newlines with `invisible' property. | 1850 | /* Watch out for newlines with `invisible' property. |
| 1857 | When moving upward, check the newline before. */ | 1851 | When moving upward, check the newline before. */ |
| 1858 | || (propval = Fget_char_property (make_number (prevline - 1), | 1852 | || (propval = Fget_char_property (make_number (prevline - 1), |
| 1859 | Qinvisible, | 1853 | Qinvisible, |
| 1860 | text_prop_object), | 1854 | text_prop_object), |
| 1861 | TEXT_PROP_MEANS_INVISIBLE (propval)))) | 1855 | TEXT_PROP_MEANS_INVISIBLE (propval)))) |
| 1862 | prevline = find_next_newline_no_quit (prevline - 1, -1); | 1856 | prevline = find_next_newline_no_quit (prevline - 1, -1, &bytepos); |
| 1863 | pos = *compute_motion (prevline, 0, | 1857 | pos = *compute_motion (prevline, 0, |
| 1864 | lmargin, | 1858 | lmargin, |
| 1865 | 0, | 1859 | 0, |
| @@ -1897,21 +1891,20 @@ vmotion (register ptrdiff_t from, register EMACS_INT vtarget, struct window *w) | |||
| 1897 | from_byte = CHAR_TO_BYTE (from); | 1891 | from_byte = CHAR_TO_BYTE (from); |
| 1898 | if (from > BEGV && FETCH_BYTE (from_byte - 1) != '\n') | 1892 | if (from > BEGV && FETCH_BYTE (from_byte - 1) != '\n') |
| 1899 | { | 1893 | { |
| 1894 | ptrdiff_t bytepos; | ||
| 1900 | Lisp_Object propval; | 1895 | Lisp_Object propval; |
| 1901 | 1896 | ||
| 1902 | prevline = find_next_newline_no_quit (from, -1); | 1897 | prevline = find_next_newline_no_quit (from, -1, &bytepos); |
| 1903 | while (prevline > BEGV | 1898 | while (prevline > BEGV |
| 1904 | && ((selective > 0 | 1899 | && ((selective > 0 |
| 1905 | && indented_beyond_p (prevline, | 1900 | && indented_beyond_p (prevline, bytepos, selective)) |
| 1906 | CHAR_TO_BYTE (prevline), | ||
| 1907 | selective)) | ||
| 1908 | /* Watch out for newlines with `invisible' property. | 1901 | /* Watch out for newlines with `invisible' property. |
| 1909 | When moving downward, check the newline after. */ | 1902 | When moving downward, check the newline after. */ |
| 1910 | || (propval = Fget_char_property (make_number (prevline), | 1903 | || (propval = Fget_char_property (make_number (prevline), |
| 1911 | Qinvisible, | 1904 | Qinvisible, |
| 1912 | text_prop_object), | 1905 | text_prop_object), |
| 1913 | TEXT_PROP_MEANS_INVISIBLE (propval)))) | 1906 | TEXT_PROP_MEANS_INVISIBLE (propval)))) |
| 1914 | prevline = find_next_newline_no_quit (prevline - 1, -1); | 1907 | prevline = find_next_newline_no_quit (prevline - 1, -1, &bytepos); |
| 1915 | pos = *compute_motion (prevline, 0, | 1908 | pos = *compute_motion (prevline, 0, |
| 1916 | lmargin, | 1909 | lmargin, |
| 1917 | 0, | 1910 | 0, |
diff --git a/src/keyboard.c b/src/keyboard.c index 3c00e017498..38136b57b4b 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -370,7 +370,7 @@ Lisp_Object Qmenu_bar; | |||
| 370 | 370 | ||
| 371 | static Lisp_Object recursive_edit_unwind (Lisp_Object buffer); | 371 | static Lisp_Object recursive_edit_unwind (Lisp_Object buffer); |
| 372 | static Lisp_Object command_loop (void); | 372 | static Lisp_Object command_loop (void); |
| 373 | static Lisp_Object Qextended_command_history; | 373 | static Lisp_Object Qcommand_execute; |
| 374 | EMACS_TIME timer_check (void); | 374 | EMACS_TIME timer_check (void); |
| 375 | 375 | ||
| 376 | static void echo_now (void); | 376 | static void echo_now (void); |
| @@ -1586,11 +1586,11 @@ command_loop_1 (void) | |||
| 1586 | = (EQ (undo, BVAR (current_buffer, undo_list)) | 1586 | = (EQ (undo, BVAR (current_buffer, undo_list)) |
| 1587 | ? Qnil : BVAR (current_buffer, undo_list)); | 1587 | ? Qnil : BVAR (current_buffer, undo_list)); |
| 1588 | } | 1588 | } |
| 1589 | Fcommand_execute (Vthis_command, Qnil, Qnil, Qnil); | 1589 | call1 (Qcommand_execute, Vthis_command); |
| 1590 | 1590 | ||
| 1591 | #ifdef HAVE_WINDOW_SYSTEM | 1591 | #ifdef HAVE_WINDOW_SYSTEM |
| 1592 | /* Do not check display_hourglass_p here, because | 1592 | /* Do not check display_hourglass_p here, because |
| 1593 | Fcommand_execute could change it, but we should cancel | 1593 | `command-execute' could change it, but we should cancel |
| 1594 | hourglass cursor anyway. | 1594 | hourglass cursor anyway. |
| 1595 | But don't cancel the hourglass within a macro | 1595 | But don't cancel the hourglass within a macro |
| 1596 | just because a command in the macro finishes. */ | 1596 | just because a command in the macro finishes. */ |
| @@ -2845,7 +2845,7 @@ read_char (int commandflag, Lisp_Object map, | |||
| 2845 | { | 2845 | { |
| 2846 | struct buffer *prev_buffer = current_buffer; | 2846 | struct buffer *prev_buffer = current_buffer; |
| 2847 | last_input_event = c; | 2847 | last_input_event = c; |
| 2848 | Fcommand_execute (tem, Qnil, Fvector (1, &last_input_event), Qt); | 2848 | call4 (Qcommand_execute, tem, Qnil, Fvector (1, &last_input_event), Qt); |
| 2849 | 2849 | ||
| 2850 | if (CONSP (c) && EQ (XCAR (c), Qselect_window) && !end_time) | 2850 | if (CONSP (c) && EQ (XCAR (c), Qselect_window) && !end_time) |
| 2851 | /* We stopped being idle for this event; undo that. This | 2851 | /* We stopped being idle for this event; undo that. This |
| @@ -9895,95 +9895,6 @@ DEFUN ("read-key-sequence-vector", Fread_key_sequence_vector, | |||
| 9895 | return unbind_to (count, Fvector (i, keybuf)); | 9895 | return unbind_to (count, Fvector (i, keybuf)); |
| 9896 | } | 9896 | } |
| 9897 | 9897 | ||
| 9898 | DEFUN ("command-execute", Fcommand_execute, Scommand_execute, 1, 4, 0, | ||
| 9899 | doc: /* Execute CMD as an editor command. | ||
| 9900 | CMD must be a symbol that satisfies the `commandp' predicate. | ||
| 9901 | Optional second arg RECORD-FLAG non-nil | ||
| 9902 | means unconditionally put this command in the variable `command-history'. | ||
| 9903 | Otherwise, that is done only if an arg is read using the minibuffer. | ||
| 9904 | The argument KEYS specifies the value to use instead of (this-command-keys) | ||
| 9905 | when reading the arguments; if it is nil, (this-command-keys) is used. | ||
| 9906 | The argument SPECIAL, if non-nil, means that this command is executing | ||
| 9907 | a special event, so ignore the prefix argument and don't clear it. */) | ||
| 9908 | (Lisp_Object cmd, Lisp_Object record_flag, Lisp_Object keys, Lisp_Object special) | ||
| 9909 | { | ||
| 9910 | register Lisp_Object final; | ||
| 9911 | register Lisp_Object tem; | ||
| 9912 | Lisp_Object prefixarg; | ||
| 9913 | |||
| 9914 | debug_on_next_call = 0; | ||
| 9915 | |||
| 9916 | if (NILP (special)) | ||
| 9917 | { | ||
| 9918 | prefixarg = KVAR (current_kboard, Vprefix_arg); | ||
| 9919 | Vcurrent_prefix_arg = prefixarg; | ||
| 9920 | kset_prefix_arg (current_kboard, Qnil); | ||
| 9921 | } | ||
| 9922 | else | ||
| 9923 | prefixarg = Qnil; | ||
| 9924 | |||
| 9925 | if (SYMBOLP (cmd)) | ||
| 9926 | { | ||
| 9927 | tem = Fget (cmd, Qdisabled); | ||
| 9928 | if (!NILP (tem)) | ||
| 9929 | { | ||
| 9930 | tem = Fsymbol_value (Qdisabled_command_function); | ||
| 9931 | if (!NILP (tem)) | ||
| 9932 | return Frun_hooks (1, &Qdisabled_command_function); | ||
| 9933 | } | ||
| 9934 | } | ||
| 9935 | |||
| 9936 | while (1) | ||
| 9937 | { | ||
| 9938 | final = Findirect_function (cmd, Qnil); | ||
| 9939 | |||
| 9940 | if (CONSP (final) && (tem = Fcar (final), EQ (tem, Qautoload))) | ||
| 9941 | { | ||
| 9942 | struct gcpro gcpro1, gcpro2; | ||
| 9943 | |||
| 9944 | GCPRO2 (cmd, prefixarg); | ||
| 9945 | Fautoload_do_load (final, cmd, Qnil); | ||
| 9946 | UNGCPRO; | ||
| 9947 | } | ||
| 9948 | else | ||
| 9949 | break; | ||
| 9950 | } | ||
| 9951 | |||
| 9952 | if (STRINGP (final) || VECTORP (final)) | ||
| 9953 | { | ||
| 9954 | /* If requested, place the macro in the command history. For | ||
| 9955 | other sorts of commands, call-interactively takes care of | ||
| 9956 | this. */ | ||
| 9957 | if (!NILP (record_flag)) | ||
| 9958 | { | ||
| 9959 | Vcommand_history | ||
| 9960 | = Fcons (Fcons (Qexecute_kbd_macro, | ||
| 9961 | Fcons (final, Fcons (prefixarg, Qnil))), | ||
| 9962 | Vcommand_history); | ||
| 9963 | |||
| 9964 | /* Don't keep command history around forever. */ | ||
| 9965 | if (NUMBERP (Vhistory_length) && XINT (Vhistory_length) > 0) | ||
| 9966 | { | ||
| 9967 | tem = Fnthcdr (Vhistory_length, Vcommand_history); | ||
| 9968 | if (CONSP (tem)) | ||
| 9969 | XSETCDR (tem, Qnil); | ||
| 9970 | } | ||
| 9971 | } | ||
| 9972 | |||
| 9973 | return Fexecute_kbd_macro (final, prefixarg, Qnil); | ||
| 9974 | } | ||
| 9975 | |||
| 9976 | if (CONSP (final) || SUBRP (final) || COMPILEDP (final)) | ||
| 9977 | /* Don't call Fcall_interactively directly because we want to make | ||
| 9978 | sure the backtrace has an entry for `call-interactively'. | ||
| 9979 | For the same reason, pass `cmd' rather than `final'. */ | ||
| 9980 | return call3 (Qcall_interactively, cmd, record_flag, keys); | ||
| 9981 | |||
| 9982 | return Qnil; | ||
| 9983 | } | ||
| 9984 | |||
| 9985 | |||
| 9986 | |||
| 9987 | /* Return true if input events are pending. */ | 9898 | /* Return true if input events are pending. */ |
| 9988 | 9899 | ||
| 9989 | bool | 9900 | bool |
| @@ -11218,8 +11129,7 @@ syms_of_keyboard (void) | |||
| 11218 | raw_keybuf = Fmake_vector (make_number (30), Qnil); | 11129 | raw_keybuf = Fmake_vector (make_number (30), Qnil); |
| 11219 | staticpro (&raw_keybuf); | 11130 | staticpro (&raw_keybuf); |
| 11220 | 11131 | ||
| 11221 | DEFSYM (Qextended_command_history, "extended-command-history"); | 11132 | DEFSYM (Qcommand_execute, "command-execute"); |
| 11222 | Fset (Qextended_command_history, Qnil); | ||
| 11223 | 11133 | ||
| 11224 | accent_key_syms = Qnil; | 11134 | accent_key_syms = Qnil; |
| 11225 | staticpro (&accent_key_syms); | 11135 | staticpro (&accent_key_syms); |
| @@ -11258,7 +11168,6 @@ syms_of_keyboard (void) | |||
| 11258 | defsubr (&Srecursive_edit); | 11168 | defsubr (&Srecursive_edit); |
| 11259 | defsubr (&Strack_mouse); | 11169 | defsubr (&Strack_mouse); |
| 11260 | defsubr (&Sinput_pending_p); | 11170 | defsubr (&Sinput_pending_p); |
| 11261 | defsubr (&Scommand_execute); | ||
| 11262 | defsubr (&Srecent_keys); | 11171 | defsubr (&Srecent_keys); |
| 11263 | defsubr (&Sthis_command_keys); | 11172 | defsubr (&Sthis_command_keys); |
| 11264 | defsubr (&Sthis_command_keys_vector); | 11173 | defsubr (&Sthis_command_keys_vector); |
diff --git a/src/lisp.h b/src/lisp.h index e7a86892908..7b36878c0c5 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -3348,12 +3348,13 @@ extern ptrdiff_t fast_string_match_ignore_case (Lisp_Object, Lisp_Object); | |||
| 3348 | extern ptrdiff_t fast_looking_at (Lisp_Object, ptrdiff_t, ptrdiff_t, | 3348 | extern ptrdiff_t fast_looking_at (Lisp_Object, ptrdiff_t, ptrdiff_t, |
| 3349 | ptrdiff_t, ptrdiff_t, Lisp_Object); | 3349 | ptrdiff_t, ptrdiff_t, Lisp_Object); |
| 3350 | extern ptrdiff_t find_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t, | 3350 | extern ptrdiff_t find_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t, |
| 3351 | ptrdiff_t *, bool); | 3351 | ptrdiff_t *, ptrdiff_t *, bool); |
| 3352 | extern EMACS_INT scan_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, | 3352 | extern EMACS_INT scan_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, |
| 3353 | EMACS_INT, bool); | 3353 | EMACS_INT, bool); |
| 3354 | extern ptrdiff_t find_next_newline (ptrdiff_t, int); | 3354 | extern ptrdiff_t find_next_newline (ptrdiff_t, int); |
| 3355 | extern ptrdiff_t find_next_newline_no_quit (ptrdiff_t, ptrdiff_t); | 3355 | extern ptrdiff_t find_next_newline_no_quit (ptrdiff_t, ptrdiff_t, ptrdiff_t *); |
| 3356 | extern ptrdiff_t find_before_next_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t); | 3356 | extern ptrdiff_t find_before_next_newline (ptrdiff_t, ptrdiff_t, |
| 3357 | ptrdiff_t, ptrdiff_t *); | ||
| 3357 | extern void syms_of_search (void); | 3358 | extern void syms_of_search (void); |
| 3358 | extern void clear_regexp_cache (void); | 3359 | extern void clear_regexp_cache (void); |
| 3359 | 3360 | ||
diff --git a/src/search.c b/src/search.c index d4508004bf6..1c0f57487f9 100644 --- a/src/search.c +++ b/src/search.c | |||
| @@ -638,15 +638,18 @@ newline_cache_on_off (struct buffer *buf) | |||
| 638 | If we don't find COUNT instances before reaching END, set *SHORTAGE | 638 | If we don't find COUNT instances before reaching END, set *SHORTAGE |
| 639 | to the number of newlines left unfound, and return END. | 639 | to the number of newlines left unfound, and return END. |
| 640 | 640 | ||
| 641 | If BYTEPOS is not NULL, set *BYTEPOS to the byte position corresponding | ||
| 642 | to the returned character position. | ||
| 643 | |||
| 641 | If ALLOW_QUIT, set immediate_quit. That's good to do | 644 | If ALLOW_QUIT, set immediate_quit. That's good to do |
| 642 | except when inside redisplay. */ | 645 | except when inside redisplay. */ |
| 643 | 646 | ||
| 644 | ptrdiff_t | 647 | ptrdiff_t |
| 645 | find_newline (ptrdiff_t start, ptrdiff_t end, | 648 | find_newline (ptrdiff_t start, ptrdiff_t end, ptrdiff_t count, |
| 646 | ptrdiff_t count, ptrdiff_t *shortage, bool allow_quit) | 649 | ptrdiff_t *shortage, ptrdiff_t *bytepos, bool allow_quit) |
| 647 | { | 650 | { |
| 648 | struct region_cache *newline_cache; | 651 | struct region_cache *newline_cache; |
| 649 | ptrdiff_t end_byte = -1; | 652 | ptrdiff_t start_byte = -1, end_byte = -1; |
| 650 | int direction; | 653 | int direction; |
| 651 | 654 | ||
| 652 | if (count > 0) | 655 | if (count > 0) |
| @@ -680,9 +683,7 @@ find_newline (ptrdiff_t start, ptrdiff_t end, | |||
| 680 | the position of the last character before the next such | 683 | the position of the last character before the next such |
| 681 | obstacle --- the last character the dumb search loop should | 684 | obstacle --- the last character the dumb search loop should |
| 682 | examine. */ | 685 | examine. */ |
| 683 | ptrdiff_t ceiling_byte = end_byte - 1; | 686 | ptrdiff_t tem, ceiling_byte = end_byte - 1; |
| 684 | ptrdiff_t start_byte; | ||
| 685 | ptrdiff_t tem; | ||
| 686 | 687 | ||
| 687 | /* If we're looking for a newline, consult the newline cache | 688 | /* If we're looking for a newline, consult the newline cache |
| 688 | to see where we can avoid some scanning. */ | 689 | to see where we can avoid some scanning. */ |
| @@ -745,21 +746,22 @@ find_newline (ptrdiff_t start, ptrdiff_t end, | |||
| 745 | if (--count == 0) | 746 | if (--count == 0) |
| 746 | { | 747 | { |
| 747 | immediate_quit = 0; | 748 | immediate_quit = 0; |
| 749 | if (bytepos) | ||
| 750 | *bytepos = nl + 1 - base + start_byte; | ||
| 748 | return BYTE_TO_CHAR (nl + 1 - base + start_byte); | 751 | return BYTE_TO_CHAR (nl + 1 - base + start_byte); |
| 749 | } | 752 | } |
| 750 | cursor = nl + 1; | 753 | cursor = nl + 1; |
| 751 | } | 754 | } |
| 752 | 755 | ||
| 753 | start = BYTE_TO_CHAR (ceiling_addr - base + start_byte); | 756 | start_byte += ceiling_addr - base; |
| 757 | start = BYTE_TO_CHAR (start_byte); | ||
| 754 | } | 758 | } |
| 755 | } | 759 | } |
| 756 | else | 760 | else |
| 757 | while (start > end) | 761 | while (start > end) |
| 758 | { | 762 | { |
| 759 | /* The last character to check before the next obstacle. */ | 763 | /* The last character to check before the next obstacle. */ |
| 760 | ptrdiff_t ceiling_byte = end_byte; | 764 | ptrdiff_t tem, ceiling_byte = end_byte; |
| 761 | ptrdiff_t start_byte; | ||
| 762 | ptrdiff_t tem; | ||
| 763 | 765 | ||
| 764 | /* Consult the newline cache, if appropriate. */ | 766 | /* Consult the newline cache, if appropriate. */ |
| 765 | if (newline_cache) | 767 | if (newline_cache) |
| @@ -816,18 +818,26 @@ find_newline (ptrdiff_t start, ptrdiff_t end, | |||
| 816 | if (++count >= 0) | 818 | if (++count >= 0) |
| 817 | { | 819 | { |
| 818 | immediate_quit = 0; | 820 | immediate_quit = 0; |
| 821 | if (bytepos) | ||
| 822 | *bytepos = nl - base + start_byte; | ||
| 819 | return BYTE_TO_CHAR (nl - base + start_byte); | 823 | return BYTE_TO_CHAR (nl - base + start_byte); |
| 820 | } | 824 | } |
| 821 | cursor = nl - 1; | 825 | cursor = nl - 1; |
| 822 | } | 826 | } |
| 823 | 827 | ||
| 824 | start = BYTE_TO_CHAR (ceiling_addr - 1 - base + start_byte); | 828 | start_byte += ceiling_addr - 1 - base; |
| 829 | start = BYTE_TO_CHAR (start_byte); | ||
| 825 | } | 830 | } |
| 826 | } | 831 | } |
| 827 | 832 | ||
| 828 | immediate_quit = 0; | 833 | immediate_quit = 0; |
| 829 | if (shortage != 0) | 834 | if (shortage) |
| 830 | *shortage = count * direction; | 835 | *shortage = count * direction; |
| 836 | if (bytepos) | ||
| 837 | { | ||
| 838 | *bytepos = start_byte == -1 ? CHAR_TO_BYTE (start) : start_byte; | ||
| 839 | eassert (*bytepos == CHAR_TO_BYTE (start)); | ||
| 840 | } | ||
| 831 | return start; | 841 | return start; |
| 832 | } | 842 | } |
| 833 | 843 | ||
| @@ -932,9 +942,9 @@ scan_newline (ptrdiff_t start, ptrdiff_t start_byte, | |||
| 932 | } | 942 | } |
| 933 | 943 | ||
| 934 | ptrdiff_t | 944 | ptrdiff_t |
| 935 | find_next_newline_no_quit (ptrdiff_t from, ptrdiff_t cnt) | 945 | find_next_newline_no_quit (ptrdiff_t from, ptrdiff_t cnt, ptrdiff_t *bytepos) |
| 936 | { | 946 | { |
| 937 | return find_newline (from, 0, cnt, (ptrdiff_t *) 0, 0); | 947 | return find_newline (from, 0, cnt, NULL, bytepos, 0); |
| 938 | } | 948 | } |
| 939 | 949 | ||
| 940 | /* Like find_next_newline, but returns position before the newline, | 950 | /* Like find_next_newline, but returns position before the newline, |
| @@ -942,14 +952,19 @@ find_next_newline_no_quit (ptrdiff_t from, ptrdiff_t cnt) | |||
| 942 | find_next_newline (...)-1, because you might hit TO. */ | 952 | find_next_newline (...)-1, because you might hit TO. */ |
| 943 | 953 | ||
| 944 | ptrdiff_t | 954 | ptrdiff_t |
| 945 | find_before_next_newline (ptrdiff_t from, ptrdiff_t to, ptrdiff_t cnt) | 955 | find_before_next_newline (ptrdiff_t from, ptrdiff_t to, |
| 956 | ptrdiff_t cnt, ptrdiff_t *bytepos) | ||
| 946 | { | 957 | { |
| 947 | ptrdiff_t shortage; | 958 | ptrdiff_t shortage; |
| 948 | ptrdiff_t pos = find_newline (from, to, cnt, &shortage, 1); | 959 | ptrdiff_t pos = find_newline (from, to, cnt, &shortage, bytepos, 1); |
| 949 | 960 | ||
| 950 | if (shortage == 0) | 961 | if (shortage == 0) |
| 951 | pos--; | 962 | { |
| 952 | 963 | if (bytepos) | |
| 964 | DEC_BOTH (pos, *bytepos); | ||
| 965 | else | ||
| 966 | pos--; | ||
| 967 | } | ||
| 953 | return pos; | 968 | return pos; |
| 954 | } | 969 | } |
| 955 | 970 | ||
diff --git a/src/sheap.c b/src/sheap.c index 06e205bc0e5..28597ec9b65 100644 --- a/src/sheap.c +++ b/src/sheap.c | |||
| @@ -91,5 +91,7 @@ report_sheap_usage (int die_if_pure_storage_exceeded) | |||
| 91 | char buf[200]; | 91 | char buf[200]; |
| 92 | sprintf (buf, "Static heap usage: %d of %d bytes", | 92 | sprintf (buf, "Static heap usage: %d of %d bytes", |
| 93 | bss_sbrk_ptr - bss_sbrk_buffer, STATIC_HEAP_SIZE); | 93 | bss_sbrk_ptr - bss_sbrk_buffer, STATIC_HEAP_SIZE); |
| 94 | message1 (buf); | 94 | /* Don't log messages, cause at this point, we're not allowed to create |
| 95 | buffers. */ | ||
| 96 | message1_nolog ("%s", buf); | ||
| 95 | } | 97 | } |
diff --git a/src/xdisp.c b/src/xdisp.c index 9207355bc09..7a329c5421b 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -5940,8 +5940,9 @@ pop_it (struct it *it) | |||
| 5940 | static void | 5940 | static void |
| 5941 | back_to_previous_line_start (struct it *it) | 5941 | back_to_previous_line_start (struct it *it) |
| 5942 | { | 5942 | { |
| 5943 | IT_CHARPOS (*it) = find_next_newline_no_quit (IT_CHARPOS (*it) - 1, -1); | 5943 | IT_CHARPOS (*it) |
| 5944 | IT_BYTEPOS (*it) = CHAR_TO_BYTE (IT_CHARPOS (*it)); | 5944 | = find_next_newline_no_quit (IT_CHARPOS (*it) - 1, |
| 5945 | -1, &IT_BYTEPOS (*it)); | ||
| 5945 | } | 5946 | } |
| 5946 | 5947 | ||
| 5947 | 5948 | ||
| @@ -6012,8 +6013,8 @@ forward_to_next_line_start (struct it *it, int *skipped_p, | |||
| 6012 | short-cut. */ | 6013 | short-cut. */ |
| 6013 | if (!newline_found_p) | 6014 | if (!newline_found_p) |
| 6014 | { | 6015 | { |
| 6015 | ptrdiff_t start = IT_CHARPOS (*it); | 6016 | ptrdiff_t bytepos, start = IT_CHARPOS (*it); |
| 6016 | ptrdiff_t limit = find_next_newline_no_quit (start, 1); | 6017 | ptrdiff_t limit = find_next_newline_no_quit (start, 1, &bytepos); |
| 6017 | Lisp_Object pos; | 6018 | Lisp_Object pos; |
| 6018 | 6019 | ||
| 6019 | eassert (!STRINGP (it->string)); | 6020 | eassert (!STRINGP (it->string)); |
| @@ -6031,7 +6032,7 @@ forward_to_next_line_start (struct it *it, int *skipped_p, | |||
| 6031 | if (!it->bidi_p) | 6032 | if (!it->bidi_p) |
| 6032 | { | 6033 | { |
| 6033 | IT_CHARPOS (*it) = limit; | 6034 | IT_CHARPOS (*it) = limit; |
| 6034 | IT_BYTEPOS (*it) = CHAR_TO_BYTE (limit); | 6035 | IT_BYTEPOS (*it) = bytepos; |
| 6035 | } | 6036 | } |
| 6036 | else | 6037 | else |
| 6037 | { | 6038 | { |
| @@ -7473,11 +7474,9 @@ get_visually_first_element (struct it *it) | |||
| 7473 | if (string_p) | 7474 | if (string_p) |
| 7474 | it->bidi_it.charpos = it->bidi_it.bytepos = 0; | 7475 | it->bidi_it.charpos = it->bidi_it.bytepos = 0; |
| 7475 | else | 7476 | else |
| 7476 | { | 7477 | it->bidi_it.charpos |
| 7477 | it->bidi_it.charpos = find_next_newline_no_quit (IT_CHARPOS (*it), | 7478 | = find_next_newline_no_quit (IT_CHARPOS (*it), -1, |
| 7478 | -1); | 7479 | &it->bidi_it.bytepos); |
| 7479 | it->bidi_it.bytepos = CHAR_TO_BYTE (it->bidi_it.charpos); | ||
| 7480 | } | ||
| 7481 | bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it, 1); | 7480 | bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it, 1); |
| 7482 | do | 7481 | do |
| 7483 | { | 7482 | { |
| @@ -9125,7 +9124,7 @@ move_it_vertically_backward (struct it *it, int dy) | |||
| 9125 | && FETCH_BYTE (IT_BYTEPOS (*it) - 1) != '\n') | 9124 | && FETCH_BYTE (IT_BYTEPOS (*it) - 1) != '\n') |
| 9126 | { | 9125 | { |
| 9127 | ptrdiff_t nl_pos = | 9126 | ptrdiff_t nl_pos = |
| 9128 | find_next_newline_no_quit (IT_CHARPOS (*it) - 1, -1); | 9127 | find_next_newline_no_quit (IT_CHARPOS (*it) - 1, -1, NULL); |
| 9129 | 9128 | ||
| 9130 | move_it_to (it, nl_pos, -1, -1, -1, MOVE_TO_POS); | 9129 | move_it_to (it, nl_pos, -1, -1, -1, MOVE_TO_POS); |
| 9131 | } | 9130 | } |