[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 26089c8: Improve detection of suspicious reordering in source cod
From: |
Eli Zaretskii |
Subject: |
master 26089c8: Improve detection of suspicious reordering in source code |
Date: |
Sat, 6 Nov 2021 06:35:21 -0400 (EDT) |
branch: master
commit 26089c8c446de4851143a42b2005844d152e8e99
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>
Improve detection of suspicious reordering in source code
* src/bidi.c (bidi_find_first_overridden): Detect suspiciously
reordered EN types as well.
* test/src/xdisp-tests.el
(xdisp-tests--find-directional-overrides-case-1): Rename from
'xdisp-tests--find-directional-overrides'.
(xdisp-tests--find-directional-overrides-case-2): New test.
---
src/bidi.c | 9 +++++----
test/src/xdisp-tests.el | 22 +++++++++++++++++++++-
2 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/src/bidi.c b/src/bidi.c
index 3cdcd7d..511b460 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -3589,10 +3589,11 @@ bidi_find_first_overridden (struct bidi_it *bidi_it)
|| (type == STRONG_L
&& (bidi_it->orig_type == STRONG_R
|| bidi_it->orig_type == STRONG_AL))
- /* Detect strong L or R types that were pushed into higher
- embedding levels (and will thus reorder) by explicit
- embeddings and isolates. */
- || (bidi_it->orig_type == STRONG_L
+ /* Detect strong L or R types or WEAK_EN types that were
+ pushed into higher embedding levels (and will thus
+ 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)
|| ((bidi_it->orig_type == STRONG_R
|| bidi_it->orig_type == STRONG_AL)
diff --git a/test/src/xdisp-tests.el b/test/src/xdisp-tests.el
index a385ded..4a87f19 100644
--- a/test/src/xdisp-tests.el
+++ b/test/src/xdisp-tests.el
@@ -99,7 +99,7 @@
(width-in-chars (/ (car size) char-width)))
(should (equal width-in-chars 3)))))
-(ert-deftest xdisp-tests--find-directional-overrides ()
+(ert-deftest xdisp-tests--find-directional-overrides-case-1 ()
(with-temp-buffer
(insert "\
int main() {
@@ -114,4 +114,24 @@ int main() {
nil)
46))))
+(ert-deftest xdisp-tests--find-directional-overrides-case-2 ()
+ (with-temp-buffer
+ (insert "\
+#define is_restricted_user(user) \\
+ !strcmp (user, \"root\") ? 0 : \\
+ !strcmp (user, \"admin\") ? 0 : \\
+ !strcmp (user, \"superuser? 0 : 1 \")
+
+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)
+ 140))))
+
;;; xdisp-tests.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 26089c8: Improve detection of suspicious reordering in source code,
Eli Zaretskii <=