summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-01-16 18:23:40 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2015-01-16 18:23:40 -0800
commitc3d897c6c86607493004e0ccdc2c7436eba9e30e (patch)
tree2c10918d118a1668208fac91b7752a42ccebd0fa /src
parentda6e2ffafd9a988aa04ffafd7c1118891e3d97c1 (diff)
Nonrecursive rewrite of ends_with_blank_line.
Closes #286.
Diffstat (limited to 'src')
-rw-r--r--src/blocks.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/blocks.c b/src/blocks.c
index 6ed54d0..e5669ea 100644
--- a/src/blocks.c
+++ b/src/blocks.c
@@ -147,14 +147,18 @@ static void remove_trailing_blank_lines(cmark_strbuf *ln)
// if needed into lists and sublists.
static bool ends_with_blank_line(cmark_node* node)
{
- if (node->last_line_blank) {
- return true;
- }
- if ((node->type == NODE_LIST || node->type == NODE_ITEM) && node->last_child) {
- return ends_with_blank_line(node->last_child);
- } else {
- return false;
+ cmark_node *cur = node;
+ while (cur != NULL) {
+ if (cur->last_line_blank) {
+ return true;
+ }
+ if (cur->type == NODE_LIST || cur->type == NODE_ITEM) {
+ cur = cur->last_child;
+ } else {
+ cur = NULL;
+ }
}
+ return false;
}
// Break out of all containing lists