From ae5f77f4afb4eacc8500ded5455086d6242ae946 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Thu, 27 Nov 2014 16:20:31 +0000 Subject: 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. --- mdoc.7 | 17 ++++++++--------- mdoc_html.c | 4 ++-- mdoc_man.c | 22 +++++++++++----------- mdoc_term.c | 10 +++++----- mdoc_validate.c | 31 +++++++++++++------------------ 5 files changed, 39 insertions(+), 45 deletions(-) diff --git a/mdoc.7 b/mdoc.7 index 9f3ca835..e69bb9f7 100644 --- a/mdoc.7 +++ b/mdoc.7 @@ -1,4 +1,4 @@ -.\" $Id: mdoc.7,v 1.241 2014/11/16 20:46:21 schwarze Exp $ +.\" $Id: mdoc.7,v 1.242 2014/11/27 16:20:31 schwarze Exp $ .\" .\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons .\" Copyright (c) 2010, 2011, 2013 Ingo Schwarze @@ -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/mdoc_html.c b/mdoc_html.c index eed9b048..ff388f37 100644 --- a/mdoc_html.c +++ b/mdoc_html.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_html.c,v 1.211 2014/11/19 22:00:37 schwarze Exp $ */ +/* $Id: mdoc_html.c,v 1.212 2014/11/27 16:20:31 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons * Copyright (c) 2014 Ingo Schwarze @@ -183,7 +183,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/mdoc_man.c b/mdoc_man.c index 75b68e62..33e8b2cb 100644 --- a/mdoc_man.c +++ b/mdoc_man.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_man.c,v 1.74 2014/11/19 22:00:37 schwarze Exp $ */ +/* $Id: mdoc_man.c,v 1.75 2014/11/27 16:20:31 schwarze Exp $ */ /* * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze * @@ -84,7 +84,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); @@ -183,7 +183,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 */ @@ -235,7 +235,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 */ @@ -1131,13 +1131,6 @@ post_eo(DECL_ARGS) outflags &= ~MMAN_spc; } -static int -pre_es(DECL_ARGS) -{ - - return(0); -} - static int pre_fa(DECL_ARGS) { @@ -1677,6 +1670,13 @@ pre_rv(DECL_ARGS) return(0); } +static int +pre_skip(DECL_ARGS) +{ + + return(0); +} + static int pre_sm(DECL_ARGS) { diff --git a/mdoc_term.c b/mdoc_term.c index f1825ccd..08a32850 100644 --- a/mdoc_term.c +++ b/mdoc_term.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.293 2014/11/25 20:00:01 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.294 2014/11/27 16:20:31 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze @@ -91,7 +91,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); @@ -111,6 +110,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); @@ -183,7 +183,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 */ @@ -235,7 +235,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 */ @@ -1838,7 +1838,7 @@ termp_sp_pre(DECL_ARGS) } static int -termp_es_pre(DECL_ARGS) +termp_skip_pre(DECL_ARGS) { return(0); 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 * Copyright (c) 2010-2014 Ingo Schwarze @@ -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)); } -- cgit v1.2.3-56-ge451