diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-11-30 05:29:00 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-11-30 05:29:00 +0000 |
commit | e43c73ab8f3bb75f87f1c6bbba2b3ae2baad3cd3 (patch) | |
tree | 703bad3ba7634f8cdeb4be5d26ef773d373ea8c1 | |
parent | 672fb7896ca2c19f7313864be8ddba51337a45c0 (diff) | |
download | mandoc-e43c73ab8f3bb75f87f1c6bbba2b3ae2baad3cd3.tar.gz |
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.1 | 8 | ||||
-rw-r--r-- | mandoc.h | 1 | ||||
-rw-r--r-- | mdoc_html.c | 3 | ||||
-rw-r--r-- | mdoc_macro.c | 22 | ||||
-rw-r--r-- | mdoc_man.c | 3 | ||||
-rw-r--r-- | mdoc_term.c | 3 | ||||
-rw-r--r-- | mdoc_validate.c | 2 | ||||
-rw-r--r-- | read.c | 1 |
8 files changed, 33 insertions, 10 deletions
@@ -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 @@ -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 ed589127..fe333655 100644 --- a/mdoc_html.c +++ b/mdoc_html.c @@ -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 8554c2d4..6d1556b4 100644 --- a/mdoc_macro.c +++ b/mdoc_macro.c @@ -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) @@ -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 be0a2ab0..4b4d12d9 100644 --- a/mdoc_term.c +++ b/mdoc_term.c @@ -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 18946b52..88ee2537 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -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 */ @@ -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 \"\"", |