From df9a9479ddee899e1995f8eba1983628deecbec6 Mon Sep 17 00:00:00 2001 From: bentley Date: Sun, 25 Jun 2017 07:23:53 +0000 Subject: [PATCH] Add support for the MT and ME mailto macros, used for example in wg(8). feedback and ok schwarze@ --- share/man/man7/man.7 | 18 ++++++++++++++++-- usr.bin/mandoc/man_html.c | 13 +++++++++++-- usr.bin/mandoc/man_macro.c | 7 ++++++- usr.bin/mandoc/man_term.c | 4 +++- usr.bin/mandoc/man_validate.c | 6 ++++-- usr.bin/mandoc/mandoc.1 | 12 ++++++++---- usr.bin/mandoc/roff.c | 4 ++-- usr.bin/mandoc/roff.h | 4 +++- 8 files changed, 53 insertions(+), 15 deletions(-) diff --git a/share/man/man7/man.7 b/share/man/man7/man.7 index 6d7031d7241..111beed7af2 100644 --- a/share/man/man7/man.7 +++ b/share/man/man7/man.7 @@ -1,4 +1,4 @@ -.\" $OpenBSD: man.7,v 1.47 2017/05/07 21:44:33 schwarze Exp $ +.\" $OpenBSD: man.7,v 1.48 2017/06/25 07:23:53 bentley Exp $ .\" .\" Copyright (c) 2009, 2010, 2011, 2012 Kristaps Dzonsons .\" Copyright (c) 2011-2015 Ingo Schwarze @@ -16,7 +16,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: May 7 2017 $ +.Dd $Mdocdate: June 25 2017 $ .Dt MAN 7 .Os .Sh NAME @@ -466,6 +466,20 @@ See also .Sx \&PP , and .Sx \&TP . +.Ss \&ME +End a mailto block. +This is a non-standard GNU extension, included only for compatibility. +See +.Sx \&MT . +.Ss \&MT +Begin a mailto block. +This is a non-standard GNU extension, included only for compatibility. +It has the following syntax: +.Bd -literal -offset indent +.Pf \. Sx \&MT Ar address +link description to be shown +.Pf \. Sx ME +.Ed .Ss \&OP Optional command-line argument. This is a non-standard GNU extension, included only for compatibility. diff --git a/usr.bin/mandoc/man_html.c b/usr.bin/mandoc/man_html.c index 5037efa8550..86f30b9901c 100644 --- a/usr.bin/mandoc/man_html.c +++ b/usr.bin/mandoc/man_html.c @@ -1,4 +1,4 @@ -/* $OpenBSD: man_html.c,v 1.97 2017/06/24 14:38:27 schwarze Exp $ */ +/* $OpenBSD: man_html.c,v 1.98 2017/06/25 07:23:53 bentley Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons * Copyright (c) 2013, 2014, 2015, 2017 Ingo Schwarze @@ -104,6 +104,8 @@ static const struct htmlman __mans[MAN_MAX - MAN_TH] = { { NULL, NULL }, /* EE */ { man_UR_pre, NULL }, /* UR */ { NULL, NULL }, /* UE */ + { man_UR_pre, NULL }, /* MT */ + { NULL, NULL }, /* ME */ }; static const struct htmlman *const mans = __mans - MAN_TH; @@ -228,6 +230,7 @@ print_man_node(MAN_ARGS) case MAN_P: /* reopen .nf in the body. */ case MAN_RS: case MAN_UR: + case MAN_MT: fillmode(h, MAN_fi); break; default: @@ -642,11 +645,17 @@ man_RS_pre(MAN_ARGS) static int man_UR_pre(MAN_ARGS) { + char *cp; n = n->child; assert(n->type == ROFFT_HEAD); if (n->child != NULL) { assert(n->child->type == ROFFT_TEXT); - print_otag(h, TAG_A, "cTh", "Lk", n->child->string); + if (n->tok == MAN_MT) { + mandoc_asprintf(&cp, "mailto:%s", n->child->string); + print_otag(h, TAG_A, "cTh", "Mt", cp); + free(cp); + } else + print_otag(h, TAG_A, "cTh", "Lk", n->child->string); } assert(n->next->type == ROFFT_BODY); diff --git a/usr.bin/mandoc/man_macro.c b/usr.bin/mandoc/man_macro.c index d27acf9088f..8ee22eb56dd 100644 --- a/usr.bin/mandoc/man_macro.c +++ b/usr.bin/mandoc/man_macro.c @@ -1,4 +1,4 @@ -/* $OpenBSD: man_macro.c,v 1.84 2017/06/17 16:47:29 schwarze Exp $ */ +/* $OpenBSD: man_macro.c,v 1.85 2017/06/25 07:23:53 bentley Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2012-2015, 2017 Ingo Schwarze @@ -73,6 +73,8 @@ const struct man_macro __man_macros[MAN_MAX - MAN_TH] = { { in_line_eoln, MAN_BSCOPE }, /* EE */ { blk_exp, MAN_BSCOPE }, /* UR */ { blk_close, MAN_BSCOPE }, /* UE */ + { blk_exp, MAN_BSCOPE }, /* MT */ + { blk_close, MAN_BSCOPE }, /* ME */ }; const struct man_macro *const man_macros = __man_macros - MAN_TH; @@ -215,6 +217,9 @@ blk_close(MACRO_PROT_ARGS) case MAN_UE: ntok = MAN_UR; break; + case MAN_ME: + ntok = MAN_MT; + break; default: abort(); } diff --git a/usr.bin/mandoc/man_term.c b/usr.bin/mandoc/man_term.c index 7b34366e6a0..0bd7770395b 100644 --- a/usr.bin/mandoc/man_term.c +++ b/usr.bin/mandoc/man_term.c @@ -1,4 +1,4 @@ -/* $OpenBSD: man_term.c,v 1.160 2017/06/17 13:05:47 schwarze Exp $ */ +/* $OpenBSD: man_term.c,v 1.161 2017/06/25 07:23:53 bentley Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2015, 2017 Ingo Schwarze @@ -126,6 +126,8 @@ static const struct termact __termacts[MAN_MAX - MAN_TH] = { { pre_literal, NULL, 0 }, /* EE */ { pre_UR, post_UR, 0 }, /* UR */ { NULL, NULL, 0 }, /* UE */ + { pre_UR, post_UR, 0 }, /* MT */ + { NULL, NULL, 0 }, /* ME */ }; static const struct termact *termacts = __termacts - MAN_TH; diff --git a/usr.bin/mandoc/man_validate.c b/usr.bin/mandoc/man_validate.c index f527723319a..a3b1f3f5043 100644 --- a/usr.bin/mandoc/man_validate.c +++ b/usr.bin/mandoc/man_validate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: man_validate.c,v 1.102 2017/06/24 14:38:27 schwarze Exp $ */ +/* $OpenBSD: man_validate.c,v 1.103 2017/06/25 07:23:53 bentley Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2012-2017 Ingo Schwarze @@ -87,6 +87,8 @@ static const v_check __man_valids[MAN_MAX - MAN_TH] = { NULL, /* EE */ post_UR, /* UR */ NULL, /* UE */ + post_UR, /* MT */ + NULL, /* ME */ }; static const v_check *man_valids = __man_valids - MAN_TH; @@ -210,7 +212,7 @@ post_UR(CHKARGS) if (n->type == ROFFT_HEAD && n->child == NULL) mandoc_vmsg(MANDOCERR_UR_NOHEAD, man->parse, - n->line, n->pos, "UR"); + n->line, n->pos, roff_name[n->tok]); check_part(man, n); } diff --git a/usr.bin/mandoc/mandoc.1 b/usr.bin/mandoc/mandoc.1 index fe0b5406107..2df74ea9cd6 100644 --- a/usr.bin/mandoc/mandoc.1 +++ b/usr.bin/mandoc/mandoc.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: mandoc.1,v 1.129 2017/06/24 21:08:28 schwarze Exp $ +.\" $OpenBSD: mandoc.1,v 1.130 2017/06/25 07:23:53 bentley Exp $ .\" .\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons .\" Copyright (c) 2012, 2014-2017 Ingo Schwarze @@ -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: June 24 2017 $ +.Dd $Mdocdate: June 25 2017 $ .Dt MANDOC 1 .Os .Sh NAME @@ -1278,6 +1278,7 @@ A .Ic \&Bl , .Ic \&D1 , .Ic \&Dl , +.Ic \&MT , .Ic \&RS , or .Ic \&UR @@ -1413,6 +1414,8 @@ An empty pair of square brackets is shown. .It Sy "missing resource identifier, using \(dq\(dq" .Pq man The +.Ic \&MT +or .Ic \&UR macro is invoked without any argument. An empty pair of angle brackets is shown. @@ -1765,7 +1768,7 @@ An .Xr mdoc 7 block closing macro, a .Xr man 7 -.Ic \&RE +.Ic \&ME , \&RE or .Ic \&UE macro, an @@ -1799,7 +1802,7 @@ At the end of the document, an explicit block, a .Xr man 7 next-line scope or -.Ic \&RS +.Ic \&MT , \&RS or .Ic \&UR block, an equation, table, or @@ -1971,6 +1974,7 @@ A macro or request is invoked with too many arguments: .Bl -dash -offset 2n -width 2n -compact .It .Ic \&Fo , +.Ic \&MT , .Ic \&PD , .Ic \&RS , .Ic \&UR , diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c index 414c43aedd4..1311d4897bf 100644 --- a/usr.bin/mandoc/roff.c +++ b/usr.bin/mandoc/roff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: roff.c,v 1.188 2017/06/24 14:38:28 schwarze Exp $ */ +/* $OpenBSD: roff.c,v 1.189 2017/06/25 07:23:53 bentley Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons * Copyright (c) 2010-2015, 2017 Ingo Schwarze @@ -328,7 +328,7 @@ const char *__roff_name[MAN_MAX + 1] = { "RE", "RS", "DT", "UC", "PD", "AT", "in", "OP", "EX", "EE", "UR", - "UE", NULL + "UE", "MT", "ME", NULL }; const char *const *roff_name = __roff_name; diff --git a/usr.bin/mandoc/roff.h b/usr.bin/mandoc/roff.h index d976cce77f7..a7ffc1dcd3b 100644 --- a/usr.bin/mandoc/roff.h +++ b/usr.bin/mandoc/roff.h @@ -1,4 +1,4 @@ -/* $OpenBSD: roff.h,v 1.38 2017/06/24 14:38:28 schwarze Exp $ */ +/* $OpenBSD: roff.h,v 1.39 2017/06/25 07:23:53 bentley Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2013, 2014, 2015, 2017 Ingo Schwarze @@ -467,6 +467,8 @@ enum roff_tok { MAN_EE, MAN_UR, MAN_UE, + MAN_MT, + MAN_ME, MAN_MAX }; -- 2.20.1