summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2013-10-17 20:51:28 +0000
committerschwarze <schwarze@openbsd.org>2013-10-17 20:51:28 +0000
commit3aeff92617d993171c51c2e1be911b4db5e35efb (patch)
treee34665b6d6f6f517b94f3530558434e88b49fd63
parentcannot have queue definitions inside anchors. (diff)
downloadwireguard-openbsd-3aeff92617d993171c51c2e1be911b4db5e35efb.tar.xz
wireguard-openbsd-3aeff92617d993171c51c2e1be911b4db5e35efb.zip
Implement the .UR/.UE block (uniform resource identifier) introduced in the
man-ext macros by Eric S. Raymond, enabled by default in groff_man(7). Usual disclaimer: You don't write new man(7) code, so you are not going to use these, either. Improves e.g. the bzr(1) and etherape(1) manuals. Thanks to naddy@ for bringing these to my attention.
-rw-r--r--regress/usr.bin/mandoc/man/Makefile4
-rw-r--r--regress/usr.bin/mandoc/man/UR/Makefile5
-rw-r--r--regress/usr.bin/mandoc/man/UR/args.in29
-rw-r--r--regress/usr.bin/mandoc/man/UR/args.out_ascii23
-rw-r--r--usr.bin/mandoc/man.c5
-rw-r--r--usr.bin/mandoc/man.h4
-rw-r--r--usr.bin/mandoc/man_html.c32
-rw-r--r--usr.bin/mandoc/man_macro.c7
-rw-r--r--usr.bin/mandoc/man_term.c32
-rw-r--r--usr.bin/mandoc/man_validate.c19
10 files changed, 149 insertions, 11 deletions
diff --git a/regress/usr.bin/mandoc/man/Makefile b/regress/usr.bin/mandoc/man/Makefile
index a591c58dc55..b9a74e228c0 100644
--- a/regress/usr.bin/mandoc/man/Makefile
+++ b/regress/usr.bin/mandoc/man/Makefile
@@ -1,6 +1,6 @@
-# $OpenBSD: Makefile,v 1.12 2012/11/18 00:23:56 schwarze Exp $
+# $OpenBSD: Makefile,v 1.13 2013/10/17 20:51:28 schwarze Exp $
-SUBDIR = BI EX HP IP PD PP RS TH TP TS nf blank
+SUBDIR = BI EX HP IP PD PP RS TH TP TS UR nf blank
ascii groff groff-clean obj-clean tman: _SUBDIRUSE
diff --git a/regress/usr.bin/mandoc/man/UR/Makefile b/regress/usr.bin/mandoc/man/UR/Makefile
new file mode 100644
index 00000000000..a0230e4712b
--- /dev/null
+++ b/regress/usr.bin/mandoc/man/UR/Makefile
@@ -0,0 +1,5 @@
+# $OpenBSD: Makefile,v 1.1 2013/10/17 20:51:31 schwarze Exp $
+
+REGRESS_TARGETS = args
+
+.include <bsd.regress.mk>
diff --git a/regress/usr.bin/mandoc/man/UR/args.in b/regress/usr.bin/mandoc/man/UR/args.in
new file mode 100644
index 00000000000..f45770b2beb
--- /dev/null
+++ b/regress/usr.bin/mandoc/man/UR/args.in
@@ -0,0 +1,29 @@
+.TH UR-ARGS 1 "October 17, 2013" OpenBSD
+.SH NAME
+UR-basic \- argument handling of the man-ext URI macro
+.SH DESCRIPTION
+argument plus text:
+.UR http://www.openbsd.org/
+OpenBSD
+homepage
+.UE
+.PP
+argument but no text:
+.UR http://www.netbsd.org/
+.UE
+.PP
+no argument, but text:
+.UR
+some text
+.UE
+.PP
+two arguments plus text:
+.UR first second
+some text
+.UE
+.PP
+two arguments, but no text:
+.UR first second
+.UE
+.PP
+final text
diff --git a/regress/usr.bin/mandoc/man/UR/args.out_ascii b/regress/usr.bin/mandoc/man/UR/args.out_ascii
new file mode 100644
index 00000000000..dad5301494d
--- /dev/null
+++ b/regress/usr.bin/mandoc/man/UR/args.out_ascii
@@ -0,0 +1,23 @@
+UR-ARGS(1) OpenBSD Reference Manual UR-ARGS(1)
+
+
+
+NNAAMMEE
+ UR-basic - argument handling of the man-ext URI macro
+
+DDEESSCCRRIIPPTTIIOONN
+ argument plus text: OpenBSD homepage <http://www.openbsd.org/>
+
+ argument but no text: <http://www.netbsd.org/>
+
+ no argument, but text: some text <>
+
+ two arguments plus text: some text <first>
+
+ two arguments, but no text: <first>
+
+ final text
+
+
+
+OpenBSD October 17, 2013 UR-ARGS(1)
diff --git a/usr.bin/mandoc/man.c b/usr.bin/mandoc/man.c
index 08c89b795c3..909019f85f1 100644
--- a/usr.bin/mandoc/man.c
+++ b/usr.bin/mandoc/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.69 2012/11/17 00:25:20 schwarze Exp $ */
+/* $Id: man.c,v 1.70 2013/10/17 20:51:28 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -36,7 +36,8 @@ const char *const __man_macronames[MAN_MAX] = {
"RI", "na", "sp", "nf",
"fi", "RE", "RS", "DT",
"UC", "PD", "AT", "in",
- "ft", "OP", "EX", "EE"
+ "ft", "OP", "EX", "EE",
+ "UR", "UE"
};
const char * const *man_macronames = __man_macronames;
diff --git a/usr.bin/mandoc/man.h b/usr.bin/mandoc/man.h
index e06257f6f05..54e13433e0d 100644
--- a/usr.bin/mandoc/man.h
+++ b/usr.bin/mandoc/man.h
@@ -1,4 +1,4 @@
-/* $Id: man.h,v 1.40 2012/06/02 20:07:09 schwarze Exp $ */
+/* $Id: man.h,v 1.41 2013/10/17 20:51:29 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -54,6 +54,8 @@ enum mant {
MAN_OP,
MAN_EX,
MAN_EE,
+ MAN_UR,
+ MAN_UE,
MAN_MAX
};
diff --git a/usr.bin/mandoc/man_html.c b/usr.bin/mandoc/man_html.c
index b9791f43b29..3d897fea064 100644
--- a/usr.bin/mandoc/man_html.c
+++ b/usr.bin/mandoc/man_html.c
@@ -1,6 +1,7 @@
-/* $Id: man_html.c,v 1.48 2012/11/17 00:25:20 schwarze Exp $ */
+/* $Id: man_html.c,v 1.49 2013/10/17 20:51:29 schwarze Exp $ */
/*
- * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2013 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -66,6 +67,7 @@ static int man_RS_pre(MAN_ARGS);
static int man_SH_pre(MAN_ARGS);
static int man_SM_pre(MAN_ARGS);
static int man_SS_pre(MAN_ARGS);
+static int man_UR_pre(MAN_ARGS);
static int man_alt_pre(MAN_ARGS);
static int man_br_pre(MAN_ARGS);
static int man_ign_pre(MAN_ARGS);
@@ -111,6 +113,8 @@ static const struct htmlman mans[MAN_MAX] = {
{ man_OP_pre, NULL }, /* OP */
{ man_literal_pre, NULL }, /* EX */
{ man_literal_pre, NULL }, /* EE */
+ { man_UR_pre, NULL }, /* UR */
+ { NULL, NULL }, /* UE */
};
/*
@@ -684,3 +688,27 @@ man_RS_pre(MAN_ARGS)
print_otag(h, TAG_DIV, 1, &tag);
return(1);
}
+
+/* ARGSUSED */
+static int
+man_UR_pre(MAN_ARGS)
+{
+ struct htmlpair tag[2];
+
+ n = n->child;
+ assert(MAN_HEAD == n->type);
+ if (n->nchild) {
+ assert(MAN_TEXT == n->child->type);
+ PAIR_CLASS_INIT(&tag[0], "link-ext");
+ PAIR_HREF_INIT(&tag[1], n->child->string);
+ print_otag(h, TAG_A, 2, tag);
+ }
+
+ assert(MAN_BODY == n->next->type);
+ if (n->next->nchild)
+ n = n->next;
+
+ print_man_nodelist(man, n->child, mh, h);
+
+ return(0);
+}
diff --git a/usr.bin/mandoc/man_macro.c b/usr.bin/mandoc/man_macro.c
index fd6bc082996..555c14a6421 100644
--- a/usr.bin/mandoc/man_macro.c
+++ b/usr.bin/mandoc/man_macro.c
@@ -1,4 +1,4 @@
-/* $Id: man_macro.c,v 1.38 2012/11/17 00:25:20 schwarze Exp $ */
+/* $Id: man_macro.c,v 1.39 2013/10/17 20:51:30 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2012 Ingo Schwarze <schwarze@openbsd.org>
@@ -84,6 +84,8 @@ const struct man_macro __man_macros[MAN_MAX] = {
{ in_line_eoln, 0 }, /* OP */
{ in_line_eoln, MAN_BSCOPE }, /* EX */
{ in_line_eoln, MAN_BSCOPE }, /* EE */
+ { blk_exp, MAN_BSCOPE | MAN_EXPLICIT }, /* UR */
+ { blk_close, 0 }, /* UE */
};
const struct man_macro * const man_macros = __man_macros;
@@ -280,6 +282,9 @@ blk_close(MACRO_PROT_ARGS)
case (MAN_RE):
ntok = MAN_RS;
break;
+ case (MAN_UE):
+ ntok = MAN_UR;
+ break;
default:
abort();
/* NOTREACHED */
diff --git a/usr.bin/mandoc/man_term.c b/usr.bin/mandoc/man_term.c
index ff8c6712d41..4c4e139cee9 100644
--- a/usr.bin/mandoc/man_term.c
+++ b/usr.bin/mandoc/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.90 2013/01/05 22:18:59 schwarze Exp $ */
+/* $Id: man_term.c,v 1.91 2013/10/17 20:51:30 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
@@ -74,6 +74,7 @@ static int pre_RS(DECL_ARGS);
static int pre_SH(DECL_ARGS);
static int pre_SS(DECL_ARGS);
static int pre_TP(DECL_ARGS);
+static int pre_UR(DECL_ARGS);
static int pre_alternate(DECL_ARGS);
static int pre_ft(DECL_ARGS);
static int pre_ign(DECL_ARGS);
@@ -87,6 +88,7 @@ static void post_RS(DECL_ARGS);
static void post_SH(DECL_ARGS);
static void post_SS(DECL_ARGS);
static void post_TP(DECL_ARGS);
+static void post_UR(DECL_ARGS);
static const struct termact termacts[MAN_MAX] = {
{ pre_sp, NULL, MAN_NOTEXT }, /* br */
@@ -125,6 +127,8 @@ static const struct termact termacts[MAN_MAX] = {
{ pre_OP, NULL, 0 }, /* OP */
{ pre_literal, NULL, 0 }, /* EX */
{ pre_literal, NULL, 0 }, /* EE */
+ { pre_UR, post_UR, 0 }, /* UR */
+ { NULL, NULL, 0 }, /* UE */
};
@@ -935,6 +939,32 @@ post_RS(DECL_ARGS)
mt->lmargincur = mt->lmarginsz;
}
+/* ARGSUSED */
+static int
+pre_UR(DECL_ARGS)
+{
+
+ return (MAN_HEAD != n->type);
+}
+
+/* ARGSUSED */
+static void
+post_UR(DECL_ARGS)
+{
+
+ if (MAN_BLOCK != n->type)
+ return;
+
+ term_word(p, "<");
+ p->flags |= TERMP_NOSPACE;
+
+ if (NULL != n->child->child)
+ print_man_node(p, mt, n->child->child, meta);
+
+ p->flags |= TERMP_NOSPACE;
+ term_word(p, ">");
+}
+
static void
print_man_node(DECL_ARGS)
{
diff --git a/usr.bin/mandoc/man_validate.c b/usr.bin/mandoc/man_validate.c
index ea80779516c..8f2ed6dd8a9 100644
--- a/usr.bin/mandoc/man_validate.c
+++ b/usr.bin/mandoc/man_validate.c
@@ -1,7 +1,7 @@
-/* $Id: man_validate.c,v 1.57 2012/11/17 00:25:20 schwarze Exp $ */
+/* $Id: man_validate.c,v 1.58 2013/10/17 20:51:31 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010, 2012 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -45,6 +45,7 @@ static int check_eq2(CHKARGS);
static int check_le1(CHKARGS);
static int check_ge2(CHKARGS);
static int check_le5(CHKARGS);
+static int check_head1(CHKARGS);
static int check_par(CHKARGS);
static int check_part(CHKARGS);
static int check_root(CHKARGS);
@@ -76,6 +77,7 @@ static v_check posts_sec[] = { post_sec, NULL };
static v_check posts_sp[] = { post_vs, check_le1, NULL };
static v_check posts_th[] = { check_ge2, check_le5, post_TH, NULL };
static v_check posts_uc[] = { post_UC, NULL };
+static v_check posts_ur[] = { check_head1, check_part, NULL };
static v_check pres_sec[] = { pre_sec, NULL };
static const struct man_valid man_valids[MAN_MAX] = {
@@ -115,6 +117,8 @@ static const struct man_valid man_valids[MAN_MAX] = {
{ NULL, posts_eq2 }, /* OP */
{ NULL, posts_nf }, /* EX */
{ NULL, posts_fi }, /* EE */
+ { NULL, posts_ur }, /* UR */
+ { NULL, NULL }, /* UE */
};
@@ -242,6 +246,17 @@ INEQ_DEFINE(2, >=, ge2)
INEQ_DEFINE(5, <=, le5)
static int
+check_head1(CHKARGS)
+{
+
+ if (MAN_HEAD == n->type && 1 != n->nchild)
+ mandoc_vmsg(MANDOCERR_ARGCOUNT, man->parse, n->line,
+ n->pos, "line arguments eq 1 (have %d)", n->nchild);
+
+ return(1);
+}
+
+static int
post_ft(CHKARGS)
{
char *cp;