Skip to content

Commit

Permalink
Add support for the MT and ME mailto macros, used for example in wg(8).
Browse files Browse the repository at this point in the history
feedback and ok schwarze@
  • Loading branch information
bentley committed Jun 25, 2017
1 parent 910b366 commit df9a947
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 15 deletions.
18 changes: 16 additions & 2 deletions share/man/man7/man.7
Original file line number Diff line number Diff line change
@@ -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 <kristaps@bsd.lv>
.\" Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org>
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down
13 changes: 11 additions & 2 deletions usr.bin/mandoc/man_html.c
Original file line number Diff line number Diff line change
@@ -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 <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 6 additions & 1 deletion usr.bin/mandoc/man_macro.c
Original file line number Diff line number Diff line change
@@ -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 <kristaps@bsd.lv>
* Copyright (c) 2012-2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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();
}
Expand Down
4 changes: 3 additions & 1 deletion usr.bin/mandoc/man_term.c
Original file line number Diff line number Diff line change
@@ -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 <kristaps@bsd.lv>
* Copyright (c) 2010-2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
Expand Down Expand Up @@ -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;

Expand Down
6 changes: 4 additions & 2 deletions usr.bin/mandoc/man_validate.c
Original file line number Diff line number Diff line change
@@ -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 <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2017 Ingo Schwarze <schwarze@openbsd.org>
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}

Expand Down
12 changes: 8 additions & 4 deletions usr.bin/mandoc/mandoc.1
Original file line number Diff line number Diff line change
@@ -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 <kristaps@bsd.lv>
.\" Copyright (c) 2012, 2014-2017 Ingo Schwarze <schwarze@openbsd.org>
Expand All @@ -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
Expand Down Expand Up @@ -1278,6 +1278,7 @@ A
.Ic \&Bl ,
.Ic \&D1 ,
.Ic \&Dl ,
.Ic \&MT ,
.Ic \&RS ,
or
.Ic \&UR
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ,
Expand Down
4 changes: 2 additions & 2 deletions usr.bin/mandoc/roff.c
Original file line number Diff line number Diff line change
@@ -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 <kristaps@bsd.lv>
* Copyright (c) 2010-2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
Expand Down Expand Up @@ -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;

Expand Down
4 changes: 3 additions & 1 deletion usr.bin/mandoc/roff.h
Original file line number Diff line number Diff line change
@@ -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 <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
Expand Down Expand Up @@ -467,6 +467,8 @@ enum roff_tok {
MAN_EE,
MAN_UR,
MAN_UE,
MAN_MT,
MAN_ME,
MAN_MAX
};

Expand Down

0 comments on commit df9a947

Please sign in to comment.