diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2014-11-30 05:28:01 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2014-11-30 05:28:01 +0000 |
commit | ae7a1edb9b7094b78fbc29671190434f22ead171 (patch) | |
tree | 6e04f9884716dea0d5e30cd462825192c09e357b /usr.bin/mandoc | |
parent | 3e6359e77ebd9c03667280d19252ee5a21567d3d (diff) |
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.
Diffstat (limited to 'usr.bin/mandoc')
-rw-r--r-- | usr.bin/mandoc/mandoc.h | 3 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_html.c | 5 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_macro.c | 24 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_man.c | 5 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_term.c | 5 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_validate.c | 4 | ||||
-rw-r--r-- | usr.bin/mandoc/read.c | 3 |
7 files changed, 32 insertions, 17 deletions
diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h index 483eda91ea8..b608b68e16a 100644 --- a/usr.bin/mandoc/mandoc.h +++ b/usr.bin/mandoc/mandoc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mandoc.h,v 1.116 2014/11/30 02:31:32 schwarze Exp $ */ +/* $OpenBSD: mandoc.h,v 1.117 2014/11/30 05:28:00 schwarze Exp $ */ /* * Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org> @@ -101,6 +101,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/usr.bin/mandoc/mdoc_html.c b/usr.bin/mandoc/mdoc_html.c index e4b9389d29a..b22e2f29e44 100644 --- a/usr.bin/mandoc/mdoc_html.c +++ b/usr.bin/mandoc/mdoc_html.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc_html.c,v 1.88 2014/11/27 22:27:40 schwarze Exp $ */ +/* $OpenBSD: mdoc_html.c,v 1.89 2014/11/30 05:28:00 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -1867,7 +1867,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/usr.bin/mandoc/mdoc_macro.c b/usr.bin/mandoc/mdoc_macro.c index f54b4c275f3..a7adb9f26d3 100644 --- a/usr.bin/mandoc/mdoc_macro.c +++ b/usr.bin/mandoc/mdoc_macro.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc_macro.c,v 1.111 2014/11/30 02:31:32 schwarze Exp $ */ +/* $OpenBSD: mdoc_macro.c,v 1.112 2014/11/30 05:28:00 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -1394,7 +1394,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). @@ -1426,11 +1426,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 && @@ -1445,8 +1452,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) @@ -1469,8 +1476,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/usr.bin/mandoc/mdoc_man.c b/usr.bin/mandoc/mdoc_man.c index 256ea37f390..5989154f41d 100644 --- a/usr.bin/mandoc/mdoc_man.c +++ b/usr.bin/mandoc/mdoc_man.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc_man.c,v 1.74 2014/11/27 22:27:40 schwarze Exp $ */ +/* $OpenBSD: mdoc_man.c,v 1.75 2014/11/30 05:28:00 schwarze Exp $ */ /* * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> * @@ -1600,7 +1600,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/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c index 66fd115a832..57ac0f5522f 100644 --- a/usr.bin/mandoc/mdoc_term.c +++ b/usr.bin/mandoc/mdoc_term.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc_term.c,v 1.196 2014/11/28 16:53:38 schwarze Exp $ */ +/* $OpenBSD: mdoc_term.c,v 1.197 2014/11/30 05:28: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> @@ -1732,7 +1732,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/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index f85936507aa..f869e7afd7f 100644 --- a/usr.bin/mandoc/mdoc_validate.c +++ b/usr.bin/mandoc/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc_validate.c,v 1.178 2014/11/28 18:35:37 schwarze Exp $ */ +/* $OpenBSD: mdoc_validate.c,v 1.179 2014/11/30 05:28:00 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org> @@ -208,7 +208,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/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c index e0a7e26cf96..040861bc55c 100644 --- a/usr.bin/mandoc/read.c +++ b/usr.bin/mandoc/read.c @@ -1,4 +1,4 @@ -/* $OpenBSD: read.c,v 1.78 2014/11/30 02:31:32 schwarze Exp $ */ +/* $OpenBSD: read.c,v 1.79 2014/11/30 05:28:00 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org> @@ -140,6 +140,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 \"\"", |