diff options
| author | Eli Zaretskii | 2014-10-12 20:13:14 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2014-10-12 20:13:14 +0300 |
| commit | 84e5bb98bf406b5d05781b726a11251fe6bebd97 (patch) | |
| tree | 2d2a8931c2acab183b5f91407b5b5746a8b321e5 /src | |
| parent | 942ba67827412eee5ddc4d1a8827ff76c2bbe730 (diff) | |
| download | emacs-84e5bb98bf406b5d05781b726a11251fe6bebd97.tar.gz emacs-84e5bb98bf406b5d05781b726a11251fe6bebd97.zip | |
Fix bidi_cache_find when NEUTRALS_OK is false; RLI no longer aborts.
Diffstat (limited to 'src')
| -rw-r--r-- | src/bidi.c | 21 |
1 files changed, 13 insertions, 8 deletions
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) | |||
| 358 | } | 358 | } |
| 359 | } | 359 | } |
| 360 | 360 | ||
| 361 | static bool | ||
| 362 | bidi_isolate_fmt_char (bidi_type_t ch_type) | ||
| 363 | { | ||
| 364 | return (ch_type == LRI || ch_type == RLI || ch_type == PDI || ch_type == FSI); | ||
| 365 | } | ||
| 366 | |||
| 361 | /* Return the mirrored character of C, if it has one. If C has no | 367 | /* Return the mirrored character of C, if it has one. If C has no |
| 362 | mirrored counterpart, return C. | 368 | mirrored counterpart, return C. |
| 363 | Note: The conditions in UAX#9 clause L4 regarding the surrounding | 369 | 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) | |||
| 804 | 810 | ||
| 805 | if (i >= bidi_cache_start | 811 | if (i >= bidi_cache_start |
| 806 | && (neutrals_ok | 812 | && (neutrals_ok |
| 813 | /* Callers that don't want to resolve neutrals (and set | ||
| 814 | neutrals_ok = false) need to be sure that there's enough | ||
| 815 | info in the cached state to resolve the neutrals and | ||
| 816 | isolates, and if not, they don't want the cached state. */ | ||
| 807 | || !(bidi_cache[i].resolved_level == -1 | 817 | || !(bidi_cache[i].resolved_level == -1 |
| 808 | && bidi_get_category (bidi_cache[i].type) == NEUTRAL | 818 | && (bidi_get_category (bidi_cache[i].type) == NEUTRAL |
| 819 | || bidi_isolate_fmt_char (bidi_cache[i].type)) | ||
| 809 | && bidi_cache[i].next_for_neutral.type == UNKNOWN_BT))) | 820 | && bidi_cache[i].next_for_neutral.type == UNKNOWN_BT))) |
| 810 | { | 821 | { |
| 811 | bidi_dir_t current_scan_dir = bidi_it->scan_dir; | 822 | bidi_dir_t current_scan_dir = bidi_it->scan_dir; |
| @@ -2037,12 +2048,6 @@ bidi_resolve_explicit (struct bidi_it *bidi_it) | |||
| 2037 | return bidi_it->resolved_level; | 2048 | return bidi_it->resolved_level; |
| 2038 | } | 2049 | } |
| 2039 | 2050 | ||
| 2040 | static bool | ||
| 2041 | bidi_isolate_fmt_char (bidi_type_t ch_type) | ||
| 2042 | { | ||
| 2043 | return (ch_type == LRI || ch_type == RLI || ch_type == PDI || ch_type == FSI); | ||
| 2044 | } | ||
| 2045 | |||
| 2046 | /* Advance in the buffer/string, resolve weak types and return the | 2051 | /* Advance in the buffer/string, resolve weak types and return the |
| 2047 | type of the next character after weak type resolution. */ | 2052 | type of the next character after weak type resolution. */ |
| 2048 | static bidi_type_t | 2053 | static bidi_type_t |
| @@ -2837,7 +2842,7 @@ bidi_level_of_next_char (struct bidi_it *bidi_it) | |||
| 2837 | eassert (bidi_it->resolved_level >= 0); | 2842 | eassert (bidi_it->resolved_level >= 0); |
| 2838 | return bidi_it->resolved_level; | 2843 | return bidi_it->resolved_level; |
| 2839 | } | 2844 | } |
| 2840 | else if (next_char_pos >= bob - 1) | 2845 | else |
| 2841 | { | 2846 | { |
| 2842 | level = bidi_it->level_stack[bidi_it->stack_idx].level; | 2847 | level = bidi_it->level_stack[bidi_it->stack_idx].level; |
| 2843 | if (bidi_get_category (type) == NEUTRAL | 2848 | if (bidi_get_category (type) == NEUTRAL |