cmark

My personal build of CMark ✏️

Commit
715d1a5921a4e3e10220d466c4ee2c1261d28c1e
Parent
90c48e849440e50b3fef21f0cd6c38b998490073
Author
John MacFarlane <jgm@berkeley.edu>
Date

Removed stack limits in inline parsing.

This brings back segfaults, but we're now aiming for a better solution, revising the renderer so it doesn't use recursion, and using a stack approach for nested brackets. Removing these limits will allow us to know when we've got it right.

See #166, #187.

Diffstat

2 files changed, 2 insertions, 4 deletions

Status File Name N° Changes Insertions Deletions
Modified src/cmark.h 1 0 1
Modified src/inlines.c 5 2 3
diff --git a/src/cmark.h b/src/cmark.h
@@ -9,7 +9,6 @@
 
 #define VERSION "0.1"
 #define CODE_INDENT 4
-#define STACK_LIMIT 1000
 
 struct node_inl {
 	enum {
diff --git a/src/inlines.c b/src/inlines.c
@@ -416,7 +416,7 @@ static node_inl* handle_strong_emph(subject* subj, unsigned char c, node_inl **l
 cannotClose:
 	inl_text = make_str(chunk_dup(&subj->input, subj->pos - numdelims, numdelims));
 
-	if (can_open && subj->emphasis_nestlevel < STACK_LIMIT)
+	if (can_open)
 	{
 		istack = (inline_stack*)malloc(sizeof(inline_stack));
                 if (istack == NULL) {
@@ -617,8 +617,7 @@ static int link_label(subject* subj, chunk *raw_label)
 
 	advance(subj);  // advance past [
 	unsigned char c;
-	while ((c = peek_char(subj)) &&
-	       (c != ']' || (nestlevel > 0 && nestlevel < STACK_LIMIT))) {
+	while ((c = peek_char(subj)) && (c != ']' || nestlevel > 0)) {
 		switch (c) {
 		case '`':
 			tmp = handle_backticks(subj);