From 16f54832c0ddd0cc553d4231d95778ed91ed5218 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 4 Oct 2014 15:09:46 +0300 Subject: [PATCH] Fixed a crash in 'C-x =' and in RLE followed by PDF; fixed 'C-x =' display. --- lisp/descr-text.el | 15 +++++++++++---- lisp/simple.el | 20 ++++++++++++-------- src/bidi.c | 15 +++++++++------ 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/lisp/descr-text.el b/lisp/descr-text.el index 02ed55b5bdf..7d5964cb368 100644 --- a/lisp/descr-text.el +++ b/lisp/descr-text.el @@ -434,13 +434,20 @@ relevant to POS." code (encode-char char charset))) (setq code char)) (cond - ;; Append a PDF character to directional embeddings and - ;; overrides, to prevent potential messup of the following - ;; text. - ((memq char '(?\x202a ?\x202b ?\x202d ?\x202e)) + ;; Append a PDF character to left-to-right directional + ;; embeddings and overrides, to prevent potential messup of the + ;; following text. + ((memq char '(?\x202a ?\x202d)) (setq char-description (concat char-description (propertize (string ?\x202c) 'invisible t)))) + ;; Append a PDF character followed by LRM to right-to-left + ;; directional embeddings and overrides, to prevent potential + ;; messup of the following numerical text. + ((memq char '(?\x202b ?\x202e)) + (setq char-description + (concat char-description + (propertize (string ?\x202c ?\x200e) 'invisible t)))) ;; Append a LRM character to any strong character to avoid ;; messing up the numerical codepoint. ((memq (get-char-code-property char 'bidi-class) '(R AL)) diff --git a/lisp/simple.el b/lisp/simple.el index cdff8d7fc3a..69c64b6de7b 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -1216,15 +1216,19 @@ in *Help* buffer. See also the command `describe-char'." (interactive "P") (let* ((char (following-char)) (bidi-fixer - (cond ((memq char '(?\x202a ?\x202b ?\x202d ?\x202e)) - ;; If the character is one of LRE, LRO, RLE, RLO, it - ;; will start a directional embedding, which could - ;; completely disrupt the rest of the line (e.g., RLO - ;; will display the rest of the line right-to-left). - ;; So we put an invisible PDF character after these - ;; characters, to end the embedding, which eliminates - ;; any effects on the rest of the line. + ;; If the character is one of LRE, LRO, RLE, RLO, it will + ;; start a directional embedding, which could completely + ;; disrupt the rest of the line (e.g., RLO will display the + ;; rest of the line right-to-left). So we put an invisible + ;; PDF character after these characters, to end the + ;; embedding, which eliminates any effects on the rest of + ;; the line. For RLE and RLO we also append an invisible + ;; LRM, to avoid reordering the following numerical + ;; characters. + (cond ((memq char '(?\x202a ?\x202d)) (propertize (string ?\x202c) 'invisible t)) + ((memq char '(?\x202b ?\x202e)) + (propertize (string ?\x202c ?\x200e) 'invisible t)) ;; Strong right-to-left characters cause reordering of ;; the following numerical characters which show the ;; codepoint, so append LRM to countermand that. diff --git a/src/bidi.c b/src/bidi.c index aad867887b1..eee2a9c623b 100644 --- a/src/bidi.c +++ b/src/bidi.c @@ -1763,10 +1763,10 @@ bidi_resolve_explicit (struct bidi_it *bidi_it) } else { - /* LRI, RLI, and FSI increment, and PDF decrements, the - embedding level of the _following_ characters, so we must - first look at the type of the previous character to support - that. */ + /* LRI, RLI, and FSI increment, and PDF decrements, the + embedding level of the _following_ characters, so we must + first look at the type of the previous character to support + that. */ switch (prev_type) { case RLI: /* X5a */ @@ -2518,7 +2518,7 @@ bidi_level_of_next_char (struct bidi_it *bidi_it) { int bob = ((bidi_it->string.s || STRINGP (bidi_it->string.lstring)) ? 0 : 1); - bidi_type_t prev_type = bidi_it->prev.type; + bidi_type_t prev_type = bidi_it->type; bidi_type_t type_for_neutral = bidi_it->next_for_neutral.type; ptrdiff_t pos_for_neutral = bidi_it->next_for_neutral.charpos; @@ -2553,7 +2553,10 @@ bidi_level_of_next_char (struct bidi_it *bidi_it) && bidi_explicit_dir_char (bidi_it->ch) && type_for_neutral != UNKNOWN_BT && bidi_it->charpos < pos_for_neutral) - type = prev_type; + { + type = prev_type; + eassert (type != UNKNOWN_BT); + } } else type = UNKNOWN_BT; -- 2.39.5