aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2014-10-10 16:31:23 +0300
committerEli Zaretskii2014-10-10 16:31:23 +0300
commit70939d8240d403b8d126783dc0eee2452765ea42 (patch)
tree29bf9feb6db0fb290ea8b1f7a906ac1a77ee7a76
parentf6d76d1c6cc380bd9cd8911214e18eca247c7bf4 (diff)
downloademacs-70939d8240d403b8d126783dc0eee2452765ea42.tar.gz
emacs-70939d8240d403b8d126783dc0eee2452765ea42.zip
Fix assertion violations due to unresolvable neutrals in cache.
-rw-r--r--src/bidi.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/bidi.c b/src/bidi.c
index 989bcf5989b..a1fe68faab4 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -592,7 +592,7 @@ bidi_cache_fetch_state (ptrdiff_t idx, struct bidi_it *bidi_it)
592} 592}
593 593
594/* Find a cached state with a given CHARPOS and resolved embedding 594/* Find a cached state with a given CHARPOS and resolved embedding
595 level less or equal to LEVEL. if LEVEL is -1, disregard the 595 level less or equal to LEVEL. If LEVEL is -1, disregard the
596 resolved levels in cached states. DIR, if non-zero, means search 596 resolved levels in cached states. DIR, if non-zero, means search
597 in that direction from the last cache hit. */ 597 in that direction from the last cache hit. */
598static ptrdiff_t 598static ptrdiff_t
@@ -778,12 +778,23 @@ bidi_cache_iterator_state (struct bidi_it *bidi_it, bool resolved)
778 bidi_cache_idx = idx + 1; 778 bidi_cache_idx = idx + 1;
779} 779}
780 780
781/* Look for a cached iterator state that corresponds to CHARPOS. If
782 found, copy the cached state into BIDI_IT and return the type of
783 the cached entry. If not found, return UNKNOWN_BT. NEUTRALS_OK
784 non-zero means it is OK to return cached state for neutral
785 characters that have no valid next_for_neutral member, and
786 therefore cannot be resolved. This can happen if the state was
787 cached before it was resolved in bidi_resolve_neutral. */
781static bidi_type_t 788static bidi_type_t
782bidi_cache_find (ptrdiff_t charpos, int level, struct bidi_it *bidi_it) 789bidi_cache_find (ptrdiff_t charpos, bool neutrals_ok, struct bidi_it *bidi_it)
783{ 790{
784 ptrdiff_t i = bidi_cache_search (charpos, level, bidi_it->scan_dir); 791 ptrdiff_t i = bidi_cache_search (charpos, -1, bidi_it->scan_dir);
785 792
786 if (i >= bidi_cache_start) 793 if (i >= bidi_cache_start
794 && (neutrals_ok
795 || !(bidi_cache[i].resolved_level == -1
796 && bidi_get_category (bidi_cache[i].type) == NEUTRAL
797 && bidi_cache[i].next_for_neutral.type == UNKNOWN_BT)))
787 { 798 {
788 bidi_dir_t current_scan_dir = bidi_it->scan_dir; 799 bidi_dir_t current_scan_dir = bidi_it->scan_dir;
789 800
@@ -2421,6 +2432,9 @@ bidi_resolve_bracket_pairs (struct bidi_it *bidi_it)
2421 } 2432 }
2422 for (sp = bpa_sp; sp >= 0; sp--) 2433 for (sp = bpa_sp; sp >= 0; sp--)
2423 bpa_stack[sp].flags |= flag; 2434 bpa_stack[sp].flags |= flag;
2435 /* FIXME: Pay attention to types that can be
2436 next_for_neutral, and when found, update cached
2437 states for which it is relevant. */
2424 } 2438 }
2425 /* Record the info about the previous character, so that it 2439 /* Record the info about the previous character, so that it
2426 will be cached with this state. */ 2440 will be cached with this state. */
@@ -2513,7 +2527,7 @@ bidi_resolve_neutral (struct bidi_it *bidi_it)
2513 && bidi_paired_bracket_type (ch) != BIDI_BRACKET_NONE) 2527 && bidi_paired_bracket_type (ch) != BIDI_BRACKET_NONE)
2514 { 2528 {
2515 if (bidi_cache_idx > bidi_cache_start 2529 if (bidi_cache_idx > bidi_cache_start
2516 && bidi_cache_find (bidi_it->charpos, -1, bidi_it) != UNKNOWN_BT 2530 && bidi_cache_find (bidi_it->charpos, 1, bidi_it) != UNKNOWN_BT
2517 && bidi_it->bracket_resolved) 2531 && bidi_it->bracket_resolved)
2518 type = bidi_it->type; 2532 type = bidi_it->type;
2519 else 2533 else
@@ -2797,7 +2811,7 @@ bidi_level_of_next_char (struct bidi_it *bidi_it)
2797 cached at the beginning of the iteration. */ 2811 cached at the beginning of the iteration. */
2798 next_char_pos = bidi_it->charpos - 1; 2812 next_char_pos = bidi_it->charpos - 1;
2799 if (next_char_pos >= bob - 1) 2813 if (next_char_pos >= bob - 1)
2800 type = bidi_cache_find (next_char_pos, -1, bidi_it); 2814 type = bidi_cache_find (next_char_pos, 0, bidi_it);
2801 else 2815 else
2802 type = UNKNOWN_BT; 2816 type = UNKNOWN_BT;
2803 2817