summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2014-11-27 16:20:29 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2014-11-27 16:20:29 +0000
commitcfd4d3ad863deab48b1605425c7ce30b540c8e08 (patch)
tree295668c4e505bfdebd5713db5f683619bc78592d
parentec339eb60cef5a539e6bbb6c5ddad6f5e39f99c7 (diff)
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.
-rw-r--r--regress/usr.bin/mandoc/mdoc/Db/Makefile6
-rw-r--r--regress/usr.bin/mandoc/mdoc/Db/args.in14
-rw-r--r--regress/usr.bin/mandoc/mdoc/Db/args.out_ascii9
-rw-r--r--regress/usr.bin/mandoc/mdoc/Db/args.out_lint3
-rw-r--r--regress/usr.bin/mandoc/mdoc/Makefile4
-rw-r--r--share/man/man7/mdoc.717
-rw-r--r--usr.bin/mandoc/mdoc_html.c4
-rw-r--r--usr.bin/mandoc/mdoc_man.c22
-rw-r--r--usr.bin/mandoc/mdoc_term.c10
-rw-r--r--usr.bin/mandoc/mdoc_validate.c32
10 files changed, 73 insertions, 48 deletions
diff --git a/regress/usr.bin/mandoc/mdoc/Db/Makefile b/regress/usr.bin/mandoc/mdoc/Db/Makefile
new file mode 100644
index 00000000000..c37822ff284
--- /dev/null
+++ b/regress/usr.bin/mandoc/mdoc/Db/Makefile
@@ -0,0 +1,6 @@
+# $OpenBSD: Makefile,v 1.1 2014/11/27 16:20:27 schwarze Exp $
+
+REGRESS_TARGETS = args
+LINT_TARGETS = args
+
+.include <bsd.regress.mk>
diff --git a/regress/usr.bin/mandoc/mdoc/Db/args.in b/regress/usr.bin/mandoc/mdoc/Db/args.in
new file mode 100644
index 00000000000..b40d7b0c20c
--- /dev/null
+++ b/regress/usr.bin/mandoc/mdoc/Db/args.in
@@ -0,0 +1,14 @@
+.Dd November 27, 2014
+.Dt DB-ARGS 1
+.Os OpenBSD
+.Sh NAME
+.Nm Db-args
+.Nd obsolete debug macro
+.Sh DESCRIPTION
+no args
+.Db
+one arg
+.Db on
+two args
+.Db foo bar
+end of text
diff --git a/regress/usr.bin/mandoc/mdoc/Db/args.out_ascii b/regress/usr.bin/mandoc/mdoc/Db/args.out_ascii
new file mode 100644
index 00000000000..909b91ba18e
--- /dev/null
+++ b/regress/usr.bin/mandoc/mdoc/Db/args.out_ascii
@@ -0,0 +1,9 @@
+DB-ARGS(1) General Commands Manual DB-ARGS(1)
+
+NNAAMMEE
+ DDbb--aarrggss - obsolete debug macro
+
+DDEESSCCRRIIPPTTIIOONN
+ no args one arg two args end of text
+
+OpenBSD November 27, 2014 OpenBSD
diff --git a/regress/usr.bin/mandoc/mdoc/Db/args.out_lint b/regress/usr.bin/mandoc/mdoc/Db/args.out_lint
new file mode 100644
index 00000000000..e0eb44aebe4
--- /dev/null
+++ b/regress/usr.bin/mandoc/mdoc/Db/args.out_lint
@@ -0,0 +1,3 @@
+mandoc: args.in:9:2: WARNING: obsolete macro: Db
+mandoc: args.in:11:2: WARNING: obsolete macro: Db
+mandoc: args.in:13:2: WARNING: obsolete macro: Db
diff --git a/regress/usr.bin/mandoc/mdoc/Makefile b/regress/usr.bin/mandoc/mdoc/Makefile
index d918d28bb5c..6006c7da574 100644
--- a/regress/usr.bin/mandoc/mdoc/Makefile
+++ b/regress/usr.bin/mandoc/mdoc/Makefile
@@ -1,7 +1,7 @@
-# $OpenBSD: Makefile,v 1.29 2014/08/14 02:00:52 schwarze Exp $
+# $OpenBSD: Makefile,v 1.30 2014/11/27 16:20:27 schwarze Exp $
SUBDIR = Ad An Ap Aq Ar At Bd Bf Bk Bl Brq Bx Cd Cm
-SUBDIR += D1 Dd Dl Dq Dt Dv Em Eo Er Ev Ex Fd Fl Fo Ft Ic In Lb Li Lk
+SUBDIR += D1 Db Dd Dl Dq Dt Dv Em Eo Er Ev Ex Fd Fl Fo Ft Ic In Lb Li Lk
SUBDIR += Ms Mt Nd Nm No Ns Oo Op Os Ox Pa Pf Pp Qq Rs Rv
SUBDIR += Sh Sm Sq St Sx Sy Tn Ux Va Vt Xr blank
diff --git a/share/man/man7/mdoc.7 b/share/man/man7/mdoc.7
index 9f98950d79c..87d5b7bc991 100644
--- a/share/man/man7/mdoc.7
+++ b/share/man/man7/mdoc.7
@@ -1,4 +1,4 @@
-.\" $OpenBSD: mdoc.7,v 1.123 2014/11/16 20:45:27 schwarze Exp $
+.\" $OpenBSD: mdoc.7,v 1.124 2014/11/27 16:20:27 schwarze Exp $
.\"
.\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2010, 2011, 2013 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,7 +15,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: November 16 2014 $
+.Dd $Mdocdate: November 27 2014 $
.Dt MDOC 7
.Os
.Sh NAME
@@ -1185,13 +1185,12 @@ See also
and
.Sx \&Dl .
.Ss \&Db
-Switch debugging mode.
-Its syntax is as follows:
-.Pp
-.D1 Pf \. Sx \&Db Cm on | off
-.Pp
-This macro is ignored by
-.Xr mandoc 1 .
+This macro is obsolete.
+No replacement is needed.
+It is ignored by
+.Xr mandoc 1
+and groff including its arguments.
+It was formerly used to toggle a debugging mode.
.Ss \&Dc
Close a
.Sx \&Do
diff --git a/usr.bin/mandoc/mdoc_html.c b/usr.bin/mandoc/mdoc_html.c
index 7146784f71a..c0f6e29c53a 100644
--- a/usr.bin/mandoc/mdoc_html.c
+++ b/usr.bin/mandoc/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_html.c,v 1.86 2014/11/19 21:59:19 schwarze Exp $ */
+/* $OpenBSD: mdoc_html.c,v 1.87 2014/11/27 16:20:27 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -181,7 +181,7 @@ static const struct htmlmdoc mdocs[MDOC_MAX] = {
{mdoc_quote_pre, mdoc_quote_post}, /* Bq */
{mdoc_xx_pre, NULL}, /* Bsx */
{mdoc_bx_pre, NULL}, /* Bx */
- {NULL, NULL}, /* Db */
+ {mdoc_skip_pre, NULL}, /* Db */
{NULL, NULL}, /* Dc */
{mdoc_quote_pre, mdoc_quote_post}, /* Do */
{mdoc_quote_pre, mdoc_quote_post}, /* Dq */
diff --git a/usr.bin/mandoc/mdoc_man.c b/usr.bin/mandoc/mdoc_man.c
index 226fb720b3d..84acd1e461e 100644
--- a/usr.bin/mandoc/mdoc_man.c
+++ b/usr.bin/mandoc/mdoc_man.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_man.c,v 1.72 2014/11/19 21:59:19 schwarze Exp $ */
+/* $OpenBSD: mdoc_man.c,v 1.73 2014/11/27 16:20:27 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -82,7 +82,7 @@ static int pre_dl(DECL_ARGS);
static int pre_en(DECL_ARGS);
static int pre_enc(DECL_ARGS);
static int pre_em(DECL_ARGS);
-static int pre_es(DECL_ARGS);
+static int pre_skip(DECL_ARGS);
static int pre_ex(DECL_ARGS);
static int pre_fa(DECL_ARGS);
static int pre_fd(DECL_ARGS);
@@ -181,7 +181,7 @@ static const struct manact manacts[MDOC_MAX + 1] = {
{ cond_body, pre_enc, post_enc, "[", "]" }, /* Bq */
{ NULL, pre_ux, NULL, "BSD/OS", NULL }, /* Bsx */
{ NULL, pre_bx, NULL, NULL, NULL }, /* Bx */
- { NULL, NULL, NULL, NULL, NULL }, /* Db */
+ { NULL, pre_skip, NULL, NULL, NULL }, /* Db */
{ NULL, NULL, NULL, NULL, NULL }, /* Dc */
{ cond_body, pre_enc, post_enc, "\\(lq", "\\(rq" }, /* Do */
{ cond_body, pre_enc, post_enc, "\\(lq", "\\(rq" }, /* Dq */
@@ -233,7 +233,7 @@ static const struct manact manacts[MDOC_MAX + 1] = {
{ cond_body, pre_enc, post_enc, "{", "}" }, /* Bro */
{ NULL, NULL, NULL, NULL, NULL }, /* Brc */
{ NULL, NULL, post_percent, NULL, NULL }, /* %C */
- { NULL, pre_es, NULL, NULL, NULL }, /* Es */
+ { NULL, pre_skip, NULL, NULL, NULL }, /* Es */
{ cond_body, pre_en, post_en, NULL, NULL }, /* En */
{ NULL, pre_ux, NULL, "DragonFly", NULL }, /* Dx */
{ NULL, NULL, post_percent, NULL, NULL }, /* %Q */
@@ -1130,13 +1130,6 @@ post_eo(DECL_ARGS)
}
static int
-pre_es(DECL_ARGS)
-{
-
- return(0);
-}
-
-static int
pre_fa(DECL_ARGS)
{
int am_Fa;
@@ -1676,6 +1669,13 @@ pre_rv(DECL_ARGS)
}
static int
+pre_skip(DECL_ARGS)
+{
+
+ return(0);
+}
+
+static int
pre_sm(DECL_ARGS)
{
diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c
index bfce12379e8..7ced72e6741 100644
--- a/usr.bin/mandoc/mdoc_term.c
+++ b/usr.bin/mandoc/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_term.c,v 1.192 2014/11/25 03:04:32 schwarze Exp $ */
+/* $OpenBSD: mdoc_term.c,v 1.193 2014/11/27 16:20:27 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -89,7 +89,6 @@ static int termp_bt_pre(DECL_ARGS);
static int termp_bx_pre(DECL_ARGS);
static int termp_cd_pre(DECL_ARGS);
static int termp_d1_pre(DECL_ARGS);
-static int termp_es_pre(DECL_ARGS);
static int termp_ex_pre(DECL_ARGS);
static int termp_fa_pre(DECL_ARGS);
static int termp_fd_pre(DECL_ARGS);
@@ -109,6 +108,7 @@ static int termp_quote_pre(DECL_ARGS);
static int termp_rs_pre(DECL_ARGS);
static int termp_rv_pre(DECL_ARGS);
static int termp_sh_pre(DECL_ARGS);
+static int termp_skip_pre(DECL_ARGS);
static int termp_sm_pre(DECL_ARGS);
static int termp_sp_pre(DECL_ARGS);
static int termp_ss_pre(DECL_ARGS);
@@ -181,7 +181,7 @@ static const struct termact termacts[MDOC_MAX] = {
{ termp_quote_pre, termp_quote_post }, /* Bq */
{ termp_xx_pre, NULL }, /* Bsx */
{ termp_bx_pre, NULL }, /* Bx */
- { NULL, NULL }, /* Db */
+ { termp_skip_pre, NULL }, /* Db */
{ NULL, NULL }, /* Dc */
{ termp_quote_pre, termp_quote_post }, /* Do */
{ termp_quote_pre, termp_quote_post }, /* Dq */
@@ -233,7 +233,7 @@ static const struct termact termacts[MDOC_MAX] = {
{ termp_quote_pre, termp_quote_post }, /* Bro */
{ NULL, NULL }, /* Brc */
{ NULL, termp____post }, /* %C */
- { termp_es_pre, NULL }, /* Es */
+ { termp_skip_pre, NULL }, /* Es */
{ termp_quote_pre, termp_quote_post }, /* En */
{ termp_xx_pre, NULL }, /* Dx */
{ NULL, termp____post }, /* %Q */
@@ -1836,7 +1836,7 @@ termp_sp_pre(DECL_ARGS)
}
static int
-termp_es_pre(DECL_ARGS)
+termp_skip_pre(DECL_ARGS)
{
return(0);
diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c
index 65ba914f69b..80dee7ea282 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.172 2014/11/26 19:23:47 schwarze Exp $ */
+/* $OpenBSD: mdoc_validate.c,v 1.173 2014/11/27 16:20:27 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -16,7 +16,6 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-
#include <sys/types.h>
#ifndef OSNAME
#include <sys/utsname.h>
@@ -71,7 +70,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);
@@ -121,6 +119,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);
@@ -198,7 +197,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 */
@@ -225,7 +224,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 */
@@ -1621,36 +1620,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));
}