aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-11-30 05:29:00 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-11-30 05:29:00 +0000
commit6f59b6b73c064f18c6d34aa05adf831fee5a9350 (patch)
tree7470dd9d286ae7b220879cc6ca3ee5160e89ca60
parent09af02110fb2332decede6c59de9e177433c15d7 (diff)
downloadmandoc-6f59b6b73c064f18c6d34aa05adf831fee5a9350.tar.gz
mandoc-6f59b6b73c064f18c6d34aa05adf831fee5a9350.tar.zst
mandoc-6f59b6b73c064f18c6d34aa05adf831fee5a9350.zip
Multiple fixes with respect to .Pf:
* The first argument of .Pf is not parsed. * Normal delimiter handling does not apply to the first argument of .Pf. * Warn if nothing follows a prefix (inspired by groff_mdoc(7)). * In that case, do not suppress spacing.
-rw-r--r--mandoc.110
-rw-r--r--mandoc.h3
-rw-r--r--mdoc_html.c5
-rw-r--r--mdoc_macro.c24
-rw-r--r--mdoc_man.c5
-rw-r--r--mdoc_term.c5
-rw-r--r--mdoc_validate.c4
-rw-r--r--read.c3
8 files changed, 41 insertions, 18 deletions
diff --git a/mandoc.1 b/mandoc.1
index 7f8b9863..5387ec83 100644
--- a/mandoc.1
+++ b/mandoc.1
@@ -1,4 +1,4 @@
-.\" $Id: mandoc.1,v 1.126 2014/11/30 02:36:38 schwarze Exp $
+.\" $Id: mandoc.1,v 1.127 2014/11/30 05:29:00 schwarze Exp $
.\"
.\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2012, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -1054,6 +1054,14 @@ argument is invalid.
The default font
.Cm \efR
is used instead.
+.It Sy "nothing follows prefix"
+.Pq mdoc
+A
+.Ic \&Pf
+macro has no argument, or only one argument and no macro follows
+on the same input line.
+This defeats its purpose; in particular, spacing is not suppressed
+before the text or macros following on the next input line.
.It Sy "missing -std argument, adding it"
.Pq mdoc
An
diff --git a/mandoc.h b/mandoc.h
index cc421ad3..3e3ba063 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -1,4 +1,4 @@
-/* $Id: mandoc.h,v 1.172 2014/11/30 02:36:38 schwarze Exp $ */
+/* $Id: mandoc.h,v 1.173 2014/11/30 05:29:00 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -103,6 +103,7 @@ enum mandocerr {
MANDOCERR_IT_NOBODY, /* empty list item: Bl -type It */
MANDOCERR_BF_NOFONT, /* missing font type, using \fR: Bf */
MANDOCERR_BF_BADFONT, /* unknown font type, using \fR: Bf font */
+ MANDOCERR_PF_SKIP, /* nothing follows prefix: Pf arg */
MANDOCERR_ARG_STD, /* missing -std argument, adding it: macro */
MANDOCERR_EQN_NOBOX, /* missing eqn box, using "": op */
diff --git a/mdoc_html.c b/mdoc_html.c
index 0cd3cf01..dd1d9970 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_html.c,v 1.213 2014/11/27 22:27:56 schwarze Exp $ */
+/* $Id: mdoc_html.c,v 1.214 2014/11/30 05:29:00 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -1869,7 +1869,8 @@ static void
mdoc_pf_post(MDOC_ARGS)
{
- h->flags |= HTML_NOSPACE;
+ if ( ! (n->next == NULL || n->next->flags & MDOC_LINE))
+ h->flags |= HTML_NOSPACE;
}
static int
diff --git a/mdoc_macro.c b/mdoc_macro.c
index c2156bf5..68b6a129 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_macro.c,v 1.155 2014/11/30 02:36:38 schwarze Exp $ */
+/* $Id: mdoc_macro.c,v 1.156 2014/11/30 05:29:00 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -1396,7 +1396,7 @@ in_line_argn(MACRO_PROT_ARGS)
char *p;
enum mdoct ntok;
- nl = MDOC_NEWLINE & mdoc->flags;
+ nl = mdoc->flags & MDOC_NEWLINE;
/*
* A line macro that has a fixed number of arguments (maxargs).
@@ -1428,11 +1428,18 @@ in_line_argn(MACRO_PROT_ARGS)
mdoc_argv(mdoc, line, tok, &arg, pos, buf);
- for (flushed = j = 0; ; ) {
+ p = NULL;
+ flushed = j = 0;
+ for (;;) {
la = *pos;
ac = mdoc_args(mdoc, line, pos, buf, tok, &p);
- if (ac == ARGS_PUNCT || ac == ARGS_EOLN)
+ if (ac == ARGS_PUNCT || ac == ARGS_EOLN) {
+ if (j < 2 && tok == MDOC_Pf)
+ mandoc_vmsg(MANDOCERR_PF_SKIP,
+ mdoc->parse, line, ppos, "Pf %s",
+ p == NULL ? "at eol" : p);
break;
+ }
if ( ! (mdoc_macros[tok].flags & MDOC_IGNDELIM) &&
ac != ARGS_QWORD && j == 0 &&
@@ -1447,8 +1454,8 @@ in_line_argn(MACRO_PROT_ARGS)
flushed = 1;
}
- ntok = ac == ARGS_QWORD ? MDOC_MAX :
- lookup(mdoc, tok, line, la, p);
+ ntok = (ac == ARGS_QWORD || (tok == MDOC_Pf && j == 0)) ?
+ MDOC_MAX : lookup(mdoc, tok, line, la, p);
if (ntok != MDOC_MAX) {
if ( ! flushed)
@@ -1471,8 +1478,11 @@ in_line_argn(MACRO_PROT_ARGS)
j++;
}
- if (j == 0)
+ if (j == 0) {
mdoc_elem_alloc(mdoc, line, ppos, tok, arg);
+ if (ac == ARGS_PUNCT && tok == MDOC_Pf)
+ append_delims(mdoc, line, pos, buf);
+ }
if ( ! flushed)
rew_elem(mdoc, tok);
if (nl)
diff --git a/mdoc_man.c b/mdoc_man.c
index 41cc65b5..974cfbd4 100644
--- a/mdoc_man.c
+++ b/mdoc_man.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_man.c,v 1.76 2014/11/27 22:27:56 schwarze Exp $ */
+/* $Id: mdoc_man.c,v 1.77 2014/11/30 05:29:00 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -1602,7 +1602,8 @@ static void
post_pf(DECL_ARGS)
{
- outflags &= ~MMAN_spc;
+ if ( ! (n->next == NULL || n->next->flags & MDOC_LINE))
+ outflags &= ~MMAN_spc;
}
static int
diff --git a/mdoc_term.c b/mdoc_term.c
index dcc2682f..5caa9717 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.297 2014/11/28 16:54:23 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.298 2014/11/30 05:29:00 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -1734,7 +1734,8 @@ static void
termp_pf_post(DECL_ARGS)
{
- p->flags |= TERMP_NOSPACE;
+ if ( ! (n->next == NULL || n->next->flags & MDOC_LINE))
+ p->flags |= TERMP_NOSPACE;
}
static int
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 5a07af3e..7990ffe9 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.262 2014/11/28 18:36:35 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.263 2014/11/30 05:29:00 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -210,7 +210,7 @@ static const struct valids mdoc_valids[MDOC_MAX] = {
{ NULL, NULL }, /* Nx */
{ NULL, NULL }, /* Ox */
{ NULL, NULL }, /* Pc */
- { NULL, ewarn_eq1 }, /* Pf */
+ { NULL, NULL }, /* Pf */
{ NULL, NULL }, /* Po */
{ NULL, NULL }, /* Pq */
{ NULL, NULL }, /* Qc */
diff --git a/read.c b/read.c
index ec2d6871..f4c1eb90 100644
--- a/read.c
+++ b/read.c
@@ -1,4 +1,4 @@
-/* $Id: read.c,v 1.102 2014/11/30 02:36:38 schwarze Exp $ */
+/* $Id: read.c,v 1.103 2014/11/30 05:29:00 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -146,6 +146,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"empty list item",
"missing font type, using \\fR",
"unknown font type, using \\fR",
+ "nothing follows prefix",
"missing -std argument, adding it",
"missing eqn box, using \"\"",