From: Eli Zaretskii Date: Sun, 12 Oct 2014 17:13:14 +0000 (+0300) Subject: Fix bidi_cache_find when NEUTRALS_OK is false; RLI no longer aborts. X-Git-Tag: emacs-25.0.90~2635^2~679^2~50^2~15 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=84e5bb98bf406b5d05781b726a11251fe6bebd97;p=emacs.git Fix bidi_cache_find when NEUTRALS_OK is false; RLI no longer aborts. --- diff --git a/src/bidi.c b/src/bidi.c index 2e980e92b27..6d5f281d571 100644 --- a/src/bidi.c +++ b/src/bidi.c @@ -358,6 +358,12 @@ bidi_get_category (bidi_type_t type) } } +static bool +bidi_isolate_fmt_char (bidi_type_t ch_type) +{ + return (ch_type == LRI || ch_type == RLI || ch_type == PDI || ch_type == FSI); +} + /* Return the mirrored character of C, if it has one. If C has no mirrored counterpart, return C. Note: The conditions in UAX#9 clause L4 regarding the surrounding @@ -804,8 +810,13 @@ bidi_cache_find (ptrdiff_t charpos, bool neutrals_ok, struct bidi_it *bidi_it) if (i >= bidi_cache_start && (neutrals_ok + /* Callers that don't want to resolve neutrals (and set + neutrals_ok = false) need to be sure that there's enough + info in the cached state to resolve the neutrals and + isolates, and if not, they don't want the cached state. */ || !(bidi_cache[i].resolved_level == -1 - && bidi_get_category (bidi_cache[i].type) == NEUTRAL + && (bidi_get_category (bidi_cache[i].type) == NEUTRAL + || bidi_isolate_fmt_char (bidi_cache[i].type)) && bidi_cache[i].next_for_neutral.type == UNKNOWN_BT))) { bidi_dir_t current_scan_dir = bidi_it->scan_dir; @@ -2037,12 +2048,6 @@ bidi_resolve_explicit (struct bidi_it *bidi_it) return bidi_it->resolved_level; } -static bool -bidi_isolate_fmt_char (bidi_type_t ch_type) -{ - return (ch_type == LRI || ch_type == RLI || ch_type == PDI || ch_type == FSI); -} - /* Advance in the buffer/string, resolve weak types and return the type of the next character after weak type resolution. */ static bidi_type_t @@ -2837,7 +2842,7 @@ bidi_level_of_next_char (struct bidi_it *bidi_it) eassert (bidi_it->resolved_level >= 0); return bidi_it->resolved_level; } - else if (next_char_pos >= bob - 1) + else { level = bidi_it->level_stack[bidi_it->stack_idx].level; if (bidi_get_category (type) == NEUTRAL