Commit 3c28a8b8dbe7315c46c83c13d2618ba1f3d35a4a

Martin Mitas 2017-01-04T14:29:50

md_rollback: Do not play with the mark flag MD_MARK_LEAF. And remove the flag altogether.

diff --git a/md4c/md4c.c b/md4c/md4c.c
index e5d6254..ac21d79 100644
--- a/md4c/md4c.c
+++ b/md4c/md4c.c
@@ -2158,7 +2158,6 @@ struct MD_MARK_tag {
 #define MD_MARK_OPENER                      0x04  /* Definitely opener. */
 #define MD_MARK_CLOSER                      0x08  /* Definitely closer. */
 #define MD_MARK_RESOLVED                    0x10  /* Resolved in any definite way. */
-#define MD_MARK_LEAF                        0x20  /* Pair does not contain any nested spans. */
 
 /* Mark flags specific for various mark types (so they can share bits). */
 #define MD_MARK_INTRAWORD                   0x40  /* Helper for emphasis '*', '_' ("the rule of 3"). */
@@ -2322,7 +2321,7 @@ md_rollback(MD_CTX* ctx, int opener_index, int closer_index, int how)
                 MD_MARK* mark_opener = &ctx->marks[mark_opener_index];
                 MD_MARKCHAIN* chain;
 
-                mark_opener->flags &= ~(MD_MARK_OPENER | MD_MARK_CLOSER | MD_MARK_RESOLVED | MD_MARK_LEAF);
+                mark_opener->flags &= ~(MD_MARK_OPENER | MD_MARK_CLOSER | MD_MARK_RESOLVED);
 
                 switch(mark_opener->ch) {
                     case '*':   chain = &ASTERISK_OPENERS; break;
@@ -2339,7 +2338,7 @@ md_rollback(MD_CTX* ctx, int opener_index, int closer_index, int how)
 
         /* And reset our flags. */
         if(discard_flag)
-            mark->flags &= ~(MD_MARK_OPENER | MD_MARK_CLOSER | MD_MARK_RESOLVED | MD_MARK_LEAF);
+            mark->flags &= ~(MD_MARK_OPENER | MD_MARK_CLOSER | MD_MARK_RESOLVED);
 
         /* Jump as far as we can over unresolved or non-interesting marks. */
         switch(how) {
@@ -2351,24 +2350,11 @@ md_rollback(MD_CTX* ctx, int opener_index, int closer_index, int how)
                     break;
                 }
                 /* Pass through. */
-            case MD_ROLLBACK_ALL:
-                if((mark_flags & (MD_MARK_CLOSER | MD_MARK_LEAF)) == (MD_MARK_CLOSER | MD_MARK_LEAF)) {
-                    /* If we are closer and now there is no nested resolved mark
-                     * we can also jump right to our opener. */
-                    mark_index = mark->prev;
-                    break;
-                }
-                /* Pass through. */
             default:
                 mark_index--;
                 break;
         }
     }
-
-    if(how == MD_ROLLBACK_ALL) {
-        ctx->marks[opener_index].flags |= MD_MARK_LEAF;
-        ctx->marks[closer_index].flags |= MD_MARK_LEAF;
-    }
 }
 
 /* Split a longer mark into two. The new mark takes the given count of characters.