diff options
author | 2010-11-29 00:12:02 +0000 | |
---|---|---|
committer | 2010-11-29 00:12:02 +0000 | |
commit | b1e9670a1c5ab8c24995c3ac0de4d25742179db2 (patch) | |
tree | 21da3bab85fa08b2c31af42e10349d3ae12d5c40 /usr.bin/mandoc/man_validate.c | |
parent | double the default message buffer size. again. (diff) | |
download | wireguard-openbsd-b1e9670a1c5ab8c24995c3ac0de4d25742179db2.tar.xz wireguard-openbsd-b1e9670a1c5ab8c24995c3ac0de4d25742179db2.zip |
Implement the roff .ft (change font) request for man(7).
Of course, we don't want to encourage low-level physical markup,
but pod2man(1) writes such requests, so Perl manuals contain them,
and some Xenocara and lots and lots of ports manuals use them as well.
In base and Xenocara, this will reduce mandoc -Tlint ERROR noise;
in ports, it will improve rendering of many manuals.
Diffstat (limited to 'usr.bin/mandoc/man_validate.c')
-rw-r--r-- | usr.bin/mandoc/man_validate.c | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/usr.bin/mandoc/man_validate.c b/usr.bin/mandoc/man_validate.c index c59d9e0bdff..f3967085186 100644 --- a/usr.bin/mandoc/man_validate.c +++ b/usr.bin/mandoc/man_validate.c @@ -1,6 +1,7 @@ -/* $Id: man_validate.c,v 1.31 2010/10/27 10:17:45 schwarze Exp $ */ +/* $Id: man_validate.c,v 1.32 2010/11/29 00:12:02 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> + * Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -42,6 +43,7 @@ static int check_eq0(CHKARGS); static int check_le1(CHKARGS); static int check_ge2(CHKARGS); static int check_le5(CHKARGS); +static int check_ft(CHKARGS); static int check_par(CHKARGS); static int check_part(CHKARGS); static int check_root(CHKARGS); @@ -50,6 +52,7 @@ static int check_text(CHKARGS); static int check_title(CHKARGS); static v_check posts_eq0[] = { check_eq0, NULL }; +static v_check posts_ft[] = { check_ft, NULL }; static v_check posts_th[] = { check_ge2, check_le5, check_title, NULL }; static v_check posts_par[] = { check_par, NULL }; static v_check posts_part[] = { check_part, NULL }; @@ -97,6 +100,7 @@ static const struct man_valid man_valids[MAN_MAX] = { { NULL, NULL }, /* in */ { NULL, NULL }, /* TS */ { NULL, NULL }, /* TE */ + { NULL, posts_ft }, /* ft */ }; @@ -258,6 +262,59 @@ INEQ_DEFINE(5, <=, le5) static int +check_ft(CHKARGS) +{ + char *cp; + int ok; + + if (0 == n->nchild) + return(1); + + ok = 0; + cp = n->child->string; + switch (*cp) { + case ('1'): + /* FALLTHROUGH */ + case ('2'): + /* FALLTHROUGH */ + case ('3'): + /* FALLTHROUGH */ + case ('4'): + /* FALLTHROUGH */ + case ('I'): + /* FALLTHROUGH */ + case ('P'): + /* FALLTHROUGH */ + case ('R'): + if ('\0' == cp[1]) + ok = 1; + break; + case ('B'): + if ('\0' == cp[1] || ('I' == cp[1] && '\0' == cp[2])) + ok = 1; + break; + case ('C'): + if ('W' == cp[1] && '\0' == cp[2]) + ok = 1; + break; + default: + break; + } + + if (0 == ok) { + man_vmsg(m, MANDOCERR_BADFONT, n->line, n->pos, "%s", cp); + *cp = '\0'; + } + + if (1 < n->nchild) + man_vmsg(m, MANDOCERR_ARGCOUNT, n->line, n->pos, + "want one child (have %d)", n->nchild); + + return(1); +} + + +static int check_sec(CHKARGS) { |