aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2014-09-19 11:32:54 +0300
committerEli Zaretskii2014-09-19 11:32:54 +0300
commit0c068f1d4fb62737984c4134760cd67c6968fbbb (patch)
treeac4f931b860bfaf1a6161d938518bfb41fbac535 /src
parent924d744508c5b6268e73258ccc7282cc1297fae7 (diff)
downloademacs-0c068f1d4fb62737984c4134760cd67c6968fbbb.tar.gz
emacs-0c068f1d4fb62737984c4134760cd67c6968fbbb.zip
Fix assertion violations due to a bug in bidi_set_sos_type; add assertions.
Diffstat (limited to 'src')
-rw-r--r--src/bidi.c67
1 files changed, 36 insertions, 31 deletions
diff --git a/src/bidi.c b/src/bidi.c
index 41e4bbb2ed6..3c204a82b78 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -403,9 +403,8 @@ bidi_set_sos_type (struct bidi_it *bidi_it, int level_before, int level_after)
403{ 403{
404 int higher_level = (level_before > level_after ? level_before : level_after); 404 int higher_level = (level_before > level_after ? level_before : level_after);
405 405
406 if (level_before < level_after) 406 /* FIXME: should the default sos direction be user selectable? */
407 /* FIXME: should the default sos direction be user selectable? */ 407 bidi_it->sos = ((higher_level & 1) != 0 ? R2L : L2R); /* X10 */
408 bidi_it->sos = ((higher_level & 1) != 0 ? R2L : L2R);
409 408
410 bidi_it->prev.type = UNKNOWN_BT; 409 bidi_it->prev.type = UNKNOWN_BT;
411 bidi_it->last_strong.type = bidi_it->last_strong.type_after_w1 410 bidi_it->last_strong.type = bidi_it->last_strong.type_after_w1
@@ -1925,14 +1924,13 @@ bidi_resolve_explicit_1 (struct bidi_it *bidi_it)
1925 if (bidi_it->invalid_levels) 1924 if (bidi_it->invalid_levels)
1926 bidi_it->invalid_levels--; 1925 bidi_it->invalid_levels--;
1927 else if (!isolate_status && bidi_it->stack_idx > 1) 1926 else if (!isolate_status && bidi_it->stack_idx > 1)
1928 new_level = bidi_pop_embedding_level (bidi_it); 1927 bidi_pop_embedding_level (bidi_it);
1929 } 1928 }
1930 } 1929 }
1931 else if (bidi_it->prev.type_after_w1 == WEAK_EN /* W5/Retaining */ 1930 else if (bidi_it->prev.type_after_w1 == WEAK_EN /* W5/Retaining */
1932 || (bidi_it->next_en_pos > bidi_it->charpos 1931 || (bidi_it->next_en_pos > bidi_it->charpos
1933 && bidi_it->next_en_type == WEAK_EN)) 1932 && bidi_it->next_en_type == WEAK_EN))
1934 type = WEAK_EN; 1933 type = WEAK_EN;
1935 bidi_it->resolved_level = new_level;
1936 break; 1934 break;
1937 default: 1935 default:
1938 /* Nothing. */ 1936 /* Nothing. */
@@ -1942,6 +1940,7 @@ bidi_resolve_explicit_1 (struct bidi_it *bidi_it)
1942 bidi_it->type = type; 1940 bidi_it->type = type;
1943 bidi_check_type (bidi_it->type); 1941 bidi_check_type (bidi_it->type);
1944 1942
1943 eassert (bidi_it->resolved_level >= 0);
1945 return bidi_it->resolved_level; 1944 return bidi_it->resolved_level;
1946} 1945}
1947 1946
@@ -2047,13 +2046,12 @@ bidi_resolve_weak (struct bidi_it *bidi_it)
2047 type = bidi_it->type; 2046 type = bidi_it->type;
2048 override = bidi_it->level_stack[bidi_it->stack_idx].override; 2047 override = bidi_it->level_stack[bidi_it->stack_idx].override;
2049 2048
2050 if (type == UNKNOWN_BT 2049 eassert (!(type == UNKNOWN_BT
2051 || type == LRE 2050 || type == LRE
2052 || type == LRO 2051 || type == LRO
2053 || type == RLE 2052 || type == RLE
2054 || type == RLO 2053 || type == RLO
2055 || type == PDF) 2054 || type == PDF));
2056 emacs_abort ();
2057 2055
2058 eassert (prev_level >= 0); 2056 eassert (prev_level >= 0);
2059 if (new_level > prev_level 2057 if (new_level > prev_level
@@ -2287,16 +2285,15 @@ bidi_resolve_neutral (struct bidi_it *bidi_it)
2287 bidi_type_t type = bidi_resolve_weak (bidi_it); 2285 bidi_type_t type = bidi_resolve_weak (bidi_it);
2288 int current_level = bidi_it->level_stack[bidi_it->stack_idx].level; 2286 int current_level = bidi_it->level_stack[bidi_it->stack_idx].level;
2289 2287
2290 if (!(type == STRONG_R 2288 eassert ((type == STRONG_R
2291 || type == STRONG_L 2289 || type == STRONG_L
2292 || type == WEAK_BN 2290 || type == WEAK_BN
2293 || type == WEAK_EN 2291 || type == WEAK_EN
2294 || type == WEAK_AN 2292 || type == WEAK_AN
2295 || type == NEUTRAL_B 2293 || type == NEUTRAL_B
2296 || type == NEUTRAL_S 2294 || type == NEUTRAL_S
2297 || type == NEUTRAL_WS 2295 || type == NEUTRAL_WS
2298 || type == NEUTRAL_ON)) 2296 || type == NEUTRAL_ON));
2299 emacs_abort ();
2300 2297
2301 eassert (prev_level >= 0); 2298 eassert (prev_level >= 0);
2302 eassert (current_level >= 0); 2299 eassert (current_level >= 0);
@@ -2482,7 +2479,10 @@ bidi_level_of_next_char (struct bidi_it *bidi_it)
2482 2479
2483 /* There's no sense in trying to advance if we hit end of text. */ 2480 /* There's no sense in trying to advance if we hit end of text. */
2484 if (bidi_it->charpos >= eob) 2481 if (bidi_it->charpos >= eob)
2485 return bidi_it->resolved_level; 2482 {
2483 eassert (bidi_it->resolved_level >= 0);
2484 return bidi_it->resolved_level;
2485 }
2486 2486
2487 /* Record the info about the previous character. */ 2487 /* Record the info about the previous character. */
2488 if (bidi_it->type_after_w1 != WEAK_BN /* W1/Retaining */ 2488 if (bidi_it->type_after_w1 != WEAK_BN /* W1/Retaining */
@@ -2563,7 +2563,10 @@ bidi_level_of_next_char (struct bidi_it *bidi_it)
2563 before it was completely resolved, so we cannot return 2563 before it was completely resolved, so we cannot return
2564 it. */ 2564 it. */
2565 if (bidi_it->resolved_level != -1) 2565 if (bidi_it->resolved_level != -1)
2566 return bidi_it->resolved_level; 2566 {
2567 eassert (bidi_it->resolved_level >= 0);
2568 return bidi_it->resolved_level;
2569 }
2567 } 2570 }
2568 if (bidi_it->scan_dir == -1) 2571 if (bidi_it->scan_dir == -1)
2569 /* If we are going backwards, the iterator state is already cached 2572 /* If we are going backwards, the iterator state is already cached
@@ -2574,7 +2577,10 @@ bidi_level_of_next_char (struct bidi_it *bidi_it)
2574 type = bidi_type_of_next_char (bidi_it); 2577 type = bidi_type_of_next_char (bidi_it);
2575 2578
2576 if (type == NEUTRAL_B) 2579 if (type == NEUTRAL_B)
2577 return bidi_it->resolved_level; 2580 {
2581 eassert (bidi_it->resolved_level >= 0);
2582 return bidi_it->resolved_level;
2583 }
2578 2584
2579 level = bidi_it->level_stack[bidi_it->stack_idx].level; 2585 level = bidi_it->level_stack[bidi_it->stack_idx].level;
2580 if ((bidi_get_category (type) == NEUTRAL /* && type != NEUTRAL_B */) 2586 if ((bidi_get_category (type) == NEUTRAL /* && type != NEUTRAL_B */)
@@ -2590,12 +2596,11 @@ bidi_level_of_next_char (struct bidi_it *bidi_it)
2590 level); 2596 level);
2591 } 2597 }
2592 2598
2593 if (!(type == STRONG_R 2599 eassert ((type == STRONG_R
2594 || type == STRONG_L 2600 || type == STRONG_L
2595 || type == WEAK_BN 2601 || type == WEAK_BN
2596 || type == WEAK_EN 2602 || type == WEAK_EN
2597 || type == WEAK_AN)) 2603 || type == WEAK_AN));
2598 emacs_abort ();
2599 bidi_it->type = type; 2604 bidi_it->type = type;
2600 bidi_check_type (bidi_it->type); 2605 bidi_check_type (bidi_it->type);
2601 2606