diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2014-11-07 16:27:05 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-11-07 21:51:05 -0800 |
commit | 490e9f08a2b2d1d6d60c56b36256e8a9a9ddf814 (patch) | |
tree | f9ea468506ce594cbb0965269981487f1c039524 /src | |
parent | 9f78f9d0b2d379f528f8e7624a344907febfabbc (diff) |
Replace parse_inlines_while with parse_inlines_from_subject.
Diffstat (limited to 'src')
-rw-r--r-- | src/inlines.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/inlines.c b/src/inlines.c index 810230c..b116717 100644 --- a/src/inlines.c +++ b/src/inlines.c @@ -28,7 +28,7 @@ typedef struct Subject { } subject; static node_inl *parse_chunk_inlines(chunk *chunk, reference_map *refmap); -static node_inl *parse_inlines_while(subject* subj, int (*f)(subject*)); +static node_inl *parse_inlines_from_subject(subject* subj); static int parse_inline(subject* subj, node_inl ** last); static void subject_from_chunk(subject *e, chunk *chunk, reference_map *refmap); @@ -759,18 +759,13 @@ static node_inl* handle_newline(subject *subj) } } -inline static int not_eof(subject* subj) -{ - return !is_eof(subj); -} - -// Parse inlines while a predicate is satisfied. Return inlines. -extern node_inl* parse_inlines_while(subject* subj, int (*f)(subject*)) +// Parse inlines til end of subject, returning inlines. +extern node_inl* parse_inlines_from_subject(subject* subj) { node_inl* result = NULL; node_inl** last = &result; node_inl* first = NULL; - while ((*f)(subj) && parse_inline(subj, last)) { + while (!is_eof(subj) && parse_inline(subj, last)) { if (!first) { first = *last; } @@ -791,7 +786,7 @@ node_inl *parse_chunk_inlines(chunk *chunk, reference_map *refmap) { subject subj; subject_from_chunk(&subj, chunk, refmap); - return parse_inlines_while(&subj, not_eof); + return parse_inlines_from_subject(&subj); } static int subject_find_special_char(subject *subj) @@ -903,7 +898,7 @@ extern node_inl* parse_inlines(strbuf *input, reference_map *refmap) { subject subj; subject_from_buf(&subj, input, refmap); - return parse_inlines_while(&subj, not_eof); + return parse_inlines_from_subject(&subj); } // Parse zero or more space characters, including at most one newline. |