aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-11-30 02:36:38 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-11-30 02:36:38 +0000
commit09af02110fb2332decede6c59de9e177433c15d7 (patch)
tree5c9e42c7d9eb47c69177aeb4177861bba1945485
parent929d6892d847e3b8dbd10eb1d45d0699169185ad (diff)
downloadmandoc-09af02110fb2332decede6c59de9e177433c15d7.tar.gz
mandoc-09af02110fb2332decede6c59de9e177433c15d7.tar.zst
mandoc-09af02110fb2332decede6c59de9e177433c15d7.zip
warn about attempts to call non-callable macros;
inspired by a similar warning in the groff_mdoc(7) macros
-rw-r--r--mandoc.111
-rw-r--r--mandoc.h3
-rw-r--r--mdoc_macro.c26
-rw-r--r--read.c3
4 files changed, 30 insertions, 13 deletions
diff --git a/mandoc.1 b/mandoc.1
index 9f2d6ba7..7f8b9863 100644
--- a/mandoc.1
+++ b/mandoc.1
@@ -1,4 +1,4 @@
-.\" $Id: mandoc.1,v 1.125 2014/11/28 18:09:01 schwarze Exp $
+.\" $Id: mandoc.1,v 1.126 2014/11/30 02:36:38 schwarze Exp $
.\"
.\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2012, 2014 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 28 2014 $
+.Dd $Mdocdate: November 30 2014 $
.Dt MANDOC 1
.Os
.Sh NAME
@@ -803,6 +803,13 @@ Probably, there are author names lacking markup.
See the
.Xr mdoc 7
manual for replacements.
+.It Sy "macro neither callable nor escaped"
+.Pq mdoc
+The name of a macro that is not callable appears on a macro line.
+It is printed verbatim.
+If the intention is to call it, move it to its own line;
+otherwise, escape it by prepending
+.Sq \e& .
.It Sy "skipping paragraph macro"
In
.Xr mdoc 7
diff --git a/mandoc.h b/mandoc.h
index 98578ed4..cc421ad3 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -1,4 +1,4 @@
-/* $Id: mandoc.h,v 1.171 2014/11/28 18:09:01 schwarze Exp $ */
+/* $Id: mandoc.h,v 1.172 2014/11/30 02:36:38 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -77,6 +77,7 @@ enum mandocerr {
/* related to macros and nesting */
MANDOCERR_MACRO_OBS, /* obsolete macro: macro */
+ MANDOCERR_MACRO_CALL, /* macro neither callable nor escaped: macro */
MANDOCERR_PAR_SKIP, /* skipping paragraph macro: macro ... */
MANDOCERR_PAR_MOVE, /* moving paragraph macro out of list: macro */
MANDOCERR_NS_SKIP, /* skipping no-space macro */
diff --git a/mdoc_macro.c b/mdoc_macro.c
index b501d4d6..c2156bf5 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_macro.c,v 1.154 2014/11/29 04:31:35 schwarze Exp $ */
+/* $Id: mdoc_macro.c,v 1.155 2014/11/30 02:36:38 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -53,7 +53,8 @@ static void phrase_ta(MACRO_PROT_ARGS);
static void dword(struct mdoc *, int, int, const char *,
enum mdelim, int);
static void append_delims(struct mdoc *, int, int *, char *);
-static enum mdoct lookup(enum mdoct, const char *);
+static enum mdoct lookup(struct mdoc *, enum mdoct,
+ int, int, const char *);
static int macro_or_word(MACRO_PROT_ARGS, int);
static int make_pending(struct mdoc_node *, enum mdoct,
struct mdoc *, int, int);
@@ -245,14 +246,19 @@ mdoc_macroend(struct mdoc *mdoc)
* or as a line macro if from == MDOC_MAX.
*/
static enum mdoct
-lookup(enum mdoct from, const char *p)
+lookup(struct mdoc *mdoc, enum mdoct from, int line, int ppos, const char *p)
{
enum mdoct res;
if (from == MDOC_MAX || mdoc_macros[from].flags & MDOC_PARSED) {
res = mdoc_hash_find(p);
- if (res != MDOC_MAX && mdoc_macros[res].flags & MDOC_CALLABLE)
- return(res);
+ if (res != MDOC_MAX) {
+ if (mdoc_macros[res].flags & MDOC_CALLABLE)
+ return(res);
+ if (res != MDOC_br && res != MDOC_sp && res != MDOC_ll)
+ mandoc_msg(MANDOCERR_MACRO_CALL,
+ mdoc->parse, line, ppos, p);
+ }
}
return(MDOC_MAX);
}
@@ -671,7 +677,7 @@ macro_or_word(MACRO_PROT_ARGS, int parsed)
else if (*p == '"')
p++;
else if (parsed)
- ntok = lookup(tok, p);
+ ntok = lookup(mdoc, tok, line, ppos, p);
if (ntok == MDOC_MAX) {
dword(mdoc, line, ppos, p, DELIM_MAX, tok == MDOC_MAX ||
@@ -832,7 +838,8 @@ blk_exp_close(MACRO_PROT_ARGS)
if (ac == ARGS_PUNCT || ac == ARGS_EOLN)
break;
- ntok = ac == ARGS_QWORD ? MDOC_MAX : lookup(tok, p);
+ ntok = ac == ARGS_QWORD ? MDOC_MAX :
+ lookup(mdoc, tok, line, lastarg, p);
if (ntok == MDOC_MAX) {
dword(mdoc, line, lastarg, p, DELIM_MAX,
@@ -933,7 +940,7 @@ in_line(MACRO_PROT_ARGS)
}
ntok = (ac == ARGS_QWORD || (tok == MDOC_Fn && !cnt)) ?
- MDOC_MAX : lookup(tok, p);
+ MDOC_MAX : lookup(mdoc, tok, line, la, p);
/*
* In this case, we've located a submacro and must
@@ -1440,7 +1447,8 @@ in_line_argn(MACRO_PROT_ARGS)
flushed = 1;
}
- ntok = ac == ARGS_QWORD ? MDOC_MAX : lookup(tok, p);
+ ntok = ac == ARGS_QWORD ? MDOC_MAX :
+ lookup(mdoc, tok, line, la, p);
if (ntok != MDOC_MAX) {
if ( ! flushed)
diff --git a/read.c b/read.c
index 96444f59..ec2d6871 100644
--- a/read.c
+++ b/read.c
@@ -1,4 +1,4 @@
-/* $Id: read.c,v 1.101 2014/11/28 18:09:01 schwarze Exp $ */
+/* $Id: read.c,v 1.102 2014/11/30 02:36:38 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -120,6 +120,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
/* related to macros and nesting */
"obsolete macro",
+ "macro neither callable nor escaped",
"skipping paragraph macro",
"moving paragraph macro out of list",
"skipping no-space macro",