]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid assertion violations in bidi.c
authorEli Zaretskii <eliz@gnu.org>
Tue, 27 Feb 2024 11:12:15 +0000 (13:12 +0200)
committerEshel Yaron <me@eshelyaron.com>
Sun, 3 Mar 2024 17:03:22 +0000 (18:03 +0100)
* src/bidi.c (bidi_resolve_brackets): Move assertion about
'resolved_level' to where it belongs.  This avoids unnecessary
aborts when the character is not a bracket type and doesn't need
BPA resolution.  (Bug#69421)

(cherry picked from commit 383ccf6d51fd7af65dbcc1ce159a03369a48d27f)

src/bidi.c

index a2b5054cb6002cc950f1e998eeb8630b7b6e078b..36d1a0496b84d35d845403d95e49ac73fd010c06 100644 (file)
@@ -2908,7 +2908,6 @@ bidi_resolve_brackets (struct bidi_it *bidi_it)
     }
   else if (bidi_it->bracket_pairing_pos != eob)
     {
-      eassert (bidi_it->resolved_level == -1);
       /* If the cached state shows an increase of embedding level due
         to an isolate initiator, we need to update the 1st cached
         state of the next run of the current isolating sequence with
@@ -2917,6 +2916,7 @@ bidi_resolve_brackets (struct bidi_it *bidi_it)
       if (bidi_it->level_stack[bidi_it->stack_idx].level > prev_level
          && ISOLATE_STATUS (bidi_it, bidi_it->stack_idx))
        {
+         eassert (bidi_it->resolved_level == -1);
          bidi_record_type_for_neutral (&prev_for_neutral, prev_level, 0);
          bidi_record_type_for_neutral (&next_for_neutral, prev_level, 1);
        }
@@ -2931,6 +2931,7 @@ bidi_resolve_brackets (struct bidi_it *bidi_it)
            }
          else if (bidi_it->bracket_pairing_pos == -1)
            {
+             eassert (bidi_it->resolved_level == -1);
              /* Higher levels were not BPA-resolved yet, even if
                 cached by bidi_find_bracket_pairs.  Force application
                 of BPA to the new level now.  */