aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_macro.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2018-12-14 05:18:02 +0000
committerIngo Schwarze <schwarze@openbsd.org>2018-12-14 05:18:02 +0000
commit7a6eb8920bdea2ecc151b308352b2a98699b2350 (patch)
tree9860a766930f3997c413b0f0aecd6ba815b80f25 /mdoc_macro.c
parent0ef6626fcc16277d2fefb32e1830dfba3df5defd (diff)
downloadmandoc-7a6eb8920bdea2ecc151b308352b2a98699b2350.tar.gz
mandoc-7a6eb8920bdea2ecc151b308352b2a98699b2350.tar.zst
mandoc-7a6eb8920bdea2ecc151b308352b2a98699b2350.zip
Almost mechanical diff to remove the "struct mparse *" argument
from mandoc_msg(), where it is no longer used. While here, rename mandoc_vmsg() to mandoc_msg() and retire the old version: There is really no point in having another function merely to save "%s" in a few places. Minus 140 lines of code.
Diffstat (limited to 'mdoc_macro.c')
-rw-r--r--mdoc_macro.c75
1 files changed, 33 insertions, 42 deletions
diff --git a/mdoc_macro.c b/mdoc_macro.c
index 31a70896..4cb69976 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_macro.c,v 1.226 2018/12/04 02:53:51 schwarze Exp $ */
+/* $Id: mdoc_macro.c,v 1.227 2018/12/14 05:18:02 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -228,8 +228,8 @@ mdoc_endparse(struct roff_man *mdoc)
for ( ; n; n = n->parent)
if (n->type == ROFFT_BLOCK &&
mdoc_macro(n->tok)->flags & MDOC_EXPLICIT)
- mandoc_msg(MANDOCERR_BLK_NOEND, mdoc->parse,
- n->line, n->pos, roff_name[n->tok]);
+ mandoc_msg(MANDOCERR_BLK_NOEND,
+ n->line, n->pos, "%s", roff_name[n->tok]);
/* Rewind to the first. */
@@ -255,8 +255,7 @@ lookup(struct roff_man *mdoc, int from, int line, int ppos, const char *p)
if (res != TOKEN_NONE) {
if (mdoc_macro(res)->flags & MDOC_CALLABLE)
return res;
- mandoc_msg(MANDOCERR_MACRO_CALL,
- mdoc->parse, line, ppos, p);
+ mandoc_msg(MANDOCERR_MACRO_CALL, line, ppos, "%s", p);
}
}
return TOKEN_NONE;
@@ -421,10 +420,9 @@ find_pending(struct roff_man *mdoc, enum roff_tok tok, int line, int ppos,
if (target->type == ROFFT_HEAD)
target->flags |= NODE_ENDED;
else if ( ! (target->flags & NODE_ENDED)) {
- mandoc_vmsg(MANDOCERR_BLK_NEST,
- mdoc->parse, line, ppos,
- "%s breaks %s", roff_name[tok],
- roff_name[n->tok]);
+ mandoc_msg(MANDOCERR_BLK_NEST,
+ line, ppos, "%s breaks %s",
+ roff_name[tok], roff_name[n->tok]);
mdoc_endbody_alloc(mdoc, line, ppos,
tok, target);
}
@@ -635,7 +633,7 @@ blk_exp_close(MACRO_PROT_ARGS)
* the scope - of the current block ends.
*/
- mandoc_vmsg(MANDOCERR_BLK_NEST, mdoc->parse,
+ mandoc_msg(MANDOCERR_BLK_NEST,
line, ppos, "%s breaks %s",
roff_name[atok], roff_name[later->tok]);
@@ -678,8 +676,8 @@ blk_exp_close(MACRO_PROT_ARGS)
}
if (body == NULL) {
- mandoc_msg(MANDOCERR_BLK_NOTOPEN, mdoc->parse,
- line, ppos, roff_name[tok]);
+ mandoc_msg(MANDOCERR_BLK_NOTOPEN, line, ppos,
+ "%s", roff_name[tok]);
if (maxargs && endbody == NULL) {
/*
* Stray .Ec without previous .Eo:
@@ -696,10 +694,8 @@ blk_exp_close(MACRO_PROT_ARGS)
if ((mdoc_macro(tok)->flags & MDOC_PARSED) == 0) {
if (buf[*pos] != '\0')
- mandoc_vmsg(MANDOCERR_ARG_SKIP,
- mdoc->parse, line, ppos,
- "%s %s", roff_name[tok],
- buf + *pos);
+ mandoc_msg(MANDOCERR_ARG_SKIP, line, ppos,
+ "%s %s", roff_name[tok], buf + *pos);
if (endbody == NULL && n != NULL)
rew_pending(mdoc, n);
return;
@@ -834,8 +830,7 @@ in_line(MACRO_PROT_ARGS)
} else if ( ! nc && ! cnt) {
mdoc_argv_free(arg);
mandoc_msg(MANDOCERR_MACRO_EMPTY,
- mdoc->parse, line, ppos,
- roff_name[tok]);
+ line, ppos, "%s", roff_name[tok]);
}
(*mdoc_macro(ntok)->fp)(mdoc, ntok,
line, la, pos, buf);
@@ -921,8 +916,8 @@ in_line(MACRO_PROT_ARGS)
rew_last(mdoc, mdoc->last);
} else {
mdoc_argv_free(arg);
- mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse,
- line, ppos, roff_name[tok]);
+ mandoc_msg(MANDOCERR_MACRO_EMPTY,
+ line, ppos, "%s", roff_name[tok]);
}
}
if (nl)
@@ -946,8 +941,8 @@ blk_full(MACRO_PROT_ARGS)
nl = MDOC_NEWLINE & mdoc->flags;
if (buf[*pos] == '\0' && (tok == MDOC_Sh || tok == MDOC_Ss)) {
- mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse,
- line, ppos, roff_name[tok]);
+ mandoc_msg(MANDOCERR_MACRO_EMPTY,
+ line, ppos, "%s", roff_name[tok]);
return;
}
@@ -967,9 +962,8 @@ blk_full(MACRO_PROT_ARGS)
if (tok == MDOC_It && n->tok == MDOC_Bl) {
if (blk != NULL) {
- mandoc_vmsg(MANDOCERR_BLK_BROKEN,
- mdoc->parse, line, ppos,
- "It breaks %s",
+ mandoc_msg(MANDOCERR_BLK_BROKEN,
+ line, ppos, "It breaks %s",
roff_name[blk->tok]);
rew_pending(mdoc, blk);
}
@@ -980,8 +974,8 @@ blk_full(MACRO_PROT_ARGS)
switch (tok) {
case MDOC_Sh:
case MDOC_Ss:
- mandoc_vmsg(MANDOCERR_BLK_BROKEN,
- mdoc->parse, line, ppos,
+ mandoc_msg(MANDOCERR_BLK_BROKEN,
+ line, ppos,
"%s breaks %s", roff_name[tok],
roff_name[n->tok]);
rew_pending(mdoc, n);
@@ -1007,8 +1001,7 @@ blk_full(MACRO_PROT_ARGS)
/* Item breaking an explicit block. */
if (blk != NULL) {
- mandoc_vmsg(MANDOCERR_BLK_BROKEN,
- mdoc->parse, line, ppos,
+ mandoc_msg(MANDOCERR_BLK_BROKEN, line, ppos,
"It breaks %s", roff_name[blk->tok]);
rew_pending(mdoc, blk);
blk = NULL;
@@ -1022,7 +1015,7 @@ blk_full(MACRO_PROT_ARGS)
/* Skip items outside lists. */
if (tok == MDOC_It && (n == NULL || n->tok != MDOC_Bl)) {
- mandoc_vmsg(MANDOCERR_IT_STRAY, mdoc->parse,
+ mandoc_msg(MANDOCERR_IT_STRAY,
line, ppos, "It %s", buf + *pos);
roff_elem_alloc(mdoc, line, ppos, ROFF_br);
rew_elem(mdoc, ROFF_br);
@@ -1100,13 +1093,12 @@ blk_full(MACRO_PROT_ARGS)
}
if (tok == MDOC_Bd || tok == MDOC_Bk) {
- mandoc_vmsg(MANDOCERR_ARG_EXCESS,
- mdoc->parse, line, la, "%s ... %s",
- roff_name[tok], buf + la);
+ mandoc_msg(MANDOCERR_ARG_EXCESS, line, la,
+ "%s ... %s", roff_name[tok], buf + la);
break;
}
if (tok == MDOC_Rs) {
- mandoc_vmsg(MANDOCERR_ARG_SKIP, mdoc->parse,
+ mandoc_msg(MANDOCERR_ARG_SKIP,
line, la, "Rs %s", buf + la);
break;
}
@@ -1360,8 +1352,8 @@ in_line_argn(MACRO_PROT_ARGS)
if (ac == ARGS_PUNCT || ac == ARGS_EOLN) {
if (abs(state) < 2 && tok == MDOC_Pf)
- mandoc_vmsg(MANDOCERR_PF_SKIP,
- mdoc->parse, line, ppos, "Pf %s",
+ mandoc_msg(MANDOCERR_PF_SKIP,
+ line, ppos, "Pf %s",
p == NULL ? "at eol" : p);
break;
}
@@ -1401,8 +1393,8 @@ in_line_argn(MACRO_PROT_ARGS)
}
if (state == -1) {
- mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse,
- line, ppos, roff_name[tok]);
+ mandoc_msg(MANDOCERR_MACRO_EMPTY,
+ line, ppos, "%s", roff_name[tok]);
return;
}
@@ -1431,8 +1423,8 @@ in_line_eoln(MACRO_PROT_ARGS)
if (buf[*pos] == '\0' &&
(tok == MDOC_Fd || *roff_name[tok] == '%')) {
- mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse,
- line, ppos, roff_name[tok]);
+ mandoc_msg(MANDOCERR_MACRO_EMPTY,
+ line, ppos, "%s", roff_name[tok]);
return;
}
@@ -1500,8 +1492,7 @@ phrase_ta(MACRO_PROT_ARGS)
}
if (n == NULL || n->norm->Bl.type != LIST_column) {
- mandoc_msg(MANDOCERR_TA_STRAY, mdoc->parse,
- line, ppos, "Ta");
+ mandoc_msg(MANDOCERR_TA_STRAY, line, ppos, "Ta");
return;
}