aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_validate.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-11-27 16:20:31 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-11-27 16:20:31 +0000
commitae5f77f4afb4eacc8500ded5455086d6242ae946 (patch)
treea14a4377b896bcb23d2b71d2b57d9b3c825b0a78 /mdoc_validate.c
parent63db09932dec56e5bb940db7c81df9660ab0c0d0 (diff)
downloadmandoc-ae5f77f4afb4eacc8500ded5455086d6242ae946.tar.gz
mandoc-ae5f77f4afb4eacc8500ded5455086d6242ae946.tar.zst
mandoc-ae5f77f4afb4eacc8500ded5455086d6242ae946.zip
Fix the obsolete .Db (toggle debug mode) macro to ignore its arguments
and not trigger an assertion when there is more than one argument; the latter found by jsg@ with afl.
Diffstat (limited to 'mdoc_validate.c')
-rw-r--r--mdoc_validate.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 28a110da..5707b319 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.256 2014/11/26 19:24:03 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.257 2014/11/27 16:20:31 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -72,7 +72,6 @@ static enum mdoc_sec a2sec(const char *);
static size_t macro2len(enum mdoct);
static void rewrite_macro2len(char **);
-static int ebool(POST_ARGS);
static int berr_ge1(POST_ARGS);
static int bwarn_ge1(POST_ARGS);
static int ewarn_eq0(POST_ARGS);
@@ -122,6 +121,7 @@ static int post_sh_head(POST_ARGS);
static int post_sh_name(POST_ARGS);
static int post_sh_see_also(POST_ARGS);
static int post_sh_authors(POST_ARGS);
+static int post_sm(POST_ARGS);
static int post_st(POST_ARGS);
static int post_vt(POST_ARGS);
static int pre_an(PRE_ARGS);
@@ -199,7 +199,7 @@ static const struct valids mdoc_valids[MDOC_MAX] = {
{ NULL, NULL }, /* Bq */
{ NULL, NULL }, /* Bsx */
{ NULL, post_bx }, /* Bx */
- { NULL, ebool }, /* Db */
+ { pre_obsolete, NULL }, /* Db */
{ NULL, NULL }, /* Dc */
{ NULL, NULL }, /* Do */
{ NULL, NULL }, /* Dq */
@@ -226,7 +226,7 @@ static const struct valids mdoc_valids[MDOC_MAX] = {
{ NULL, NULL }, /* Sc */
{ NULL, NULL }, /* So */
{ NULL, NULL }, /* Sq */
- { NULL, ebool }, /* Sm */
+ { NULL, post_sm }, /* Sm */
{ NULL, post_hyph }, /* Sx */
{ NULL, NULL }, /* Sy */
{ NULL, NULL }, /* Tn */
@@ -1622,36 +1622,31 @@ post_bk(POST_ARGS)
}
static int
-ebool(struct mdoc *mdoc)
+post_sm(struct mdoc *mdoc)
{
struct mdoc_node *nch;
- enum mdoct tok;
- tok = mdoc->last->tok;
nch = mdoc->last->child;
- if (NULL == nch) {
- if (MDOC_Sm == tok)
- mdoc->flags ^= MDOC_SMOFF;
+ if (nch == NULL) {
+ mdoc->flags ^= MDOC_SMOFF;
return(1);
}
- assert(MDOC_TEXT == nch->type);
+ assert(nch->type == MDOC_TEXT);
- if (0 == strcmp(nch->string, "on")) {
- if (MDOC_Sm == tok)
- mdoc->flags &= ~MDOC_SMOFF;
+ if ( ! strcmp(nch->string, "on")) {
+ mdoc->flags &= ~MDOC_SMOFF;
return(1);
}
- if (0 == strcmp(nch->string, "off")) {
- if (MDOC_Sm == tok)
- mdoc->flags |= MDOC_SMOFF;
+ if ( ! strcmp(nch->string, "off")) {
+ mdoc->flags |= MDOC_SMOFF;
return(1);
}
mandoc_vmsg(MANDOCERR_SM_BAD,
mdoc->parse, nch->line, nch->pos,
- "%s %s", mdoc_macronames[tok], nch->string);
+ "%s %s", mdoc_macronames[mdoc->last->tok], nch->string);
return(mdoc_node_relink(mdoc, nch));
}