diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2015-04-02 22:48:17 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2015-04-02 22:48:17 +0000 |
commit | 9e6e3b6be0e9ffe29cf4876ce0b7ded2c3c386b9 (patch) | |
tree | 1a2bb3465096bc77a000c55dc5753148f39484ad /man_macro.c | |
parent | dd569c39747096c781c1cbec49b48a85ba29f23d (diff) | |
download | mandoc-9e6e3b6be0e9ffe29cf4876ce0b7ded2c3c386b9.tar.gz |
Second step towards parser unification:
Replace struct mdoc_node and struct man_node by a unified struct roff_node.
To be able to use the tok member for both mdoc(7) and man(7) without
defining all the macros in roff.h, sacrifice a tiny bit of type safety
and make tok an int rather than an enum.
Almost mechanical, no functional change.
Written on the Eurostar from Bruxelles to London on the way to p2k15.
Diffstat (limited to 'man_macro.c')
-rw-r--r-- | man_macro.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/man_macro.c b/man_macro.c index fdf82ad8..74f962aa 100644 --- a/man_macro.c +++ b/man_macro.c @@ -44,12 +44,11 @@ static void in_line_eoln(MACRO_PROT_ARGS); static int man_args(struct man *, int, int *, char *, char **); -static void rew_scope(enum roff_type, - struct man *, enum mant); -static enum rew rew_dohalt(enum mant, enum roff_type, - const struct man_node *); -static enum rew rew_block(enum mant, enum roff_type, - const struct man_node *); +static void rew_scope(enum roff_type, struct man *, int); +static enum rew rew_dohalt(int, enum roff_type, + const struct roff_node *); +static enum rew rew_block(int, enum roff_type, + const struct roff_node *); const struct man_macro __man_macros[MAN_MAX] = { { in_line_eoln, MAN_NSCOPED }, /* br */ @@ -96,9 +95,9 @@ const struct man_macro * const man_macros = __man_macros; void -man_unscope(struct man *man, const struct man_node *to) +man_unscope(struct man *man, const struct roff_node *to) { - struct man_node *n; + struct roff_node *n; to = to->parent; n = man->last; @@ -156,7 +155,7 @@ man_unscope(struct man *man, const struct man_node *to) } static enum rew -rew_block(enum mant ntok, enum roff_type type, const struct man_node *n) +rew_block(int ntok, enum roff_type type, const struct roff_node *n) { if (type == ROFFT_BLOCK && n->parent->tok == ntok && @@ -171,7 +170,7 @@ rew_block(enum mant ntok, enum roff_type type, const struct man_node *n) * sections and subsections). */ static enum rew -rew_dohalt(enum mant tok, enum roff_type type, const struct man_node *n) +rew_dohalt(int tok, enum roff_type type, const struct roff_node *n) { enum rew c; @@ -244,9 +243,9 @@ rew_dohalt(enum mant tok, enum roff_type type, const struct man_node *n) * scopes. When a scope is closed, it must be validated and actioned. */ static void -rew_scope(enum roff_type type, struct man *man, enum mant tok) +rew_scope(enum roff_type type, struct man *man, int tok) { - struct man_node *n; + struct roff_node *n; enum rew c; for (n = man->last; n; n = n->parent) { @@ -277,8 +276,8 @@ rew_scope(enum roff_type type, struct man *man, enum mant tok) void blk_close(MACRO_PROT_ARGS) { - enum mant ntok; - const struct man_node *nn; + int ntok; + const struct roff_node *nn; char *p; int nrew, target; @@ -338,7 +337,7 @@ blk_close(MACRO_PROT_ARGS) void blk_exp(MACRO_PROT_ARGS) { - struct man_node *head; + struct roff_node *head; char *p; int la; @@ -371,7 +370,7 @@ blk_imp(MACRO_PROT_ARGS) { int la; char *p; - struct man_node *n; + struct roff_node *n; rew_scope(ROFFT_BODY, man, tok); rew_scope(ROFFT_BLOCK, man, tok); @@ -411,7 +410,7 @@ in_line_eoln(MACRO_PROT_ARGS) { int la; char *p; - struct man_node *n; + struct roff_node *n; man_elem_alloc(man, line, ppos, tok); n = man->last; |