aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/man_validate.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-12-06 15:31:19 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-12-06 15:31:19 +0000
commit8824599579c15c29a52a6ec127ec1b2a35719e2c (patch)
treef539cfc87104909847b10dcdfe2a9610a7a177c1 /man_validate.c
parent6da78159c4f30e5cbfe60fe6a244c73321edcb1c (diff)
downloadmandoc-8824599579c15c29a52a6ec127ec1b2a35719e2c.tar.gz
mandoc-8824599579c15c29a52a6ec127ec1b2a35719e2c.tar.zst
mandoc-8824599579c15c29a52a6ec127ec1b2a35719e2c.zip
Add support for `ft' macro found in groff(7). Based on a patch by
schwarze@, but without the -T[x]html handling, which structurally does not work. Also add man.7 documentation (not in original patch).
Diffstat (limited to 'man_validate.c')
-rw-r--r--man_validate.c57
1 files changed, 56 insertions, 1 deletions
diff --git a/man_validate.c b/man_validate.c
index 11f3de78..94bfdf29 100644
--- a/man_validate.c
+++ b/man_validate.c
@@ -1,4 +1,4 @@
-/* $Id: man_validate.c,v 1.54 2010/12/06 13:56:56 kristaps Exp $ */
+/* $Id: man_validate.c,v 1.55 2010/12/06 15:31:19 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -44,6 +44,7 @@ struct man_valid {
static int check_bline(CHKARGS);
static int check_eq0(CHKARGS);
+static int check_ft(CHKARGS);
static int check_le1(CHKARGS);
static int check_ge2(CHKARGS);
static int check_le5(CHKARGS);
@@ -64,6 +65,7 @@ static v_check posts_at[] = { post_AT, NULL };
static v_check posts_eq0[] = { check_eq0, NULL };
static v_check posts_fi[] = { check_eq0, post_fi, NULL };
static v_check posts_le1[] = { check_le1, NULL };
+static v_check posts_ft[] = { check_ft, NULL };
static v_check posts_nf[] = { check_eq0, post_nf, NULL };
static v_check posts_par[] = { check_par, NULL };
static v_check posts_part[] = { check_part, NULL };
@@ -108,6 +110,7 @@ static const struct man_valid man_valids[MAN_MAX] = {
{ NULL, NULL }, /* PD */
{ NULL, posts_at }, /* AT */
{ NULL, NULL }, /* in */
+ { NULL, posts_ft }, /* ft */
};
@@ -268,6 +271,58 @@ INEQ_DEFINE(1, <=, le1)
INEQ_DEFINE(2, >=, ge2)
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)