diff options
| author | Eli Zaretskii | 2010-01-02 10:57:35 -0500 |
|---|---|---|
| committer | Eli Zaretskii | 2010-01-02 10:57:35 -0500 |
| commit | 241ab1c185285abf1faff9596cbbbc880519dccb (patch) | |
| tree | e2cfad0d846aab9c505006bcd8ee058f4f53b1b7 /src | |
| parent | c4810d2f26b64517c8fefe9e30b296ca41e3f8bc (diff) | |
| download | emacs-241ab1c185285abf1faff9596cbbbc880519dccb.tar.gz emacs-241ab1c185285abf1faff9596cbbbc880519dccb.zip | |
Continue working on handling of properties in bidi iteration.
Region display and extension seems to work.
Solved a crash in bidirectional display of etc/HELLO.
(HELLO display still not 100% OK, e.g. near Kannada.)
.gdbinit (pitx): Display some bidi information about the
iterator.
dispextern.h (BIDI_AT_BASE_LEVEL): Enclose definition in
parentheses.
xdisp.c (handle_stop_backwards): Save and restore it->current
and it->position, instead of expecting the caller to do that.
(next_element_from_buffer): When moving across stop_charpos,
record it in prev_stop. When IT_CHARPOS backs up, call
handle_stop_backwards only if above the base embedding level.
This solves the crash while displaying etc/HELLO in bidi mode.
Diffstat (limited to 'src')
| -rw-r--r-- | src/.gdbinit | 3 | ||||
| -rw-r--r-- | src/ChangeLog.bidi | 15 | ||||
| -rw-r--r-- | src/dispextern.h | 7 | ||||
| -rw-r--r-- | src/xdisp.c | 49 |
4 files changed, 48 insertions, 26 deletions
diff --git a/src/.gdbinit b/src/.gdbinit index a500f2532f5..8949e66134c 100644 --- a/src/.gdbinit +++ b/src/.gdbinit | |||
| @@ -271,6 +271,9 @@ define pitx | |||
| 271 | end | 271 | end |
| 272 | end | 272 | end |
| 273 | printf "\n" | 273 | printf "\n" |
| 274 | if ($it->bidi_p) | ||
| 275 | printf "BIDI: base_stop=%d prev_stop=%d level=%d\n", $it->base_level_stop, $it->prev_stop, $it->bidi_it.resolved_level | ||
| 276 | end | ||
| 274 | if ($it->region_beg_charpos >= 0) | 277 | if ($it->region_beg_charpos >= 0) |
| 275 | printf "reg=%d-%d ", $it->region_beg_charpos, $it->region_end_charpos | 278 | printf "reg=%d-%d ", $it->region_beg_charpos, $it->region_end_charpos |
| 276 | end | 279 | end |
diff --git a/src/ChangeLog.bidi b/src/ChangeLog.bidi index 7e11c6ec024..11ed09b6d54 100644 --- a/src/ChangeLog.bidi +++ b/src/ChangeLog.bidi | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | 2010-01-02 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * .gdbinit (pitx): Display some bidi information about the | ||
| 4 | iterator. | ||
| 5 | |||
| 6 | * dispextern.h (BIDI_AT_BASE_LEVEL): Enclose definition in | ||
| 7 | parentheses. | ||
| 8 | |||
| 9 | * xdisp.c (handle_stop_backwards): Save and restore it->current | ||
| 10 | and it->position, instead of expecting the caller to do that. | ||
| 11 | (next_element_from_buffer): When moving across stop_charpos, | ||
| 12 | record it in prev_stop. When IT_CHARPOS backs up, call | ||
| 13 | handle_stop_backwards only if above the base embedding level. | ||
| 14 | This solves the crash while displaying etc/HELLO in bidi mode. | ||
| 15 | |||
| 1 | 2009-12-26 Eli Zaretskii <eliz@gnu.org> | 16 | 2009-12-26 Eli Zaretskii <eliz@gnu.org> |
| 2 | 17 | ||
| 3 | * xdisp.c (handle_stop_backwards): Call compute_stop_pos in the | 18 | * xdisp.c (handle_stop_backwards): Call compute_stop_pos in the |
diff --git a/src/dispextern.h b/src/dispextern.h index 510ffe50dab..0521a062351 100644 --- a/src/dispextern.h +++ b/src/dispextern.h | |||
| @@ -1812,7 +1812,7 @@ struct bidi_it { | |||
| 1812 | /* Value is non-zero when the bidi iterator is at base paragraph | 1812 | /* Value is non-zero when the bidi iterator is at base paragraph |
| 1813 | embedding level. */ | 1813 | embedding level. */ |
| 1814 | #define BIDI_AT_BASE_LEVEL(BIDI_IT) \ | 1814 | #define BIDI_AT_BASE_LEVEL(BIDI_IT) \ |
| 1815 | (BIDI_IT).resolved_level == (BIDI_IT).level_stack[0].level | 1815 | ((BIDI_IT).resolved_level == (BIDI_IT).level_stack[0].level) |
| 1816 | 1816 | ||
| 1817 | 1817 | ||
| 1818 | /*********************************************************************** | 1818 | /*********************************************************************** |
| @@ -2013,10 +2013,11 @@ struct it | |||
| 2013 | EMACS_INT stop_charpos; | 2013 | EMACS_INT stop_charpos; |
| 2014 | 2014 | ||
| 2015 | /* Previous stop position, i.e. the last one before the current | 2015 | /* Previous stop position, i.e. the last one before the current |
| 2016 | buffer position. */ | 2016 | iterator position in `current'. */ |
| 2017 | EMACS_INT prev_stop; | 2017 | EMACS_INT prev_stop; |
| 2018 | 2018 | ||
| 2019 | /* Last stop_pos at the current paragraph's embedding level. */ | 2019 | /* Last stop position iterated across whose embedding level is equal |
| 2020 | to the current paragraph's embedding level. */ | ||
| 2020 | EMACS_INT base_level_stop; | 2021 | EMACS_INT base_level_stop; |
| 2021 | 2022 | ||
| 2022 | /* Maximum string or buffer position + 1. ZV when iterating over | 2023 | /* Maximum string or buffer position + 1. ZV when iterating over |
diff --git a/src/xdisp.c b/src/xdisp.c index b18b0e04be2..17d2be0f7f2 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -6550,19 +6550,18 @@ next_element_from_stretch (it) | |||
| 6550 | 6550 | ||
| 6551 | /* Scan forward from CHARPOS in the current buffer, until we find a | 6551 | /* Scan forward from CHARPOS in the current buffer, until we find a |
| 6552 | stop position > current IT's position. Then handle the stop | 6552 | stop position > current IT's position. Then handle the stop |
| 6553 | position before that. | 6553 | position before that. This is called when we bump into a stop |
| 6554 | 6554 | position while reordering bidirectional text. */ | |
| 6555 | This is called when we are reordering bidirectional text. The | ||
| 6556 | caller should save and restore IT and in particular the bidi_p | ||
| 6557 | flag, because this function modifies them. */ | ||
| 6558 | 6555 | ||
| 6559 | static void | 6556 | static void |
| 6560 | handle_stop_backwards (it, charpos) | 6557 | handle_stop_backwards (it, charpos) |
| 6561 | struct it *it; | 6558 | struct it *it; |
| 6562 | EMACS_INT charpos; | 6559 | EMACS_INT charpos; |
| 6563 | { | 6560 | { |
| 6564 | struct text_pos pos1; | ||
| 6565 | EMACS_INT where_we_are = IT_CHARPOS (*it); | 6561 | EMACS_INT where_we_are = IT_CHARPOS (*it); |
| 6562 | struct display_pos save_current = it->current; | ||
| 6563 | struct text_pos save_position = it->position; | ||
| 6564 | struct text_pos pos1; | ||
| 6566 | EMACS_INT next_stop; | 6565 | EMACS_INT next_stop; |
| 6567 | 6566 | ||
| 6568 | /* Scan in strict logical order. */ | 6567 | /* Scan in strict logical order. */ |
| @@ -6584,6 +6583,9 @@ handle_stop_backwards (it, charpos) | |||
| 6584 | it->stop_charpos = it->prev_stop; | 6583 | it->stop_charpos = it->prev_stop; |
| 6585 | handle_stop (it); | 6584 | handle_stop (it); |
| 6586 | it->stop_charpos = next_stop; | 6585 | it->stop_charpos = next_stop; |
| 6586 | it->bidi_p = 1; | ||
| 6587 | it->current = save_current; | ||
| 6588 | it->position = save_position; | ||
| 6587 | } | 6589 | } |
| 6588 | 6590 | ||
| 6589 | /* Load IT with the next display element from current_buffer. Value | 6591 | /* Load IT with the next display element from current_buffer. Value |
| @@ -6685,38 +6687,39 @@ next_element_from_buffer (it) | |||
| 6685 | them all now, in buffer's logical order, until we find | 6687 | them all now, in buffer's logical order, until we find |
| 6686 | and handle the last stop_charpos that precedes our | 6688 | and handle the last stop_charpos that precedes our |
| 6687 | current position. */ | 6689 | current position. */ |
| 6688 | struct it save_it = *it; | ||
| 6689 | |||
| 6690 | handle_stop_backwards (it, it->stop_charpos); | 6690 | handle_stop_backwards (it, it->stop_charpos); |
| 6691 | it->bidi_p = 1; | ||
| 6692 | it->current = save_it.current; | ||
| 6693 | it->position = save_it.position; | ||
| 6694 | return GET_NEXT_DISPLAY_ELEMENT (it); | 6691 | return GET_NEXT_DISPLAY_ELEMENT (it); |
| 6695 | } | 6692 | } |
| 6696 | else | 6693 | else |
| 6697 | { | 6694 | { |
| 6698 | /* If we are at base paragraph embedding level, take note of | 6695 | if (it->bidi_p) |
| 6699 | the last stop position seen at this level. */ | 6696 | { |
| 6700 | if (BIDI_AT_BASE_LEVEL (it->bidi_it)) | 6697 | /* Take note of the stop position we just moved across, |
| 6701 | it->base_level_stop = it->stop_charpos; | 6698 | for when we will move back across it. */ |
| 6699 | it->prev_stop = it->stop_charpos; | ||
| 6700 | /* If we are at base paragraph embedding level, take | ||
| 6701 | note of the last stop position seen at this | ||
| 6702 | level. */ | ||
| 6703 | if (BIDI_AT_BASE_LEVEL (it->bidi_it)) | ||
| 6704 | it->base_level_stop = it->stop_charpos; | ||
| 6705 | } | ||
| 6702 | handle_stop (it); | 6706 | handle_stop (it); |
| 6703 | return GET_NEXT_DISPLAY_ELEMENT (it); | 6707 | return GET_NEXT_DISPLAY_ELEMENT (it); |
| 6704 | } | 6708 | } |
| 6705 | } | 6709 | } |
| 6706 | else if (it->bidi_p && IT_CHARPOS (*it) < it->prev_stop) | 6710 | else if (it->bidi_p |
| 6711 | /* We can sometimes back up for reasons that have nothing | ||
| 6712 | to do with bidi reordering. E.g., compositions. The | ||
| 6713 | code below is only needed when we are above the base | ||
| 6714 | embedding level, so test for that explicitly. */ | ||
| 6715 | && !BIDI_AT_BASE_LEVEL (it->bidi_it) | ||
| 6716 | && IT_CHARPOS (*it) < it->prev_stop) | ||
| 6707 | { | 6717 | { |
| 6708 | struct it save_it = *it; | ||
| 6709 | |||
| 6710 | if (it->base_level_stop <= 0) | 6718 | if (it->base_level_stop <= 0) |
| 6711 | it->base_level_stop = 1; | 6719 | it->base_level_stop = 1; |
| 6712 | if (IT_CHARPOS (*it) < it->base_level_stop) | 6720 | if (IT_CHARPOS (*it) < it->base_level_stop) |
| 6713 | abort (); | 6721 | abort (); |
| 6714 | if (BIDI_AT_BASE_LEVEL (it->bidi_it)) | ||
| 6715 | abort (); | ||
| 6716 | handle_stop_backwards (it, it->base_level_stop); | 6722 | handle_stop_backwards (it, it->base_level_stop); |
| 6717 | it->bidi_p = 1; | ||
| 6718 | it->current = save_it.current; | ||
| 6719 | it->position = save_it.position; | ||
| 6720 | return GET_NEXT_DISPLAY_ELEMENT (it); | 6723 | return GET_NEXT_DISPLAY_ELEMENT (it); |
| 6721 | } | 6724 | } |
| 6722 | else | 6725 | else |