(prop-match-end prop-match)
'(font-lock-face face mouse-face
help-echo)))))
- (let (next)
+ (let ((count 0)
+ next)
(goto-char beg)
(while (setq next
(bidi-find-overridden-directionality
help-echo "\
This text is reordered on display in a way that could change its semantics;
use \\[forward-char] and \\[backward-char] to see the actual order of characters.")))
- (goto-char finish)))))))
+ (goto-char finish)
+ (setq count (1+ count))))
+ (message
+ (if (> count 0)
+ (ngettext
+ "Highlighted %d confusingly-reordered text string"
+ "Highlighted %d confusingly-reordered text strings"
+ count)
+ "No confusingly-reordered text strings were found")
+ count)))))
;;; mule-cmds.el ends here
overrides, and isolates, i.e. before resolving implicit levels. */
int max_l2r = bidi_it->paragraph_dir == L2R ? 0 : 2;
int max_r2l = 1;
+ /* Same for WEAK and NEUTRAL_ON types. */
+ int max_weak = bidi_it->paragraph_dir == L2R ? 1 : 2;
do
{
because the directional overrides are applied by the
former. */
bidi_type_t type = bidi_resolve_weak (bidi_it);
+ unsigned level = bidi_it->level_stack[bidi_it->stack_idx].level;
+ bidi_category_t category = bidi_get_category (bidi_it->orig_type);
/* Detect strong L or R types that have been overridden by
explicit overrides. */
reorder) by explicit embeddings and isolates. */
|| ((bidi_it->orig_type == STRONG_L
|| bidi_it->orig_type == WEAK_EN)
- && bidi_it->level_stack[bidi_it->stack_idx].level > max_l2r)
+ && level > max_l2r)
|| ((bidi_it->orig_type == STRONG_R
|| bidi_it->orig_type == STRONG_AL)
- && bidi_it->level_stack[bidi_it->stack_idx].level > max_r2l))
+ && level > max_r2l)
+ /* Detect other weak or neutral types whose level was
+ tweaked by explicit embeddings and isolates. */
+ || ((category == WEAK || bidi_it->orig_type == NEUTRAL_ON)
+ && level > max_weak))
found_pos = bidi_it->charpos;
} while (found_pos == ZV
&& bidi_it->charpos < ZV
(goto-char (point-min))
(should (eq (bidi-find-overridden-directionality (point-min) (point-max)
nil)
- 140))))
+ 138))))
+
+(ert-deftest xdisp-tests--find-directional-overrides-case-3 ()
+ (with-temp-buffer
+ (insert "\
+#define is_restricted_user(user) \\
+ !strcmp (user, \"root\") ? 0 : \\
+ !strcmp (user, \"admin\") ? 0 : \\
+ !strcmp (user, \"superuser? '#' : '!' \")
+
+int main () {
+ printf (\"root: %d\\n\", is_restricted_user (\"root\"));
+ printf (\"admin: %d\\n\", is_restricted_user (\"admin\"));
+ printf (\"superuser: %d\\n\", is_restricted_user (\"superuser\"));
+ printf (\"luser: %d\\n\", is_restricted_user (\"luser\"));
+ printf (\"nobody: %d\\n\", is_restricted_user (\"nobody\"));
+}")
+ (goto-char (point-min))
+ (should (eq (bidi-find-overridden-directionality (point-min) (point-max)
+ nil)
+ 138))))
;;; xdisp-tests.el ends here