@@ -70,22 +70,6 @@ static void S_parser_feed(cmark_parser *parser, const unsigned char *buffer,
70
70
static void S_process_line (cmark_parser * parser , const unsigned char * buffer ,
71
71
bufsize_t bytes );
72
72
73
- static void subtract_open_block_counts (cmark_parser * parser , cmark_node * node ) {
74
- do {
75
- decr_open_block_count (parser , S_type (node ));
76
- node -> flags &= ~CMARK_NODE__OPEN_BLOCK ;
77
- node = node -> last_child ;
78
- } while (node );
79
- }
80
-
81
- static void add_open_block_counts (cmark_parser * parser , cmark_node * node ) {
82
- do {
83
- incr_open_block_count (parser , S_type (node ));
84
- node -> flags |= CMARK_NODE__OPEN_BLOCK ;
85
- node = node -> last_child ;
86
- } while (node );
87
- }
88
-
89
73
static cmark_node * make_block (cmark_mem * mem , cmark_node_type tag ,
90
74
int start_line , int start_column ) {
91
75
cmark_node * e ;
@@ -145,7 +129,6 @@ static void cmark_parser_reset(cmark_parser *parser) {
145
129
parser -> refmap = cmark_reference_map_new (parser -> mem );
146
130
parser -> root = document ;
147
131
parser -> current = document ;
148
- add_open_block_counts (parser , document );
149
132
150
133
parser -> syntax_extensions = saved_exts ;
151
134
parser -> inline_syntax_extensions = saved_inline_exts ;
@@ -327,12 +310,6 @@ static cmark_node *finalize(cmark_parser *parser, cmark_node *b) {
327
310
has_content = resolve_reference_link_definitions (parser , b );
328
311
if (!has_content ) {
329
312
// remove blank node (former reference def)
330
- if (b -> flags & CMARK_NODE__OPEN_BLOCK ) {
331
- decr_open_block_count (parser , S_type (b ));
332
- if (b -> prev ) {
333
- add_open_block_counts (parser , b -> prev );
334
- }
335
- }
336
313
cmark_node_free (b );
337
314
}
338
315
break ;
@@ -405,15 +382,6 @@ static cmark_node *finalize(cmark_parser *parser, cmark_node *b) {
405
382
return parent ;
406
383
}
407
384
408
- // Recalculates the number of open blocks. Returns true if it matches what's currently stored
409
- // in parser. (Used to check that the counts in parser, which are updated incrementally, are
410
- // correct.)
411
- bool check_open_block_counts (cmark_parser * parser ) {
412
- cmark_parser tmp_parser = {0 }; // Only used for its open_block_counts field.
413
- add_open_block_counts (& tmp_parser , parser -> root );
414
- return memcmp (tmp_parser .open_block_counts , parser -> open_block_counts , sizeof (parser -> open_block_counts )) == 0 ;
415
- }
416
-
417
385
// Add a node as child of another. Return pointer to child.
418
386
static cmark_node * add_child (cmark_parser * parser , cmark_node * parent ,
419
387
cmark_node_type block_type , int start_column ) {
@@ -432,14 +400,11 @@ static cmark_node *add_child(cmark_parser *parser, cmark_node *parent,
432
400
if (parent -> last_child ) {
433
401
parent -> last_child -> next = child ;
434
402
child -> prev = parent -> last_child ;
435
- subtract_open_block_counts (parser , parent -> last_child );
436
403
} else {
437
404
parent -> first_child = child ;
438
405
child -> prev = NULL ;
439
406
}
440
407
parent -> last_child = child ;
441
- add_open_block_counts (parser , child );
442
-
443
408
return child ;
444
409
}
445
410
@@ -1083,8 +1048,6 @@ static cmark_node *check_open_blocks(cmark_parser *parser, cmark_chunk *input,
1083
1048
cmark_node * container = parser -> root ;
1084
1049
cmark_node_type cont_type ;
1085
1050
1086
- assert (check_open_block_counts (parser ));
1087
-
1088
1051
while (S_last_child_is_open (container )) {
1089
1052
container = container -> last_child ;
1090
1053
cont_type = S_type (container );
@@ -1230,9 +1193,8 @@ static void open_new_blocks(cmark_parser *parser, cmark_node **container,
1230
1193
has_content = resolve_reference_link_definitions (parser , * container );
1231
1194
1232
1195
if (has_content ) {
1233
- cmark_node_set_type (* container , CMARK_NODE_HEADING );
1234
- decr_open_block_count (parser , CMARK_NODE_PARAGRAPH );
1235
- incr_open_block_count (parser , CMARK_NODE_HEADING );
1196
+
1197
+ (* container )-> type = (uint16_t )CMARK_NODE_HEADING ;
1236
1198
(* container )-> as .heading .level = lev ;
1237
1199
(* container )-> as .heading .setext = true;
1238
1200
S_advance_offset (parser , input , input -> len - 1 - parser -> offset , false);
@@ -1516,7 +1478,6 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
1516
1478
1517
1479
parser -> line_number ++ ;
1518
1480
1519
- assert (parser -> current -> next == NULL );
1520
1481
last_matched_container = check_open_blocks (parser , & input , & all_matched );
1521
1482
1522
1483
if (!last_matched_container )
0 commit comments