aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2018-08-14 01:27:48 +0000
committerIngo Schwarze <schwarze@openbsd.org>2018-08-14 01:27:48 +0000
commit239614951577ba74078ca14afdba3508fb622fcb (patch)
treeb0cad4641ba4301bfba799b00568ad282f56890b
parent6a76b50ce922aa5133e03e44dd1c91f7f6d7d745 (diff)
downloadmandoc-239614951577ba74078ca14afdba3508fb622fcb.tar.gz
mandoc-239614951577ba74078ca14afdba3508fb622fcb.tar.zst
mandoc-239614951577ba74078ca14afdba3508fb622fcb.zip
support tail arguments on the .ME and .UE macros,
used for example in the ditroff(7) manual of the groff package
-rw-r--r--TODO5
-rw-r--r--man_macro.c41
-rw-r--r--man_term.c4
-rw-r--r--regress/man/MT/args.in8
-rw-r--r--regress/man/MT/args.out_ascii6
-rw-r--r--regress/man/MT/args.out_lint10
-rw-r--r--regress/man/UR/args.in8
-rw-r--r--regress/man/UR/args.out_ascii7
-rw-r--r--regress/man/UR/args.out_lint10
-rw-r--r--tree.c4
10 files changed, 64 insertions, 39 deletions
diff --git a/TODO b/TODO
index bda06ece..fa07058d 100644
--- a/TODO
+++ b/TODO
@@ -1,6 +1,6 @@
************************************************************************
* Official mandoc TODO.
-* $Id: TODO,v 1.262 2018/08/10 22:43:20 schwarze Exp $
+* $Id: TODO,v 1.263 2018/08/14 01:27:48 schwarze Exp $
************************************************************************
Many issues are annotated for difficulty as follows:
@@ -172,9 +172,6 @@ are mere guesses, and some may be wrong.
- .SY and .YS,
used by many groff manual pages
-- preserve punctuation following .ME,
- see ditroff(7) for an example
-
- .TQ tagged paragraph continuation,
see groff_diff(7) for examples
diff --git a/man_macro.c b/man_macro.c
index aa8b2001..a146bb11 100644
--- a/man_macro.c
+++ b/man_macro.c
@@ -1,7 +1,7 @@
-/* $Id: man_macro.c,v 1.123 2017/06/25 11:45:37 schwarze Exp $ */
+/* $Id: man_macro.c,v 1.124 2018/08/14 01:27:48 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2012-2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2012-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2013 Franco Fichtner <franco@lastsummer.de>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -189,10 +189,10 @@ rew_scope(struct roff_man *man, enum roff_tok tok)
void
blk_close(MACRO_PROT_ARGS)
{
- enum roff_tok ntok;
+ enum roff_tok ctok, ntok;
const struct roff_node *nn;
char *p;
- int nrew, target;
+ int cline, cpos, nrew, target;
nrew = 1;
switch (tok) {
@@ -234,22 +234,29 @@ blk_close(MACRO_PROT_ARGS)
mandoc_msg(MANDOCERR_BLK_NOTOPEN, man->parse,
line, ppos, roff_name[tok]);
rew_scope(man, MAN_PP);
- } else {
- line = man->last->line;
- ppos = man->last->pos;
- ntok = man->last->tok;
- man_unscope(man, nn);
+ return;
+ }
- if (tok == MAN_RE && nn->head->aux > 0)
- roff_setreg(man->roff, "an-margin",
- nn->head->aux, '-');
+ cline = man->last->line;
+ cpos = man->last->pos;
+ ctok = man->last->tok;
+ man_unscope(man, nn);
- /* Move a trailing paragraph behind the block. */
+ if (tok == MAN_RE && nn->head->aux > 0)
+ roff_setreg(man->roff, "an-margin", nn->head->aux, '-');
- if (ntok == MAN_LP || ntok == MAN_PP || ntok == MAN_P) {
- *pos = strlen(buf);
- blk_imp(man, ntok, line, ppos, pos, buf);
- }
+ /* Trailing text. */
+
+ if (buf[*pos] != '\0') {
+ roff_word_alloc(man, line, ppos, buf + *pos);
+ man->last->flags |= NODE_DELIMC;
+ }
+
+ /* Move a trailing paragraph behind the block. */
+
+ if (ctok == MAN_LP || ctok == MAN_PP || ctok == MAN_P) {
+ *pos = strlen(buf);
+ blk_imp(man, ctok, line, ppos, pos, buf);
}
}
diff --git a/man_term.c b/man_term.c
index b5723ccf..5838fa19 100644
--- a/man_term.c
+++ b/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.211 2018/06/10 15:12:35 schwarze Exp $ */
+/* $Id: man_term.c,v 1.212 2018/08/14 01:27:48 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -884,6 +884,8 @@ print_man_node(DECL_ARGS)
} else if (*n->string == ' ' && n->flags & NODE_LINE &&
(p->flags & TERMP_NONEWLINE) == 0)
term_newln(p);
+ else if (n->flags & NODE_DELIMC)
+ p->flags |= TERMP_NOSPACE;
term_word(p, n->string);
goto out;
diff --git a/regress/man/MT/args.in b/regress/man/MT/args.in
index c6ea1526..806e1a77 100644
--- a/regress/man/MT/args.in
+++ b/regress/man/MT/args.in
@@ -1,13 +1,19 @@
.\" $OpenBSD: args.in,v 1.2 2017/07/04 14:53:23 schwarze Exp $
-.TH MT-ARGS 1 "June 25, 2017"
+.TH MT-ARGS 1 "August 13, 2018"
.SH NAME
MT-args \- argument handling of the man-ext mailto macro
.SH DESCRIPTION
+argument, text, and tail:
+.MT test@example.com
+text
+.ME tail args
+.PP
argument plus text:
.MT test@example.com
invalid
address
.ME
+next line
.PP
argument but no text:
.MT test@example.com
diff --git a/regress/man/MT/args.out_ascii b/regress/man/MT/args.out_ascii
index 05939dcb..09dd4cd1 100644
--- a/regress/man/MT/args.out_ascii
+++ b/regress/man/MT/args.out_ascii
@@ -6,7 +6,9 @@ NNAAMMEE
MT-args - argument handling of the man-ext mailto macro
DDEESSCCRRIIPPTTIIOONN
- argument plus text: invalid address <test@example.com>
+ argument, text, and tail: text <test@example.com>tail args
+
+ argument plus text: invalid address <test@example.com> next line
argument but no text: <test@example.com>
@@ -20,4 +22,4 @@ DDEESSCCRRIIPPTTIIOONN
-OpenBSD June 25, 2017 MT-ARGS(1)
+OpenBSD August 13, 2018 MT-ARGS(1)
diff --git a/regress/man/MT/args.out_lint b/regress/man/MT/args.out_lint
index e94e63de..b06ec906 100644
--- a/regress/man/MT/args.out_lint
+++ b/regress/man/MT/args.out_lint
@@ -1,5 +1,5 @@
-mandoc: args.in:22:11: ERROR: skipping excess arguments: MT ... second
-mandoc: args.in:27:11: ERROR: skipping excess arguments: MT ... second
-mandoc: args.in:13:2: WARNING: empty block: MT
-mandoc: args.in:17:2: WARNING: missing resource identifier, using "": MT
-mandoc: args.in:27:2: WARNING: empty block: MT
+mandoc: args.in:28:11: ERROR: skipping excess arguments: MT ... second
+mandoc: args.in:33:11: ERROR: skipping excess arguments: MT ... second
+mandoc: args.in:19:2: WARNING: empty block: MT
+mandoc: args.in:23:2: WARNING: missing resource identifier, using "": MT
+mandoc: args.in:33:2: WARNING: empty block: MT
diff --git a/regress/man/UR/args.in b/regress/man/UR/args.in
index 183269e8..9afbbee5 100644
--- a/regress/man/UR/args.in
+++ b/regress/man/UR/args.in
@@ -1,13 +1,19 @@
.\" $OpenBSD: args.in,v 1.2 2017/07/04 14:53:24 schwarze Exp $
-.TH UR-ARGS 1 "October 17, 2013"
+.TH UR-ARGS 1 "August 14, 2018"
.SH NAME
UR-basic \- argument handling of the man-ext URI macro
.SH DESCRIPTION
+argument, text, and tail:
+.UR http://www.openbsd.org/
+text
+.UE tail argument
+.PP
argument plus text:
.UR http://www.openbsd.org/
OpenBSD
homepage
.UE
+next line
.PP
argument but no text:
.UR http://www.netbsd.org/
diff --git a/regress/man/UR/args.out_ascii b/regress/man/UR/args.out_ascii
index 9368974a..9b1d2ec3 100644
--- a/regress/man/UR/args.out_ascii
+++ b/regress/man/UR/args.out_ascii
@@ -6,7 +6,10 @@ NNAAMMEE
UR-basic - argument handling of the man-ext URI macro
DDEESSCCRRIIPPTTIIOONN
- argument plus text: OpenBSD homepage <http://www.openbsd.org/>
+ argument, text, and tail: text <http://www.openbsd.org/>tail argument
+
+ argument plus text: OpenBSD homepage <http://www.openbsd.org/> next
+ line
argument but no text: <http://www.netbsd.org/>
@@ -20,4 +23,4 @@ DDEESSCCRRIIPPTTIIOONN
-OpenBSD October 17, 2013 UR-ARGS(1)
+OpenBSD August 14, 2018 UR-ARGS(1)
diff --git a/regress/man/UR/args.out_lint b/regress/man/UR/args.out_lint
index 262c9886..b1525e0f 100644
--- a/regress/man/UR/args.out_lint
+++ b/regress/man/UR/args.out_lint
@@ -1,5 +1,5 @@
-mandoc: args.in:22:11: ERROR: skipping excess arguments: UR ... second
-mandoc: args.in:27:11: ERROR: skipping excess arguments: UR ... second
-mandoc: args.in:13:2: WARNING: empty block: UR
-mandoc: args.in:17:2: WARNING: missing resource identifier, using "": UR
-mandoc: args.in:27:2: WARNING: empty block: UR
+mandoc: args.in:28:11: ERROR: skipping excess arguments: UR ... second
+mandoc: args.in:33:11: ERROR: skipping excess arguments: UR ... second
+mandoc: args.in:19:2: WARNING: empty block: UR
+mandoc: args.in:23:2: WARNING: missing resource identifier, using "": UR
+mandoc: args.in:33:2: WARNING: empty block: UR
diff --git a/tree.c b/tree.c
index b9774e1c..416253f7 100644
--- a/tree.c
+++ b/tree.c
@@ -1,4 +1,4 @@
-/* $Id: tree.c,v 1.78 2018/04/11 17:11:13 schwarze Exp $ */
+/* $Id: tree.c,v 1.79 2018/08/14 01:27:48 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -289,6 +289,8 @@ print_man(const struct roff_node *n, int indent)
if (NODE_LINE & n->flags)
putchar('*');
printf("%d:%d", n->line, n->pos + 1);
+ if (NODE_DELIMC & n->flags)
+ putchar(')');
if (NODE_EOS & n->flags)
putchar('.');
putchar('\n');