diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2017-01-10 21:54:35 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2017-01-10 21:54:35 +0000 |
commit | 3feb3d9fedff2863348b78acf1f07514a912954e (patch) | |
tree | 06acaaba8c7cc11e20cf7cbd49b26458faf75498 /usr.bin/mandoc/mdoc_validate.c | |
parent | bc7842c770254a36b3bfc5deeb06e64265f8a5f7 (diff) |
For the .Ux/.Ox family of macros, do text production at the validation
stage rather than in each and every individual formatter, using the
new NODE_NOSRC flag. More rigorous and also ten lines less code.
Diffstat (limited to 'usr.bin/mandoc/mdoc_validate.c')
-rw-r--r-- | usr.bin/mandoc/mdoc_validate.c | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index 27417d5b5c1..b41aba41201 100644 --- a/usr.bin/mandoc/mdoc_validate.c +++ b/usr.bin/mandoc/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc_validate.c,v 1.230 2017/01/10 13:46:53 schwarze Exp $ */ +/* $OpenBSD: mdoc_validate.c,v 1.231 2017/01/10 21:54:34 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org> @@ -102,6 +102,7 @@ static void post_sm(POST_ARGS); static void post_st(POST_ARGS); static void post_std(POST_ARGS); static void post_xr(POST_ARGS); +static void post_xx(POST_ARGS); static v_post mdoc_valids[MDOC_MAX] = { NULL, /* Ap */ @@ -164,7 +165,7 @@ static v_post mdoc_valids[MDOC_MAX] = { post_bf, /* Bf */ NULL, /* Bo */ NULL, /* Bq */ - NULL, /* Bsx */ + post_xx, /* Bsx */ post_bx, /* Bx */ post_obsolete, /* Db */ NULL, /* Dc */ @@ -174,12 +175,12 @@ static v_post mdoc_valids[MDOC_MAX] = { NULL, /* Ef */ NULL, /* Em */ NULL, /* Eo */ - NULL, /* Fx */ + post_xx, /* Fx */ NULL, /* Ms */ NULL, /* No */ post_ns, /* Ns */ - NULL, /* Nx */ - NULL, /* Ox */ + post_xx, /* Nx */ + post_xx, /* Ox */ NULL, /* Pc */ NULL, /* Pf */ NULL, /* Po */ @@ -197,7 +198,7 @@ static v_post mdoc_valids[MDOC_MAX] = { post_hyph, /* Sx */ NULL, /* Sy */ NULL, /* Tn */ - NULL, /* Ux */ + post_xx, /* Ux */ NULL, /* Xc */ NULL, /* Xo */ post_fo, /* Fo */ @@ -220,7 +221,7 @@ static v_post mdoc_valids[MDOC_MAX] = { NULL, /* %C */ post_es, /* Es */ post_en, /* En */ - NULL, /* Dx */ + post_xx, /* Dx */ NULL, /* %Q */ post_par, /* br */ post_par, /* sp */ @@ -1022,6 +1023,41 @@ post_es(POST_ARGS) } static void +post_xx(POST_ARGS) +{ + struct roff_node *n; + const char *os; + + n = mdoc->last; + switch (n->tok) { + case MDOC_Bsx: + os = "BSD/OS"; + break; + case MDOC_Dx: + os = "DragonFly"; + break; + case MDOC_Fx: + os = "FreeBSD"; + break; + case MDOC_Nx: + os = "NetBSD"; + break; + case MDOC_Ox: + os = "OpenBSD"; + break; + case MDOC_Ux: + os = "UNIX"; + break; + default: + abort(); + } + mdoc->next = ROFF_NEXT_CHILD; + roff_word_alloc(mdoc, n->line, n->pos, os); + mdoc->last->flags |= NODE_NOSRC; + mdoc->last = n; +} + +static void post_it(POST_ARGS) { struct roff_node *nbl, *nit, *nch; |