diff options
Diffstat (limited to 'src/bidi.c')
| -rw-r--r-- | src/bidi.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/bidi.c b/src/bidi.c index 84341cb1456..ccdcb2f4451 100644 --- a/src/bidi.c +++ b/src/bidi.c | |||
| @@ -1743,6 +1743,9 @@ bidi_resolve_explicit (struct bidi_it *bidi_it) | |||
| 1743 | bool string_p = bidi_it->string.s || STRINGP (bidi_it->string.lstring); | 1743 | bool string_p = bidi_it->string.s || STRINGP (bidi_it->string.lstring); |
| 1744 | ptrdiff_t ch_len, nchars, disp_pos, end; | 1744 | ptrdiff_t ch_len, nchars, disp_pos, end; |
| 1745 | int disp_prop; | 1745 | int disp_prop; |
| 1746 | ptrdiff_t eob | ||
| 1747 | = ((bidi_it->string.s || STRINGP (bidi_it->string.lstring)) | ||
| 1748 | ? bidi_it->string.schars : ZV); | ||
| 1746 | 1749 | ||
| 1747 | /* Record the info about the previous character. */ | 1750 | /* Record the info about the previous character. */ |
| 1748 | if (bidi_it->type_after_wn != WEAK_BN /* W1/Retaining */ | 1751 | if (bidi_it->type_after_wn != WEAK_BN /* W1/Retaining */ |
| @@ -1774,7 +1777,7 @@ bidi_resolve_explicit (struct bidi_it *bidi_it) | |||
| 1774 | /* If needed, reset the "magical" value of pairing bracket | 1777 | /* If needed, reset the "magical" value of pairing bracket |
| 1775 | position, so that bidi_resolve_brackets will resume | 1778 | position, so that bidi_resolve_brackets will resume |
| 1776 | resolution of brackets according to BPA. */ | 1779 | resolution of brackets according to BPA. */ |
| 1777 | if (bidi_it->bracket_pairing_pos == ZV) | 1780 | if (bidi_it->bracket_pairing_pos == eob) |
| 1778 | bidi_it->bracket_pairing_pos = -1; | 1781 | bidi_it->bracket_pairing_pos = -1; |
| 1779 | } | 1782 | } |
| 1780 | if (bidi_it->next_en_pos >= 0 | 1783 | if (bidi_it->next_en_pos >= 0 |
| @@ -1787,7 +1790,7 @@ bidi_resolve_explicit (struct bidi_it *bidi_it) | |||
| 1787 | /* Reset the bracket resolution info, unless we previously decided | 1790 | /* Reset the bracket resolution info, unless we previously decided |
| 1788 | (in bidi_find_bracket_pairs) that brackets in this level run | 1791 | (in bidi_find_bracket_pairs) that brackets in this level run |
| 1789 | should be resolved as neutrals. */ | 1792 | should be resolved as neutrals. */ |
| 1790 | if (bidi_it->bracket_pairing_pos != ZV) | 1793 | if (bidi_it->bracket_pairing_pos != eob) |
| 1791 | { | 1794 | { |
| 1792 | bidi_it->bracket_pairing_pos = -1; | 1795 | bidi_it->bracket_pairing_pos = -1; |
| 1793 | bidi_it->bracket_enclosed_type = UNKNOWN_BT; | 1796 | bidi_it->bracket_enclosed_type = UNKNOWN_BT; |
| @@ -2608,6 +2611,10 @@ bidi_find_bracket_pairs (struct bidi_it *bidi_it) | |||
| 2608 | && ((base_level == 0 && !r2l_seen) | 2611 | && ((base_level == 0 && !r2l_seen) |
| 2609 | || (base_level == 1 && !l2r_seen))) | 2612 | || (base_level == 1 && !l2r_seen))) |
| 2610 | { | 2613 | { |
| 2614 | ptrdiff_t eob | ||
| 2615 | = ((bidi_it->string.s || STRINGP (bidi_it->string.lstring)) | ||
| 2616 | ? bidi_it->string.schars : ZV); | ||
| 2617 | |||
| 2611 | if (retval) | 2618 | if (retval) |
| 2612 | pairing_pos = bidi_it->bracket_pairing_pos; | 2619 | pairing_pos = bidi_it->bracket_pairing_pos; |
| 2613 | 2620 | ||
| @@ -2616,7 +2623,7 @@ bidi_find_bracket_pairs (struct bidi_it *bidi_it) | |||
| 2616 | will be noticed by bidi_resolve_explicit, and will be | 2623 | will be noticed by bidi_resolve_explicit, and will be |
| 2617 | copied to the following iterator states, instead of being | 2624 | copied to the following iterator states, instead of being |
| 2618 | reset to -1. */ | 2625 | reset to -1. */ |
| 2619 | bidi_it->bracket_pairing_pos = ZV; | 2626 | bidi_it->bracket_pairing_pos = eob; |
| 2620 | /* This type value will be used for resolving the outermost | 2627 | /* This type value will be used for resolving the outermost |
| 2621 | closing bracket in bidi_resolve_brackets. */ | 2628 | closing bracket in bidi_resolve_brackets. */ |
| 2622 | bidi_it->bracket_enclosed_type = embedding_type; | 2629 | bidi_it->bracket_enclosed_type = embedding_type; |
| @@ -2669,6 +2676,9 @@ bidi_resolve_brackets (struct bidi_it *bidi_it) | |||
| 2669 | bidi_type_t type = UNKNOWN_BT; | 2676 | bidi_type_t type = UNKNOWN_BT; |
| 2670 | int ch; | 2677 | int ch; |
| 2671 | struct bidi_saved_info prev_for_neutral, next_for_neutral; | 2678 | struct bidi_saved_info prev_for_neutral, next_for_neutral; |
| 2679 | ptrdiff_t eob | ||
| 2680 | = ((bidi_it->string.s || STRINGP (bidi_it->string.lstring)) | ||
| 2681 | ? bidi_it->string.schars : ZV); | ||
| 2672 | 2682 | ||
| 2673 | /* Record the prev_for_neutral type either from the previous | 2683 | /* Record the prev_for_neutral type either from the previous |
| 2674 | character, if it was a strong or AN/EN, or from the | 2684 | character, if it was a strong or AN/EN, or from the |
| @@ -2693,11 +2703,11 @@ bidi_resolve_brackets (struct bidi_it *bidi_it) | |||
| 2693 | type = bidi_resolve_weak (bidi_it); | 2703 | type = bidi_resolve_weak (bidi_it); |
| 2694 | if (type == NEUTRAL_ON) | 2704 | if (type == NEUTRAL_ON) |
| 2695 | { | 2705 | { |
| 2696 | /* bracket_pairing_pos == ZV means this bracket does not | 2706 | /* bracket_pairing_pos == eob means this bracket does not |
| 2697 | need to be resolved as a bracket, but as a neutral, see | 2707 | need to be resolved as a bracket, but as a neutral, see |
| 2698 | the optimization trick we play near the end of | 2708 | the optimization trick we play near the end of |
| 2699 | bidi_find_bracket_pairs. */ | 2709 | bidi_find_bracket_pairs. */ |
| 2700 | if (bidi_it->bracket_pairing_pos == ZV) | 2710 | if (bidi_it->bracket_pairing_pos == eob) |
| 2701 | { | 2711 | { |
| 2702 | /* If this is the outermost closing bracket of a run of | 2712 | /* If this is the outermost closing bracket of a run of |
| 2703 | characters in which we decided to resolve brackets as | 2713 | characters in which we decided to resolve brackets as |
| @@ -2711,7 +2721,7 @@ bidi_resolve_brackets (struct bidi_it *bidi_it) | |||
| 2711 | resolve_bracket = true; | 2721 | resolve_bracket = true; |
| 2712 | } | 2722 | } |
| 2713 | } | 2723 | } |
| 2714 | else if (bidi_it->bracket_pairing_pos != ZV) | 2724 | else if (bidi_it->bracket_pairing_pos != eob) |
| 2715 | { | 2725 | { |
| 2716 | eassert (bidi_it->resolved_level == -1); | 2726 | eassert (bidi_it->resolved_level == -1); |
| 2717 | /* If the cached state shows an increase of embedding level due | 2727 | /* If the cached state shows an increase of embedding level due |