1 /* $Id: roff_validate.c,v 1.7 2017/06/06 15:01:04 schwarze Exp $ */
3 * Copyright (c) 2010, 2017 Ingo Schwarze <schwarze@openbsd.org>
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #include <sys/types.h>
24 #include "libmandoc.h"
27 #define ROFF_VALID_ARGS struct roff_man *man, struct roff_node *n
29 typedef void (*roff_valid_fp
)(ROFF_VALID_ARGS
);
31 static void roff_valid_ft(ROFF_VALID_ARGS
);
33 static const roff_valid_fp roff_valids
[ROFF_MAX
] = {
36 roff_valid_ft
, /* ft */
46 roff_validate(struct roff_man
*man
)
51 assert(n
->tok
< ROFF_MAX
);
52 if (roff_valids
[n
->tok
] != NULL
)
53 (*roff_valids
[n
->tok
])(man
, n
);
57 roff_valid_ft(ROFF_VALID_ARGS
)
61 if (n
->child
== NULL
) {
62 man
->next
= ROFF_NEXT_CHILD
;
63 roff_word_alloc(man
, n
->line
, n
->pos
, "P");
68 cp
= n
->child
->string
;
81 if (cp
[1] == '\0' || (cp
[1] == 'I' && cp
[2] == '\0'))
85 if (cp
[1] == 'W' && cp
[2] == '\0')
92 mandoc_vmsg(MANDOCERR_FT_BAD
, man
->parse
,
93 n
->line
, n
->pos
, "ft %s", cp
);
94 roff_node_delete(man
, n
);