diff options
| author | Dmitry Antipov | 2013-02-20 09:18:20 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2013-02-20 09:18:20 +0400 |
| commit | 2a14a4f13cdb22f5b6b0840081d977c8d38a91e6 (patch) | |
| tree | 06dd7c36007f50d291a9443aa0f6901c65c2f4b8 /src | |
| parent | 1dfcc79e83d3db031b45e9f6b9314dc1f0697b1d (diff) | |
| download | emacs-2a14a4f13cdb22f5b6b0840081d977c8d38a91e6.tar.gz emacs-2a14a4f13cdb22f5b6b0840081d977c8d38a91e6.zip | |
* search.c (find_newline): Return byte position in bytepos.
Adjust comment.
(find_next_newline_no_quit, find_before_next_newline): Add
bytepos argument.
* lisp.h (find_newline, find_next_newline_no_quit)
(find_before_next_newline): Adjust prototypes.
* bidi.c (bidi_find_paragraph_start):
* editfns.c (Fconstrain_to_field, Fline_end_position):
* indent.c (compute_motion, vmotion):
* xdisp.c (back_to_previous_line_start, forward_to_next_line_start):
(get_visually_first_element, move_it_vertically_backward):
Adjust users and avoid calls to CHAR_TO_BYTE where appropriate.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 15 | ||||
| -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/lisp.h | 7 | ||||
| -rw-r--r-- | src/search.c | 51 | ||||
| -rw-r--r-- | src/xdisp.c | 21 |
7 files changed, 82 insertions, 61 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index ff059cf1a3c..7396ccb3759 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | 2013-02-20 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 2 | |||
| 3 | * search.c (find_newline): Return byte position in bytepos. | ||
| 4 | Adjust comment. | ||
| 5 | (find_next_newline_no_quit, find_before_next_newline): Add | ||
| 6 | bytepos argument. | ||
| 7 | * lisp.h (find_newline, find_next_newline_no_quit) | ||
| 8 | (find_before_next_newline): Adjust prototypes. | ||
| 9 | * bidi.c (bidi_find_paragraph_start): | ||
| 10 | * editfns.c (Fconstrain_to_field, Fline_end_position): | ||
| 11 | * indent.c (compute_motion, vmotion): | ||
| 12 | * xdisp.c (back_to_previous_line_start, forward_to_next_line_start): | ||
| 13 | (get_visually_first_element, move_it_vertically_backward): | ||
| 14 | Adjust users and avoid calls to CHAR_TO_BYTE where appropriate. | ||
| 15 | |||
| 1 | 2013-02-19 Eli Zaretskii <eliz@gnu.org> | 16 | 2013-02-19 Eli Zaretskii <eliz@gnu.org> |
| 2 | 17 | ||
| 3 | * w32proc.c (new_child): Avoid leaking handles if the subprocess | 18 | * 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/lisp.h b/src/lisp.h index 79fc9616d67..e0a8b237e72 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -3343,12 +3343,13 @@ extern ptrdiff_t fast_string_match_ignore_case (Lisp_Object, Lisp_Object); | |||
| 3343 | extern ptrdiff_t fast_looking_at (Lisp_Object, ptrdiff_t, ptrdiff_t, | 3343 | extern ptrdiff_t fast_looking_at (Lisp_Object, ptrdiff_t, ptrdiff_t, |
| 3344 | ptrdiff_t, ptrdiff_t, Lisp_Object); | 3344 | ptrdiff_t, ptrdiff_t, Lisp_Object); |
| 3345 | extern ptrdiff_t find_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t, | 3345 | extern ptrdiff_t find_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t, |
| 3346 | ptrdiff_t *, bool); | 3346 | ptrdiff_t *, ptrdiff_t *, bool); |
| 3347 | extern EMACS_INT scan_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, | 3347 | extern EMACS_INT scan_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, |
| 3348 | EMACS_INT, bool); | 3348 | EMACS_INT, bool); |
| 3349 | extern ptrdiff_t find_next_newline (ptrdiff_t, int); | 3349 | extern ptrdiff_t find_next_newline (ptrdiff_t, int); |
| 3350 | extern ptrdiff_t find_next_newline_no_quit (ptrdiff_t, ptrdiff_t); | 3350 | extern ptrdiff_t find_next_newline_no_quit (ptrdiff_t, ptrdiff_t, ptrdiff_t *); |
| 3351 | extern ptrdiff_t find_before_next_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t); | 3351 | extern ptrdiff_t find_before_next_newline (ptrdiff_t, ptrdiff_t, |
| 3352 | ptrdiff_t, ptrdiff_t *); | ||
| 3352 | extern void syms_of_search (void); | 3353 | extern void syms_of_search (void); |
| 3353 | extern void clear_regexp_cache (void); | 3354 | extern void clear_regexp_cache (void); |
| 3354 | 3355 | ||
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/xdisp.c b/src/xdisp.c index f32b88f3027..6b86fd076a5 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -5905,8 +5905,9 @@ pop_it (struct it *it) | |||
| 5905 | static void | 5905 | static void |
| 5906 | back_to_previous_line_start (struct it *it) | 5906 | back_to_previous_line_start (struct it *it) |
| 5907 | { | 5907 | { |
| 5908 | IT_CHARPOS (*it) = find_next_newline_no_quit (IT_CHARPOS (*it) - 1, -1); | 5908 | IT_CHARPOS (*it) |
| 5909 | IT_BYTEPOS (*it) = CHAR_TO_BYTE (IT_CHARPOS (*it)); | 5909 | = find_next_newline_no_quit (IT_CHARPOS (*it) - 1, |
| 5910 | -1, &IT_BYTEPOS (*it)); | ||
| 5910 | } | 5911 | } |
| 5911 | 5912 | ||
| 5912 | 5913 | ||
| @@ -5977,8 +5978,8 @@ forward_to_next_line_start (struct it *it, int *skipped_p, | |||
| 5977 | short-cut. */ | 5978 | short-cut. */ |
| 5978 | if (!newline_found_p) | 5979 | if (!newline_found_p) |
| 5979 | { | 5980 | { |
| 5980 | ptrdiff_t start = IT_CHARPOS (*it); | 5981 | ptrdiff_t bytepos, start = IT_CHARPOS (*it); |
| 5981 | ptrdiff_t limit = find_next_newline_no_quit (start, 1); | 5982 | ptrdiff_t limit = find_next_newline_no_quit (start, 1, &bytepos); |
| 5982 | Lisp_Object pos; | 5983 | Lisp_Object pos; |
| 5983 | 5984 | ||
| 5984 | eassert (!STRINGP (it->string)); | 5985 | eassert (!STRINGP (it->string)); |
| @@ -5996,7 +5997,7 @@ forward_to_next_line_start (struct it *it, int *skipped_p, | |||
| 5996 | if (!it->bidi_p) | 5997 | if (!it->bidi_p) |
| 5997 | { | 5998 | { |
| 5998 | IT_CHARPOS (*it) = limit; | 5999 | IT_CHARPOS (*it) = limit; |
| 5999 | IT_BYTEPOS (*it) = CHAR_TO_BYTE (limit); | 6000 | IT_BYTEPOS (*it) = bytepos; |
| 6000 | } | 6001 | } |
| 6001 | else | 6002 | else |
| 6002 | { | 6003 | { |
| @@ -7432,11 +7433,9 @@ get_visually_first_element (struct it *it) | |||
| 7432 | if (string_p) | 7433 | if (string_p) |
| 7433 | it->bidi_it.charpos = it->bidi_it.bytepos = 0; | 7434 | it->bidi_it.charpos = it->bidi_it.bytepos = 0; |
| 7434 | else | 7435 | else |
| 7435 | { | 7436 | it->bidi_it.charpos |
| 7436 | it->bidi_it.charpos = find_next_newline_no_quit (IT_CHARPOS (*it), | 7437 | = find_next_newline_no_quit (IT_CHARPOS (*it), -1, |
| 7437 | -1); | 7438 | &it->bidi_it.bytepos); |
| 7438 | it->bidi_it.bytepos = CHAR_TO_BYTE (it->bidi_it.charpos); | ||
| 7439 | } | ||
| 7440 | bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it, 1); | 7439 | bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it, 1); |
| 7441 | do | 7440 | do |
| 7442 | { | 7441 | { |
| @@ -9071,7 +9070,7 @@ move_it_vertically_backward (struct it *it, int dy) | |||
| 9071 | && FETCH_BYTE (IT_BYTEPOS (*it) - 1) != '\n') | 9070 | && FETCH_BYTE (IT_BYTEPOS (*it) - 1) != '\n') |
| 9072 | { | 9071 | { |
| 9073 | ptrdiff_t nl_pos = | 9072 | ptrdiff_t nl_pos = |
| 9074 | find_next_newline_no_quit (IT_CHARPOS (*it) - 1, -1); | 9073 | find_next_newline_no_quit (IT_CHARPOS (*it) - 1, -1, NULL); |
| 9075 | 9074 | ||
| 9076 | move_it_to (it, nl_pos, -1, -1, -1, MOVE_TO_POS); | 9075 | move_it_to (it, nl_pos, -1, -1, -1, MOVE_TO_POS); |
| 9077 | } | 9076 | } |