cmark

My personal build of CMark ✏️

Commit
1989e87296bd5d143da262d5ac868605e8310a00
Parent
ea8818b809a2d50a484ab5154352e4d4790df992
Author
John MacFarlane <jgm@berkeley.edu>
Date

html: Removed union from RenderStack.

It doesn't make sense to have a union here, and this simplifies the code.

Diffstat

1 file changed, 6 insertions, 9 deletions

Status File Name N° Changes Insertions Deletions
Modified src/html/html.c 15 6 9
diff --git a/src/html/html.c b/src/html/html.c
@@ -13,10 +13,7 @@
 typedef struct RenderStack {
 	struct RenderStack *previous;
 	char* literal;
-	union {
-		cmark_node *inl;
-		cmark_node *block;
-	} next_sibling;
+	cmark_node* next_sibling;
 	bool tight;
 	bool trim;
 } render_stack;
@@ -41,7 +38,7 @@ static render_stack* push_inline(render_stack* rstack,
 		return NULL;
 	}
 	newstack->previous = rstack;
-	newstack->next_sibling.inl = inl;
+	newstack->next_sibling = inl;
 	newstack->literal = literal;
 	newstack->tight = false;
 	newstack->trim = false;
@@ -60,7 +57,7 @@ static render_stack* push_block(render_stack* rstack,
 		return NULL;
 	}
 	newstack->previous = rstack;
-	newstack->next_sibling.block = block;
+	newstack->next_sibling = block;
 	newstack->literal = literal;
 	newstack->tight = tight;
 	newstack->trim = trim;
@@ -143,7 +140,7 @@ static void inlines_to_plain_html(strbuf *html, cmark_node* ils)
 		}
 		while (ils == NULL && rstack != NULL) {
 			strbuf_puts(html, rstack->literal);
-			ils = rstack->next_sibling.inl;
+			ils = rstack->next_sibling;
 			rstack = pop_render_stack(rstack);
 		}
 	}
@@ -237,7 +234,7 @@ static void inlines_to_html(strbuf *html, cmark_node* ils)
 		}
 		while (ils == NULL && rstack != NULL) {
 			strbuf_puts(html, rstack->literal);
-			ils = rstack->next_sibling.inl;
+			ils = rstack->next_sibling;
 			rstack = pop_render_stack(rstack);
 		}
 	}
@@ -365,7 +362,7 @@ static void blocks_to_html(strbuf *html, cmark_node *b)
 				strbuf_rtrim(html);
 			}
 			tight = rstack->tight;
-			b = rstack->next_sibling.block;
+			b = rstack->next_sibling;
 			rstack = pop_render_stack(rstack);
 		}
 	}