aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2011-08-05 17:21:29 -0700
committerPaul Eggert2011-08-05 17:21:29 -0700
commitc3b9a83ed346d1f0c9ab9f0776b527c74e3ca971 (patch)
tree04ac5617e8feb4ed4de3f650cdbdbee0af36b627 /src
parentd9f0172e44ae854a422fd52555f9535ed57f2392 (diff)
parentd747b53feb3e403571c724cc5add1e5e354f4408 (diff)
downloademacs-c3b9a83ed346d1f0c9ab9f0776b527c74e3ca971.tar.gz
emacs-c3b9a83ed346d1f0c9ab9f0776b527c74e3ca971.zip
Merge from trunk.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog28
-rw-r--r--src/bidi.c77
-rw-r--r--src/dispextern.h2
-rw-r--r--src/dispnew.c2
-rw-r--r--src/indent.c2
-rw-r--r--src/window.c18
-rw-r--r--src/xdisp.c74
7 files changed, 131 insertions, 72 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 8ed6761e1dd..60c835cb100 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,31 @@
12011-08-05 Eli Zaretskii <eliz@gnu.org>
2
3 * bidi.c <bidi_cache_total_alloc>: Now static.
4 (bidi_initialize): Initialize bidi_cache_total_alloc.
5
6 *xdisp.c (display_line): Release buffer allocated for shelved bidi
7 cache. (Bug#9221)
8
9 * bidi.c (bidi_shelve_cache, bidi_unshelve_cache): Track total
10 amount allocated this far in `bidi_cache_total_alloc'.
11 (bidi_unshelve_cache): Accept an additional argument JUST_FREE; if
12 non-zero, only free the data buffer without restoring the cache
13 contents. All callers changed.
14
15 * dispextern.h (bidi_unshelve_cache): Update prototype.
16
17 * xdisp.c (SAVE_IT, pos_visible_p, move_it_in_display_line_to)
18 (move_it_in_display_line, move_it_to)
19 (move_it_vertically_backward, move_it_by_lines): Replace the call
20 to xfree to an equivalent call to bidi_unshelve_cache.
21 (move_it_in_display_line_to): Fix logic of returning
22 MOVE_POS_MATCH_OR_ZV in the bidi case. (Bug#9224)
23
242011-08-05 Eli Zaretskii <eliz@gnu.org>
25
26 * xdisp.c (set_cursor_from_row): Prefer the candidate glyph that
27 came from a string character with a `cursor' property. (Bug#9229)
28
12011-08-04 Jan Djärv <jan.h.d@swipnet.se> 292011-08-04 Jan Djärv <jan.h.d@swipnet.se>
2 30
3 * Makefile.in (LIB_PTHREAD): New variable. 31 * Makefile.in (LIB_PTHREAD): New variable.
diff --git a/src/bidi.c b/src/bidi.c
index ae5143b37e0..0db144bea6c 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -620,12 +620,15 @@ bidi_pop_it (struct bidi_it *bidi_it)
620 bidi_cache_last_idx = -1; 620 bidi_cache_last_idx = -1;
621} 621}
622 622
623static ptrdiff_t bidi_cache_total_alloc;
624
623/* Stash away a copy of the cache and its control variables. */ 625/* Stash away a copy of the cache and its control variables. */
624void * 626void *
625bidi_shelve_cache (void) 627bidi_shelve_cache (void)
626{ 628{
627 unsigned char *databuf; 629 unsigned char *databuf;
628 630
631 /* Empty cache. */
629 if (bidi_cache_idx == 0) 632 if (bidi_cache_idx == 0)
630 return NULL; 633 return NULL;
631 634
@@ -634,6 +637,12 @@ bidi_shelve_cache (void)
634 + sizeof (bidi_cache_start_stack) 637 + sizeof (bidi_cache_start_stack)
635 + sizeof (bidi_cache_sp) + sizeof (bidi_cache_start) 638 + sizeof (bidi_cache_sp) + sizeof (bidi_cache_start)
636 + sizeof (bidi_cache_last_idx)); 639 + sizeof (bidi_cache_last_idx));
640 bidi_cache_total_alloc +=
641 sizeof (bidi_cache_idx) + bidi_cache_idx * sizeof (struct bidi_it)
642 + sizeof (bidi_cache_start_stack)
643 + sizeof (bidi_cache_sp) + sizeof (bidi_cache_start)
644 + sizeof (bidi_cache_last_idx);
645
637 memcpy (databuf, &bidi_cache_idx, sizeof (bidi_cache_idx)); 646 memcpy (databuf, &bidi_cache_idx, sizeof (bidi_cache_idx));
638 memcpy (databuf + sizeof (bidi_cache_idx), 647 memcpy (databuf + sizeof (bidi_cache_idx),
639 bidi_cache, bidi_cache_idx * sizeof (struct bidi_it)); 648 bidi_cache, bidi_cache_idx * sizeof (struct bidi_it));
@@ -659,7 +668,7 @@ bidi_shelve_cache (void)
659 668
660/* Restore the cache state from a copy stashed away by bidi_shelve_cache. */ 669/* Restore the cache state from a copy stashed away by bidi_shelve_cache. */
661void 670void
662bidi_unshelve_cache (void *databuf) 671bidi_unshelve_cache (void *databuf, int just_free)
663{ 672{
664 unsigned char *p = databuf; 673 unsigned char *p = databuf;
665 674
@@ -672,30 +681,47 @@ bidi_unshelve_cache (void *databuf)
672 } 681 }
673 else 682 else
674 { 683 {
675 memcpy (&bidi_cache_idx, p, sizeof (bidi_cache_idx)); 684 if (just_free)
676 bidi_cache_ensure_space (bidi_cache_idx); 685 {
677 memcpy (bidi_cache, p + sizeof (bidi_cache_idx), 686 ptrdiff_t idx;
678 bidi_cache_idx * sizeof (struct bidi_it)); 687
679 memcpy (bidi_cache_start_stack, 688 memcpy (&idx, p, sizeof (bidi_cache_idx));
680 p + sizeof (bidi_cache_idx) 689 bidi_cache_total_alloc -=
681 + bidi_cache_idx * sizeof (struct bidi_it), 690 sizeof (bidi_cache_idx) + idx * sizeof (struct bidi_it)
682 sizeof (bidi_cache_start_stack)); 691 + sizeof (bidi_cache_start_stack) + sizeof (bidi_cache_sp)
683 memcpy (&bidi_cache_sp, 692 + sizeof (bidi_cache_start) + sizeof (bidi_cache_last_idx);
684 p + sizeof (bidi_cache_idx) 693 }
685 + bidi_cache_idx * sizeof (struct bidi_it) 694 else
686 + sizeof (bidi_cache_start_stack), 695 {
687 sizeof (bidi_cache_sp)); 696 memcpy (&bidi_cache_idx, p, sizeof (bidi_cache_idx));
688 memcpy (&bidi_cache_start, 697 bidi_cache_ensure_space (bidi_cache_idx);
689 p + sizeof (bidi_cache_idx) 698 memcpy (bidi_cache, p + sizeof (bidi_cache_idx),
690 + bidi_cache_idx * sizeof (struct bidi_it) 699 bidi_cache_idx * sizeof (struct bidi_it));
691 + sizeof (bidi_cache_start_stack) + sizeof (bidi_cache_sp), 700 memcpy (bidi_cache_start_stack,
692 sizeof (bidi_cache_start)); 701 p + sizeof (bidi_cache_idx)
693 memcpy (&bidi_cache_last_idx, 702 + bidi_cache_idx * sizeof (struct bidi_it),
694 p + sizeof (bidi_cache_idx) 703 sizeof (bidi_cache_start_stack));
695 + bidi_cache_idx * sizeof (struct bidi_it) 704 memcpy (&bidi_cache_sp,
696 + sizeof (bidi_cache_start_stack) + sizeof (bidi_cache_sp) 705 p + sizeof (bidi_cache_idx)
697 + sizeof (bidi_cache_start), 706 + bidi_cache_idx * sizeof (struct bidi_it)
698 sizeof (bidi_cache_last_idx)); 707 + sizeof (bidi_cache_start_stack),
708 sizeof (bidi_cache_sp));
709 memcpy (&bidi_cache_start,
710 p + sizeof (bidi_cache_idx)
711 + bidi_cache_idx * sizeof (struct bidi_it)
712 + sizeof (bidi_cache_start_stack) + sizeof (bidi_cache_sp),
713 sizeof (bidi_cache_start));
714 memcpy (&bidi_cache_last_idx,
715 p + sizeof (bidi_cache_idx)
716 + bidi_cache_idx * sizeof (struct bidi_it)
717 + sizeof (bidi_cache_start_stack) + sizeof (bidi_cache_sp)
718 + sizeof (bidi_cache_start),
719 sizeof (bidi_cache_last_idx));
720 bidi_cache_total_alloc -=
721 sizeof (bidi_cache_idx) + bidi_cache_idx * sizeof (struct bidi_it)
722 + sizeof (bidi_cache_start_stack) + sizeof (bidi_cache_sp)
723 + sizeof (bidi_cache_start) + sizeof (bidi_cache_last_idx);
724 }
699 725
700 xfree (p); 726 xfree (p);
701 } 727 }
@@ -742,6 +768,7 @@ bidi_initialize (void)
742 staticpro (&paragraph_separate_re); 768 staticpro (&paragraph_separate_re);
743 769
744 bidi_cache_sp = 0; 770 bidi_cache_sp = 0;
771 bidi_cache_total_alloc = 0;
745 772
746 bidi_initialized = 1; 773 bidi_initialized = 1;
747} 774}
diff --git a/src/dispextern.h b/src/dispextern.h
index 2e245479a81..ea4b11baa74 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -2978,7 +2978,7 @@ extern int bidi_mirror_char (int);
2978extern void bidi_push_it (struct bidi_it *); 2978extern void bidi_push_it (struct bidi_it *);
2979extern void bidi_pop_it (struct bidi_it *); 2979extern void bidi_pop_it (struct bidi_it *);
2980extern void *bidi_shelve_cache (void); 2980extern void *bidi_shelve_cache (void);
2981extern void bidi_unshelve_cache (void *); 2981extern void bidi_unshelve_cache (void *, int);
2982 2982
2983/* Defined in xdisp.c */ 2983/* Defined in xdisp.c */
2984 2984
diff --git a/src/dispnew.c b/src/dispnew.c
index b2f416701c3..fadfbb26603 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -5282,7 +5282,7 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p
5282 argument is ZV to prevent move_it_in_display_line from matching 5282 argument is ZV to prevent move_it_in_display_line from matching
5283 based on buffer positions. */ 5283 based on buffer positions. */
5284 move_it_in_display_line (&it, ZV, to_x, MOVE_TO_X); 5284 move_it_in_display_line (&it, ZV, to_x, MOVE_TO_X);
5285 bidi_unshelve_cache (itdata); 5285 bidi_unshelve_cache (itdata, 0);
5286 5286
5287 Fset_buffer (old_current_buffer); 5287 Fset_buffer (old_current_buffer);
5288 5288
diff --git a/src/indent.c b/src/indent.c
index aaeaaf591ef..70689311dd5 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -2135,7 +2135,7 @@ whether or not it is currently displayed in some window. */)
2135 } 2135 }
2136 2136
2137 SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); 2137 SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it));
2138 bidi_unshelve_cache (itdata); 2138 bidi_unshelve_cache (itdata, 0);
2139 } 2139 }
2140 2140
2141 if (BUFFERP (old_buffer)) 2141 if (BUFFERP (old_buffer))
diff --git a/src/window.c b/src/window.c
index 3f5a743f5c6..8df4a857851 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1379,7 +1379,7 @@ if it isn't already recorded. */)
1379 if (it.current_y < it.last_visible_y) 1379 if (it.current_y < it.last_visible_y)
1380 move_it_past_eol (&it); 1380 move_it_past_eol (&it);
1381 value = make_number (IT_CHARPOS (it)); 1381 value = make_number (IT_CHARPOS (it));
1382 bidi_unshelve_cache (itdata); 1382 bidi_unshelve_cache (itdata, 0);
1383 1383
1384 if (old_buffer) 1384 if (old_buffer)
1385 set_buffer_internal (old_buffer); 1385 set_buffer_internal (old_buffer);
@@ -4273,7 +4273,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4273 } 4273 }
4274 4274
4275 start = it.current.pos; 4275 start = it.current.pos;
4276 bidi_unshelve_cache (itdata); 4276 bidi_unshelve_cache (itdata, 0);
4277 } 4277 }
4278 else if (auto_window_vscroll_p) 4278 else if (auto_window_vscroll_p)
4279 { 4279 {
@@ -4417,7 +4417,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4417 } 4417 }
4418 else 4418 else
4419 { 4419 {
4420 bidi_unshelve_cache (itdata); 4420 bidi_unshelve_cache (itdata, 0);
4421 if (noerror) 4421 if (noerror)
4422 return; 4422 return;
4423 else if (n < 0) /* could happen with empty buffers */ 4423 else if (n < 0) /* could happen with empty buffers */
@@ -4434,7 +4434,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4434 w->vscroll = 0; 4434 w->vscroll = 0;
4435 else 4435 else
4436 { 4436 {
4437 bidi_unshelve_cache (itdata); 4437 bidi_unshelve_cache (itdata, 0);
4438 if (noerror) 4438 if (noerror)
4439 return; 4439 return;
4440 else 4440 else
@@ -4583,7 +4583,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4583 SET_PT_BOTH (charpos, bytepos); 4583 SET_PT_BOTH (charpos, bytepos);
4584 } 4584 }
4585 } 4585 }
4586 bidi_unshelve_cache (itdata); 4586 bidi_unshelve_cache (itdata, 0);
4587} 4587}
4588 4588
4589 4589
@@ -5010,7 +5010,7 @@ displayed_window_lines (struct window *w)
5010 start_display (&it, w, start); 5010 start_display (&it, w, start);
5011 move_it_vertically (&it, height); 5011 move_it_vertically (&it, height);
5012 bottom_y = line_bottom_y (&it); 5012 bottom_y = line_bottom_y (&it);
5013 bidi_unshelve_cache (itdata); 5013 bidi_unshelve_cache (itdata, 0);
5014 5014
5015 /* rms: On a non-window display, 5015 /* rms: On a non-window display,
5016 the value of it.vpos at the bottom of the screen 5016 the value of it.vpos at the bottom of the screen
@@ -5116,7 +5116,7 @@ and redisplay normally--don't erase and redraw the frame. */)
5116 move_it_vertically_backward (&it, window_box_height (w) / 2); 5116 move_it_vertically_backward (&it, window_box_height (w) / 2);
5117 charpos = IT_CHARPOS (it); 5117 charpos = IT_CHARPOS (it);
5118 bytepos = IT_BYTEPOS (it); 5118 bytepos = IT_BYTEPOS (it);
5119 bidi_unshelve_cache (itdata); 5119 bidi_unshelve_cache (itdata, 0);
5120 } 5120 }
5121 else if (iarg < 0) 5121 else if (iarg < 0)
5122 { 5122 {
@@ -5164,7 +5164,7 @@ and redisplay normally--don't erase and redraw the frame. */)
5164 } 5164 }
5165 if (h <= 0) 5165 if (h <= 0)
5166 { 5166 {
5167 bidi_unshelve_cache (itdata); 5167 bidi_unshelve_cache (itdata, 0);
5168 return Qnil; 5168 return Qnil;
5169 } 5169 }
5170 5170
@@ -5187,7 +5187,7 @@ and redisplay normally--don't erase and redraw the frame. */)
5187 charpos = IT_CHARPOS (it); 5187 charpos = IT_CHARPOS (it);
5188 bytepos = IT_BYTEPOS (it); 5188 bytepos = IT_BYTEPOS (it);
5189 5189
5190 bidi_unshelve_cache (itdata); 5190 bidi_unshelve_cache (itdata, 0);
5191 } 5191 }
5192 else 5192 else
5193 { 5193 {
diff --git a/src/xdisp.c b/src/xdisp.c
index 923f0aba591..6800dcf694c 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -604,7 +604,7 @@ int current_mode_line_height, current_header_line_height;
604#define SAVE_IT(ITCOPY,ITORIG,CACHE) \ 604#define SAVE_IT(ITCOPY,ITORIG,CACHE) \
605 do { \ 605 do { \
606 if (CACHE) \ 606 if (CACHE) \
607 xfree (CACHE); \ 607 bidi_unshelve_cache (CACHE, 1); \
608 ITCOPY = ITORIG; \ 608 ITCOPY = ITORIG; \
609 CACHE = bidi_shelve_cache(); \ 609 CACHE = bidi_shelve_cache(); \
610 } while (0) 610 } while (0)
@@ -613,7 +613,7 @@ int current_mode_line_height, current_header_line_height;
613 do { \ 613 do { \
614 if (pITORIG != pITCOPY) \ 614 if (pITORIG != pITCOPY) \
615 *(pITORIG) = *(pITCOPY); \ 615 *(pITORIG) = *(pITCOPY); \
616 bidi_unshelve_cache (CACHE); \ 616 bidi_unshelve_cache (CACHE, 0); \
617 CACHE = NULL; \ 617 CACHE = NULL; \
618 } while (0) 618 } while (0)
619 619
@@ -1341,9 +1341,9 @@ pos_visible_p (struct window *w, EMACS_INT charpos, int *x, int *y,
1341 *vpos = it2.vpos; 1341 *vpos = it2.vpos;
1342 } 1342 }
1343 else 1343 else
1344 xfree (it2data); 1344 bidi_unshelve_cache (it2data, 1);
1345 } 1345 }
1346 bidi_unshelve_cache (itdata); 1346 bidi_unshelve_cache (itdata, 0);
1347 1347
1348 if (old_buffer) 1348 if (old_buffer)
1349 set_buffer_internal_1 (old_buffer); 1349 set_buffer_internal_1 (old_buffer);
@@ -2627,7 +2627,7 @@ init_iterator (struct it *it, struct window *w,
2627 it->paragraph_embedding = R2L; 2627 it->paragraph_embedding = R2L;
2628 else 2628 else
2629 it->paragraph_embedding = NEUTRAL_DIR; 2629 it->paragraph_embedding = NEUTRAL_DIR;
2630 bidi_unshelve_cache (NULL); 2630 bidi_unshelve_cache (NULL, 0);
2631 bidi_init_it (charpos, IT_BYTEPOS (*it), FRAME_WINDOW_P (it->f), 2631 bidi_init_it (charpos, IT_BYTEPOS (*it), FRAME_WINDOW_P (it->f),
2632 &it->bidi_it); 2632 &it->bidi_it);
2633 } 2633 }
@@ -5620,7 +5620,7 @@ back_to_previous_visible_line_start (struct it *it)
5620 pos = --IT_CHARPOS (it2); 5620 pos = --IT_CHARPOS (it2);
5621 --IT_BYTEPOS (it2); 5621 --IT_BYTEPOS (it2);
5622 it2.sp = 0; 5622 it2.sp = 0;
5623 bidi_unshelve_cache (NULL); 5623 bidi_unshelve_cache (NULL, 0);
5624 it2.string_from_display_prop_p = 0; 5624 it2.string_from_display_prop_p = 0;
5625 it2.from_disp_prop_p = 0; 5625 it2.from_disp_prop_p = 0;
5626 if (handle_display_prop (&it2) == HANDLED_RETURN 5626 if (handle_display_prop (&it2) == HANDLED_RETURN
@@ -5830,7 +5830,7 @@ reseat_1 (struct it *it, struct text_pos pos, int set_stop_p)
5830 { 5830 {
5831 bidi_init_it (IT_CHARPOS (*it), IT_BYTEPOS (*it), FRAME_WINDOW_P (it->f), 5831 bidi_init_it (IT_CHARPOS (*it), IT_BYTEPOS (*it), FRAME_WINDOW_P (it->f),
5832 &it->bidi_it); 5832 &it->bidi_it);
5833 bidi_unshelve_cache (NULL); 5833 bidi_unshelve_cache (NULL, 0);
5834 it->bidi_it.paragraph_dir = NEUTRAL_DIR; 5834 it->bidi_it.paragraph_dir = NEUTRAL_DIR;
5835 it->bidi_it.string.s = NULL; 5835 it->bidi_it.string.s = NULL;
5836 it->bidi_it.string.lstring = Qnil; 5836 it->bidi_it.string.lstring = Qnil;
@@ -8011,13 +8011,13 @@ move_it_in_display_line_to (struct it *it,
8011 positions smaller than TO_CHARPOS, return 8011 positions smaller than TO_CHARPOS, return
8012 MOVE_POS_MATCH_OR_ZV, like the unidirectional display 8012 MOVE_POS_MATCH_OR_ZV, like the unidirectional display
8013 did. */ 8013 did. */
8014 if ((op & MOVE_TO_POS) != 0 8014 if (it->bidi_p && (op & MOVE_TO_POS) != 0
8015 && !saw_smaller_pos 8015 && !saw_smaller_pos
8016 && IT_CHARPOS (*it) > to_charpos) 8016 && IT_CHARPOS (*it) > to_charpos)
8017 { 8017 {
8018 result = MOVE_POS_MATCH_OR_ZV; 8018 if (IT_CHARPOS (ppos_it) < ZV)
8019 if (it->bidi_p && IT_CHARPOS (ppos_it) < ZV)
8020 RESTORE_IT (it, &ppos_it, ppos_data); 8019 RESTORE_IT (it, &ppos_it, ppos_data);
8020 goto buffer_pos_reached;
8021 } 8021 }
8022 else 8022 else
8023 result = MOVE_NEWLINE_OR_CR; 8023 result = MOVE_NEWLINE_OR_CR;
@@ -8056,14 +8056,13 @@ move_it_in_display_line_to (struct it *it,
8056 character positions smaller than TO_CHARPOS, 8056 character positions smaller than TO_CHARPOS,
8057 return MOVE_POS_MATCH_OR_ZV, like the 8057 return MOVE_POS_MATCH_OR_ZV, like the
8058 unidirectional display did. */ 8058 unidirectional display did. */
8059 || ((op & MOVE_TO_POS) != 0 8059 || (it->bidi_p && (op & MOVE_TO_POS) != 0
8060 && !saw_smaller_pos 8060 && !saw_smaller_pos
8061 && IT_CHARPOS (*it) > to_charpos)) 8061 && IT_CHARPOS (*it) > to_charpos))
8062 { 8062 {
8063 result = MOVE_POS_MATCH_OR_ZV; 8063 if (!at_eob_p && IT_CHARPOS (ppos_it) < ZV)
8064 if (it->bidi_p && !at_eob_p && IT_CHARPOS (ppos_it) < ZV)
8065 RESTORE_IT (it, &ppos_it, ppos_data); 8064 RESTORE_IT (it, &ppos_it, ppos_data);
8066 break; 8065 goto buffer_pos_reached;
8067 } 8066 }
8068 if (ITERATOR_AT_END_OF_LINE_P (it)) 8067 if (ITERATOR_AT_END_OF_LINE_P (it))
8069 { 8068 {
@@ -8071,14 +8070,13 @@ move_it_in_display_line_to (struct it *it,
8071 break; 8070 break;
8072 } 8071 }
8073 } 8072 }
8074 else if ((op & MOVE_TO_POS) != 0 8073 else if (it->bidi_p && (op & MOVE_TO_POS) != 0
8075 && !saw_smaller_pos 8074 && !saw_smaller_pos
8076 && IT_CHARPOS (*it) > to_charpos) 8075 && IT_CHARPOS (*it) > to_charpos)
8077 { 8076 {
8078 result = MOVE_POS_MATCH_OR_ZV; 8077 if (IT_CHARPOS (ppos_it) < ZV)
8079 if (it->bidi_p && IT_CHARPOS (ppos_it) < ZV)
8080 RESTORE_IT (it, &ppos_it, ppos_data); 8078 RESTORE_IT (it, &ppos_it, ppos_data);
8081 break; 8079 goto buffer_pos_reached;
8082 } 8080 }
8083 result = MOVE_LINE_TRUNCATED; 8081 result = MOVE_LINE_TRUNCATED;
8084 break; 8082 break;
@@ -8098,13 +8096,13 @@ move_it_in_display_line_to (struct it *it,
8098 done: 8096 done:
8099 8097
8100 if (atpos_data) 8098 if (atpos_data)
8101 xfree (atpos_data); 8099 bidi_unshelve_cache (atpos_data, 1);
8102 if (atx_data) 8100 if (atx_data)
8103 xfree (atx_data); 8101 bidi_unshelve_cache (atx_data, 1);
8104 if (wrap_data) 8102 if (wrap_data)
8105 xfree (wrap_data); 8103 bidi_unshelve_cache (wrap_data, 1);
8106 if (ppos_data) 8104 if (ppos_data)
8107 xfree (ppos_data); 8105 bidi_unshelve_cache (ppos_data, 1);
8108 8106
8109 /* Restore the iterator settings altered at the beginning of this 8107 /* Restore the iterator settings altered at the beginning of this
8110 function. */ 8108 function. */
@@ -8139,7 +8137,7 @@ move_it_in_display_line (struct it *it,
8139 (it, -1, prev_x, MOVE_TO_X); 8137 (it, -1, prev_x, MOVE_TO_X);
8140 } 8138 }
8141 else 8139 else
8142 xfree (save_data); 8140 bidi_unshelve_cache (save_data, 1);
8143 } 8141 }
8144 else 8142 else
8145 move_it_in_display_line_to (it, to_charpos, to_x, op); 8143 move_it_in_display_line_to (it, to_charpos, to_x, op);
@@ -8398,7 +8396,7 @@ move_it_to (struct it *it, EMACS_INT to_charpos, int to_x, int to_y, int to_vpos
8398 } 8396 }
8399 8397
8400 if (backup_data) 8398 if (backup_data)
8401 xfree (backup_data); 8399 bidi_unshelve_cache (backup_data, 1);
8402 8400
8403 TRACE_MOVE ((stderr, "move_it_to: reached %d\n", reached)); 8401 TRACE_MOVE ((stderr, "move_it_to: reached %d\n", reached));
8404} 8402}
@@ -8477,7 +8475,7 @@ move_it_vertically_backward (struct it *it, int dy)
8477 RESTORE_IT (it, it, it2data); 8475 RESTORE_IT (it, it, it2data);
8478 if (nlines > 0) 8476 if (nlines > 0)
8479 move_it_by_lines (it, nlines); 8477 move_it_by_lines (it, nlines);
8480 xfree (it3data); 8478 bidi_unshelve_cache (it3data, 1);
8481 } 8479 }
8482 else 8480 else
8483 { 8481 {
@@ -8673,7 +8671,7 @@ move_it_by_lines (struct it *it, int dvpos)
8673 if (IT_CHARPOS (*it) >= start_charpos) 8671 if (IT_CHARPOS (*it) >= start_charpos)
8674 RESTORE_IT (it, &it2, it2data); 8672 RESTORE_IT (it, &it2, it2data);
8675 else 8673 else
8676 xfree (it2data); 8674 bidi_unshelve_cache (it2data, 1);
8677 } 8675 }
8678 else 8676 else
8679 RESTORE_IT (it, it, it2data); 8677 RESTORE_IT (it, it, it2data);
@@ -13708,14 +13706,12 @@ set_cursor_from_row (struct window *w, struct glyph_row *row,
13708 w->cursor.vpos >= 0 13706 w->cursor.vpos >= 0
13709 /* that candidate is not the row we are processing */ 13707 /* that candidate is not the row we are processing */
13710 && MATRIX_ROW (matrix, w->cursor.vpos) != row 13708 && MATRIX_ROW (matrix, w->cursor.vpos) != row
13711 /* the row we are processing is part of a continued line */
13712 && (row->continued_p || MATRIX_ROW_CONTINUATION_LINE_P (row))
13713 /* Make sure cursor.vpos specifies a row whose start and end 13709 /* Make sure cursor.vpos specifies a row whose start and end
13714 charpos occlude point. This is because some callers of this 13710 charpos occlude point. This is because some callers of this
13715 function leave cursor.vpos at the row where the cursor was 13711 function leave cursor.vpos at the row where the cursor was
13716 displayed during the last redisplay cycle. */ 13712 displayed during the last redisplay cycle. */
13717 && MATRIX_ROW_START_CHARPOS (MATRIX_ROW (matrix, w->cursor.vpos)) <= pt_old 13713 && MATRIX_ROW_START_CHARPOS (MATRIX_ROW (matrix, w->cursor.vpos)) <= pt_old
13718 && pt_old < MATRIX_ROW_END_CHARPOS (MATRIX_ROW (matrix, w->cursor.vpos))) 13714 && pt_old <= MATRIX_ROW_END_CHARPOS (MATRIX_ROW (matrix, w->cursor.vpos)))
13719 { 13715 {
13720 struct glyph *g1 = 13716 struct glyph *g1 =
13721 MATRIX_ROW_GLYPH_START (matrix, w->cursor.vpos) + w->cursor.hpos; 13717 MATRIX_ROW_GLYPH_START (matrix, w->cursor.vpos) + w->cursor.hpos;
@@ -13724,15 +13720,20 @@ set_cursor_from_row (struct window *w, struct glyph_row *row,
13724 if (!(row->reversed_p ? glyph > glyphs_end : glyph < glyphs_end)) 13720 if (!(row->reversed_p ? glyph > glyphs_end : glyph < glyphs_end))
13725 return 0; 13721 return 0;
13726 /* Keep the candidate whose buffer position is the closest to 13722 /* Keep the candidate whose buffer position is the closest to
13727 point. */ 13723 point or has the `cursor' property. */
13728 if (/* previous candidate is a glyph in TEXT_AREA of that row */ 13724 if (/* previous candidate is a glyph in TEXT_AREA of that row */
13729 w->cursor.hpos >= 0 13725 w->cursor.hpos >= 0
13730 && w->cursor.hpos < MATRIX_ROW_USED (matrix, w->cursor.vpos) 13726 && w->cursor.hpos < MATRIX_ROW_USED (matrix, w->cursor.vpos)
13731 && BUFFERP (g1->object) 13727 && ((BUFFERP (g1->object)
13732 && (g1->charpos == pt_old /* an exact match always wins */ 13728 && (g1->charpos == pt_old /* an exact match always wins */
13733 || (BUFFERP (glyph->object) 13729 || (BUFFERP (glyph->object)
13734 && eabs (g1->charpos - pt_old) 13730 && eabs (g1->charpos - pt_old)
13735 < eabs (glyph->charpos - pt_old)))) 13731 < eabs (glyph->charpos - pt_old))))
13732 /* previous candidate is a glyph from a string that has
13733 a non-nil `cursor' property */
13734 || (STRINGP (g1->object)
13735 && !NILP (Fget_char_property (make_number (g1->charpos),
13736 Qcursor, g1->object)))))
13736 return 0; 13737 return 0;
13737 /* If this candidate gives an exact match, use that. */ 13738 /* If this candidate gives an exact match, use that. */
13738 if (!(BUFFERP (glyph->object) && glyph->charpos == pt_old) 13739 if (!(BUFFERP (glyph->object) && glyph->charpos == pt_old)
@@ -18778,6 +18779,9 @@ display_line (struct it *it)
18778 } 18779 }
18779 } 18780 }
18780 18781
18782 if (wrap_data)
18783 bidi_unshelve_cache (wrap_data, 1);
18784
18781 /* If line is not empty and hscrolled, maybe insert truncation glyphs 18785 /* If line is not empty and hscrolled, maybe insert truncation glyphs
18782 at the left window margin. */ 18786 at the left window margin. */
18783 if (it->first_visible_x 18787 if (it->first_visible_x