Commit 5b5c8e7bb0d383b902fc74c91bdc07b99b56b7a3

Martin Mitas 2016-11-21T00:17:25

md_analyze_simple_pairing_mark: Fix handling of the "rule of three".

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/md4c/md4c.c b/md4c/md4c.c
index 301e491..a5f323f 100644
--- a/md4c/md4c.c
+++ b/md4c/md4c.c
@@ -2887,12 +2887,13 @@ md_analyze_simple_pairing_mark(MD_CTX* ctx, MD_MARKCHAIN* chain, int mark_index,
         SZ opener_size = opener->end - opener->beg;
         SZ closer_size = mark->end - mark->beg;
 
-        if(apply_rule_of_three  &&  (mark->flags & MD_MARK_INTRAWORD)) {
+        if(apply_rule_of_three  &&  ((mark->flags & MD_MARK_INTRAWORD) || (opener->flags & MD_MARK_INTRAWORD))) {
             while((opener_size + closer_size) % 3 == 0) {
                 if(opener->prev < 0)
                     goto cannot_resolve;
 
-                opener = &ctx->marks[opener->prev];
+                opener_index = opener->prev;
+                opener = &ctx->marks[opener_index];
                 opener_size = opener->end - opener->beg;
                 closer_size = mark->end - mark->beg;
             }