summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/inlines.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/inlines.c b/src/inlines.c
index 589b3c3..56e4eba 100644
--- a/src/inlines.c
+++ b/src/inlines.c
@@ -11,7 +11,7 @@
#include "inlines.h"
typedef struct InlineStack {
- inline_stack *previous;
+ struct InlineStack *previous;
node_inl *first_inline;
int delim_count;
char delim_char;
@@ -27,7 +27,7 @@ typedef struct Subject {
static node_inl *parse_chunk_inlines(chunk *chunk, reference_map *refmap);
static node_inl *parse_inlines_while(subject* subj, int (*f)(subject*));
-static int parse_inline(subject* subj, node_inl ** last);
+static int parse_inline(subject* subj, node_inl ** first, node_inl ** last);
static void subject_from_chunk(subject *e, chunk *chunk, reference_map *refmap);
static void subject_from_buf(subject *e, strbuf *buffer, reference_map *refmap);
@@ -720,8 +720,9 @@ inline static int not_eof(subject* subj)
extern node_inl* parse_inlines_while(subject* subj, int (*f)(subject*))
{
node_inl* result = NULL;
- node_inl** last = &result;
- while ((*f)(subj) && parse_inline(subj, last)) {
+ node_inl** first = &result;
+ node_inl* last = NULL;
+ while ((*f)(subj) && parse_inline(subj, first, &last)) {
}
return result;
}
@@ -768,7 +769,7 @@ static int subject_find_special_char(subject *subj)
// Parse an inline, advancing subject, and add it to last element.
// Adjust tail to point to new last element of list.
// Return 0 if no inline can be parsed, 1 otherwise.
-static int parse_inline(subject* subj, node_inl ** last)
+static int parse_inline(subject* subj, node_inl ** first, node_inl ** last)
{
node_inl* new = NULL;
chunk contents;
@@ -828,11 +829,18 @@ static int parse_inline(subject* subj, node_inl ** last)
new = make_str(contents);
}
- if (*last == NULL) {
+ if (*first == NULL) {
+ *first = new;
*last = new;
} else {
- append_inlines(*last, new);
+ append_inlines(*first, new);
}
+
+ while (new->next) {
+ new = new->next;
+ }
+ *last = new;
+
return 1;
}