diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2015-02-01 17:30:45 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2015-02-01 17:30:45 +0000 |
commit | 871a699012dc95eebbafa24701859316ba995d6b (patch) | |
tree | 044ad97016757fea68c9efc5e2ebb5f419223b42 /mdoc_macro.c | |
parent | 01c799579c9d64d32016fa6127a74e2d864fd9a9 (diff) | |
download | mandoc-871a699012dc95eebbafa24701859316ba995d6b.tar.gz |
Simplify blk_part_exp(), no functional change.
* Replace calls to rew_sub() with rew_last() - two less out of 18.
* No need to keep track of the body, it's always opened right after
the head and never used for anything in this function.
Diffstat (limited to 'mdoc_macro.c')
-rw-r--r-- | mdoc_macro.c | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/mdoc_macro.c b/mdoc_macro.c index 88499561..3e27c1e7 100644 --- a/mdoc_macro.c +++ b/mdoc_macro.c @@ -1340,7 +1340,6 @@ blk_part_exp(MACRO_PROT_ARGS) int la, nl; enum margserr ac; struct mdoc_node *head; /* keep track of head */ - struct mdoc_node *body; /* keep track of body */ char *p; nl = MDOC_NEWLINE & mdoc->flags; @@ -1352,7 +1351,8 @@ blk_part_exp(MACRO_PROT_ARGS) */ mdoc_block_alloc(mdoc, line, ppos, tok, NULL); - for (head = body = NULL; ; ) { + head = NULL; + for (;;) { la = *pos; ac = mdoc_args(mdoc, line, pos, buf, tok, &p); if (ac == ARGS_PUNCT || ac == ARGS_EOLN) @@ -1362,32 +1362,19 @@ blk_part_exp(MACRO_PROT_ARGS) if (head == NULL && ac != ARGS_QWORD && mdoc_isdelim(p) == DELIM_OPEN) { - assert(NULL == body); dword(mdoc, line, la, p, DELIM_OPEN, 0); continue; } if (head == NULL) { - assert(body == NULL); head = mdoc_head_alloc(mdoc, line, ppos, tok); - } - - /* - * `Eo' gobbles any data into the head, but most other - * macros just immediately close out and begin the body. - */ - - if (body == NULL) { - assert(head); - /* No check whether it's a macro! */ - if (tok == MDOC_Eo) + if (tok == MDOC_Eo) /* Not parsed. */ dword(mdoc, line, la, p, DELIM_MAX, 0); - rew_sub(MDOC_HEAD, mdoc, tok, line, ppos); - body = mdoc_body_alloc(mdoc, line, ppos, tok); + rew_last(mdoc, head); + mdoc_body_alloc(mdoc, line, ppos, tok); if (tok == MDOC_Eo) continue; } - assert(head != NULL && body != NULL); if (macro_or_word(mdoc, tok, line, la, pos, buf, 1)) break; @@ -1395,11 +1382,8 @@ blk_part_exp(MACRO_PROT_ARGS) /* Clean-up to leave in a consistent state. */ - if (head == NULL) - mdoc_head_alloc(mdoc, line, ppos, tok); - - if (body == NULL) { - rew_sub(MDOC_HEAD, mdoc, tok, line, ppos); + if (head == NULL) { + rew_last(mdoc, mdoc_head_alloc(mdoc, line, ppos, tok)); mdoc_body_alloc(mdoc, line, ppos, tok); } if (nl) |