aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2025-02-04 11:43:58 -0800
committerPaul Eggert2025-02-04 13:04:35 -0800
commit782ec71053d8535511522f27f28c11682ca0f40b (patch)
treea8f58e82794ab9cb7765cc6f6c697473ec5a9cea /src
parent6842415577405adafcba16f8cbff02f35b5583f9 (diff)
downloademacs-782ec71053d8535511522f27f28c11682ca0f40b.tar.gz
emacs-782ec71053d8535511522f27f28c11682ca0f40b.zip
Improve bidi_get_time runtime checking
* 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.
Diffstat (limited to 'src')
-rw-r--r--src/bidi.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/bidi.c b/src/bidi.c
index d8754e2db73..fd0bebb85e0 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -282,12 +282,6 @@ bidi_get_type (int ch, bidi_dir_t override)
282 emacs_abort (); 282 emacs_abort ();
283 283
284 default_type = (bidi_type_t) XFIXNUM (CHAR_TABLE_REF (bidi_type_table, ch)); 284 default_type = (bidi_type_t) XFIXNUM (CHAR_TABLE_REF (bidi_type_table, ch));
285 /* Every valid character code, even those that are unassigned by the
286 UCD, have some bidi-class property, according to
287 DerivedBidiClass.txt file. Therefore, if we ever get UNKNOWN_BT
288 (= zero) code from CHAR_TABLE_REF, that's a bug. */
289 if (default_type == UNKNOWN_BT)
290 emacs_abort ();
291 285
292 switch (default_type) 286 switch (default_type)
293 { 287 {
@@ -303,13 +297,26 @@ bidi_get_type (int ch, bidi_dir_t override)
303 case FSI: 297 case FSI:
304 case PDI: 298 case PDI:
305 return default_type; 299 return default_type;
306 default: 300
301 case STRONG_L: case STRONG_R:
302 case WEAK_EN: case WEAK_AN:
303 case STRONG_AL:
304 case WEAK_ES: case WEAK_ET: case WEAK_CS: case WEAK_NSM:
305 case NEUTRAL_S: case NEUTRAL_WS: case NEUTRAL_ON:
307 if (override == L2R) 306 if (override == L2R)
308 return STRONG_L; 307 return STRONG_L;
309 else if (override == R2L) 308 else if (override == R2L)
310 return STRONG_R; 309 return STRONG_R;
311 else 310 else
312 return default_type; 311 return default_type;
312
313 case UNKNOWN_BT:
314 default:
315 /* Every valid character code, even those unassigned by the UCD,
316 have some bidi-class property, according to DerivedBidiClass.txt.
317 Therefore, if we ever get UNKNOWN_BT (= zero) or some unknown
318 code from CHAR_TABLE_REF, that's a bug. */
319 emacs_abort ();
313 } 320 }
314} 321}
315 322