]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve bidi_get_time runtime checking
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 4 Feb 2025 19:43:58 +0000 (11:43 -0800)
committerEshel Yaron <me@eshelyaron.com>
Sun, 9 Feb 2025 08:35:00 +0000 (09:35 +0100)
* src/bidi.c (bidi_get_type): Improve runtime checking, by also
aborting if the bidi_type_table entry is not a bidi_type_t value.

(cherry picked from commit 782ec71053d8535511522f27f28c11682ca0f40b)

src/bidi.c

index d8754e2db73748f4c27a00e2eb6ecdc23c3fece3..fd0bebb85e0ad1a8279ddb5cd55805d81d6ae87a 100644 (file)
@@ -282,12 +282,6 @@ bidi_get_type (int ch, bidi_dir_t override)
     emacs_abort ();
 
   default_type = (bidi_type_t) XFIXNUM (CHAR_TABLE_REF (bidi_type_table, ch));
-  /* Every valid character code, even those that are unassigned by the
-     UCD, have some bidi-class property, according to
-     DerivedBidiClass.txt file.  Therefore, if we ever get UNKNOWN_BT
-     (= zero) code from CHAR_TABLE_REF, that's a bug.  */
-  if (default_type == UNKNOWN_BT)
-    emacs_abort ();
 
   switch (default_type)
     {
@@ -303,13 +297,26 @@ bidi_get_type (int ch, bidi_dir_t override)
       case FSI:
       case PDI:
        return default_type;
-      default:
+
+      case STRONG_L: case STRONG_R:
+      case WEAK_EN: case WEAK_AN:
+      case STRONG_AL:
+      case WEAK_ES: case WEAK_ET: case WEAK_CS: case WEAK_NSM:
+      case NEUTRAL_S: case NEUTRAL_WS: case NEUTRAL_ON:
        if (override == L2R)
          return STRONG_L;
        else if (override == R2L)
          return STRONG_R;
        else
          return default_type;
+
+      case UNKNOWN_BT:
+      default:
+       /* Every valid character code, even those unassigned by the UCD,
+          have some bidi-class property, according to DerivedBidiClass.txt.
+          Therefore, if we ever get UNKNOWN_BT (= zero) or some unknown
+          code from CHAR_TABLE_REF, that's a bug.  */
+       emacs_abort ();
     }
 }