aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-02-06 03:38:45 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-02-06 03:38:45 +0000
commit7dfe6b3fdffd0ff76af3e3d347b0f300fddb15e8 (patch)
treec8da2ede0eced598b1c3160a92a64f654f8225ca
parent21214100bde85df055d67a3ab4b9c51b8a2dd7fb (diff)
downloadmandoc-7dfe6b3fdffd0ff76af3e3d347b0f300fddb15e8.tar.gz
mandoc-7dfe6b3fdffd0ff76af3e3d347b0f300fddb15e8.tar.zst
mandoc-7dfe6b3fdffd0ff76af3e3d347b0f300fddb15e8.zip
better handle .Fo and .Fd without argument
better handle .Fo with more than one argument
-rw-r--r--mandoc.112
-rw-r--r--mandoc.h3
-rw-r--r--mdoc_macro.c8
-rw-r--r--mdoc_man.c9
-rw-r--r--mdoc_validate.c35
-rw-r--r--read.c3
6 files changed, 49 insertions, 21 deletions
diff --git a/mandoc.1 b/mandoc.1
index 2a542d9f..3e2a2d06 100644
--- a/mandoc.1
+++ b/mandoc.1
@@ -1,4 +1,4 @@
-.\" $Id: mandoc.1,v 1.145 2015/02/04 22:30:10 schwarze Exp $
+.\" $Id: mandoc.1,v 1.146 2015/02/06 03:38:45 schwarze Exp $
.\"
.\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2012, 2014, 2015 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: February 4 2015 $
+.Dd $Mdocdate: February 6 2015 $
.Dt MANDOC 1
.Os
.Sh NAME
@@ -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 aaa24114..5fbc6871 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -1,4 +1,4 @@
-/* $Id: mandoc.h,v 1.196 2015/02/04 18:03:47 schwarze Exp $ */
+/* $Id: mandoc.h,v 1.197 2015/02/06 03:38:45 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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 8bc79919..18f1df58 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_macro.c,v 1.177 2015/02/06 01:07:22 schwarze Exp $ */
+/* $Id: mdoc_macro.c,v 1.178 2015/02/06 03:38:45 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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 2be9945e..eee1e3a7 100644
--- a/mdoc_man.c
+++ b/mdoc_man.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_man.c,v 1.84 2015/02/01 23:10:35 schwarze Exp $ */
+/* $Id: mdoc_man.c,v 1.85 2015/02/06 03:38:45 schwarze Exp $ */
/*
* Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -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 f399e868..cd666b5a 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.273 2015/02/06 02:04:54 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.274 2015/02/06 03:38:45 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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 9027bb94..560e6fdd 100644
--- a/read.c
+++ b/read.c
@@ -1,4 +1,4 @@
-/* $Id: read.c,v 1.122 2015/02/04 18:03:48 schwarze Exp $ */
+/* $Id: read.c,v 1.123 2015/02/06 03:38:45 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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",