summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mandoc.18
-rw-r--r--mandoc.h1
-rw-r--r--mdoc_macro.c6
-rw-r--r--mdoc_man.c7
-rw-r--r--mdoc_validate.c33
-rw-r--r--read.c1
6 files changed, 42 insertions, 14 deletions
diff --git a/mandoc.1 b/mandoc.1
index 86170cb5..e8e97336 100644
--- a/mandoc.1
+++ b/mandoc.1
@@ -1042,6 +1042,12 @@ The
macro is called without an argument before
.Ic \&Nm
has first been called with an argument.
+.It Sy "missing function name, using \(dq\(dq"
+.Pq mdoc
+The
+.Ic \&Fo
+macro is called without an argument.
+No function name is printed.
.It Sy "empty head in list item"
.Pq mdoc
In a
@@ -1637,6 +1643,8 @@ macro is invoked with another argument after
.Fl split
or
.Fl nosplit ,
+.Ic \&Fo
+is invoked with more than one argument,
.Ic \&Bd ,
.Ic \&Bk ,
or
diff --git a/mandoc.h b/mandoc.h
index 0be99722..9d365cb3 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -98,6 +98,7 @@ enum mandocerr {
MANDOCERR_BL_LATETYPE, /* list type is not the first argument: Bl arg */
MANDOCERR_BL_NOWIDTH, /* missing -width in -tag list, using 8n */
MANDOCERR_EX_NONAME, /* missing utility name, using "": Ex */
+ MANDOCERR_FO_NOHEAD, /* missing function name, using "": Fo */
MANDOCERR_IT_NOHEAD, /* empty head in list item: Bl -type It */
MANDOCERR_IT_NOBODY, /* empty list item: Bl -type It */
MANDOCERR_BF_NOFONT, /* missing font type, using \fR: Bf */
diff --git a/mdoc_macro.c b/mdoc_macro.c
index dc710030..c22e61a1 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -1403,6 +1403,12 @@ in_line_eoln(MACRO_PROT_ARGS)
rew_last(mdoc, mdoc->last->parent);
}
+ if (buf[*pos] == '\0' && tok == MDOC_Fd) {
+ mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse,
+ line, ppos, "Fd");
+ return;
+ }
+
mdoc_argv(mdoc, line, tok, &arg, pos, buf);
mdoc_elem_alloc(mdoc, line, ppos, tok, arg);
if (parse_rest(mdoc, tok, line, pos, buf))
diff --git a/mdoc_man.c b/mdoc_man.c
index 131e1f3f..ad3fc626 100644
--- a/mdoc_man.c
+++ b/mdoc_man.c
@@ -1284,12 +1284,14 @@ pre_fo(DECL_ARGS)
pre_syn(n);
break;
case MDOC_HEAD:
+ if (n->child == NULL)
+ return(0);
if (MDOC_SYNPRETTY & n->flags)
print_block(".HP 4n", MMAN_nl);
font_push('B');
break;
case MDOC_BODY:
- outflags &= ~MMAN_spc;
+ outflags &= ~(MMAN_spc | MMAN_nl);
print_word("(");
outflags &= ~MMAN_spc;
break;
@@ -1305,7 +1307,8 @@ post_fo(DECL_ARGS)
switch (n->type) {
case MDOC_HEAD:
- font_pop();
+ if (n->child != NULL)
+ font_pop();
break;
case MDOC_BODY:
post_fn(meta, n);
diff --git a/mdoc_validate.c b/mdoc_validate.c
index cf7358bf..b554a9bb 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -67,7 +67,6 @@ static enum mdoc_sec a2sec(const char *);
static size_t macro2len(enum mdoct);
static void rewrite_macro2len(char **);
-static void bwarn_ge1(POST_ARGS);
static void ewarn_eq1(POST_ARGS);
static void ewarn_ge1(POST_ARGS);
@@ -151,7 +150,7 @@ static const struct valids mdoc_valids[MDOC_MAX] = {
{ NULL, NULL }, /* Ev */
{ pre_std, post_ex }, /* Ex */
{ NULL, post_fa }, /* Fa */
- { NULL, ewarn_ge1 }, /* Fd */
+ { NULL, NULL }, /* Fd */
{ NULL, NULL }, /* Fl */
{ NULL, post_fn }, /* Fn */
{ NULL, NULL }, /* Ft */
@@ -402,12 +401,6 @@ check_count(struct mdoc *mdoc, enum mdoc_type type,
}
static void
-bwarn_ge1(POST_ARGS)
-{
- check_count(mdoc, MDOC_BODY, CHECK_GT, 0);
-}
-
-static void
ewarn_eq1(POST_ARGS)
{
check_count(mdoc, MDOC_ELEM, CHECK_EQ, 1);
@@ -980,11 +973,27 @@ post_fn(POST_ARGS)
static void
post_fo(POST_ARGS)
{
+ const struct mdoc_node *n;
+
+ n = mdoc->last;
+
+ if (n->type != MDOC_HEAD)
+ return;
+
+ if (n->child == NULL) {
+ mandoc_msg(MANDOCERR_FO_NOHEAD, mdoc->parse,
+ n->line, n->pos, "Fo");
+ return;
+ }
+ if (n->child != n->last) {
+ mandoc_vmsg(MANDOCERR_ARG_EXCESS, mdoc->parse,
+ n->child->next->line, n->child->next->pos,
+ "Fo ... %s", n->child->next->string);
+ while (n->child != n->last)
+ mdoc_node_delete(mdoc, n->last);
+ }
- check_count(mdoc, MDOC_HEAD, CHECK_EQ, 1);
- bwarn_ge1(mdoc);
- if (mdoc->last->type == MDOC_HEAD && mdoc->last->nchild)
- post_fname(mdoc);
+ post_fname(mdoc);
}
static void
diff --git a/read.c b/read.c
index 7126c76d..b1991bec 100644
--- a/read.c
+++ b/read.c
@@ -142,6 +142,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"list type is not the first argument",
"missing -width in -tag list, using 8n",
"missing utility name, using \"\"",
+ "missing function name, using \"\"",
"empty head in list item",
"empty list item",
"missing font type, using \\fR",