aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2012-01-03 15:16:24 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2012-01-03 15:16:24 +0000
commitd346448c959f7b9855c02917b358cfb0da2525e8 (patch)
tree1339709d2371873603f713f958f83cc8daa1a231
parent484b430b59995e6ddf4b84461fdcc0c3a757addb (diff)
downloadmandoc-d346448c959f7b9855c02917b358cfb0da2525e8.tar.gz
mandoc-d346448c959f7b9855c02917b358cfb0da2525e8.tar.zst
mandoc-d346448c959f7b9855c02917b358cfb0da2525e8.zip
Add support for `OP', one of the extended man macros. This also requires
some man(7) changes to accomodate for the an-ext compatibility.
-rw-r--r--man.731
-rw-r--r--man.c4
-rw-r--r--man.h3
-rw-r--r--man_html.c53
-rw-r--r--man_macro.c3
-rw-r--r--man_term.c31
-rw-r--r--man_validate.c10
7 files changed, 112 insertions, 23 deletions
diff --git a/man.7 b/man.7
index b7cf7f70..1715a7ca 100644
--- a/man.7
+++ b/man.7
@@ -1,4 +1,4 @@
-.\" $Id: man.7,v 1.112 2011/12/02 01:37:14 schwarze Exp $
+.\" $Id: man.7,v 1.113 2012/01/03 15:16:24 kristaps Exp $
.\"
.\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -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: December 2 2011 $
+.Dd $Mdocdate: January 3 2012 $
.Dt MAN 7
.Os
.Sh NAME
@@ -272,6 +272,10 @@ in the alphabetical reference below.
.It Sx RB Ta alternate between roman and boldface fonts
.It Sx RI Ta alternate between roman and italic fonts
.El
+.Ss Semantic markup
+.Bl -column "PP, LP, P" description
+.It Sx OP Ta optional arguments
+.El
.Sh MACRO REFERENCE
This section is a canonical reference to all macros, arranged
alphabetically.
@@ -437,6 +441,19 @@ See also
.Sx \&PP ,
and
.Sx \&TP .
+.Ss \&OP
+Optional command-line argument.
+This has the following syntax:
+.Bd -filled -offset indent
+.Pf \. Sx \&OP
+.Cm key Op Cm value
+.Ed
+.Pp
+The
+.Cm key
+is usually a command-line flag and
+.Cm value
+its argument.
.Ss \&P
Synonym for
.Sx \&LP .
@@ -691,6 +708,7 @@ The syntax is as follows:
.It Sx \&I Ta n Ta next-line Ta \&
.It Sx \&IB Ta n Ta current Ta \&
.It Sx \&IR Ta n Ta current Ta \&
+.It Sx \&OP Ta 0, 1 Ta current Ta compat
.It Sx \&R Ta n Ta next-line Ta \&
.It Sx \&RB Ta n Ta current Ta \&
.It Sx \&RI Ta n Ta current Ta \&
@@ -854,6 +872,12 @@ number when no
is given, like in
.Xr mdoc 7 .
.El
+.Pp
+The
+.Sx OP
+macro is part of the extended
+.Nm
+macro set, and may not be portable to non-GNU troff implementations.
.Sh SEE ALSO
.Xr man 1 ,
.Xr mandoc 1 ,
@@ -869,6 +893,9 @@ language first appeared as a macro package for the roff typesetting
system in
.At v7 .
It was later rewritten by James Clark as a macro package for groff.
+Eric S. Raymond wrote the extended
+.Nm
+macros for groff in 2007.
The stand-alone implementation that is part of the
.Xr mandoc 1
utility written by Kristaps Dzonsons appeared in
diff --git a/man.c b/man.c
index 61f2a5eb..1bea5610 100644
--- a/man.c
+++ b/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.114 2011/11/16 22:39:05 joerg Exp $ */
+/* $Id: man.c,v 1.115 2012/01/03 15:16:24 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -40,7 +40,7 @@ const char *const __man_macronames[MAN_MAX] = {
"RI", "na", "sp", "nf",
"fi", "RE", "RS", "DT",
"UC", "PD", "AT", "in",
- "ft"
+ "ft", "OP"
};
const char * const *man_macronames = __man_macronames;
diff --git a/man.h b/man.h
index beb406f6..4fc3934e 100644
--- a/man.h
+++ b/man.h
@@ -1,4 +1,4 @@
-/* $Id: man.h,v 1.59 2011/10/06 22:29:12 kristaps Exp $ */
+/* $Id: man.h,v 1.60 2012/01/03 15:16:24 kristaps Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -51,6 +51,7 @@ enum mant {
MAN_AT,
MAN_in,
MAN_ft,
+ MAN_OP,
MAN_MAX
};
diff --git a/man_html.c b/man_html.c
index fce1d4c5..a76ea2d7 100644
--- a/man_html.c
+++ b/man_html.c
@@ -1,4 +1,4 @@
-/* $Id: man_html.c,v 1.85 2011/12/04 00:44:12 schwarze Exp $ */
+/* $Id: man_html.c,v 1.86 2012/01/03 15:16:24 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -58,26 +58,25 @@ static void print_man(MAN_ARGS);
static void print_man_head(MAN_ARGS);
static void print_man_nodelist(MAN_ARGS);
static void print_man_node(MAN_ARGS);
-
static int a2width(const struct man_node *,
struct roffsu *);
-
-static int man_alt_pre(MAN_ARGS);
-static int man_br_pre(MAN_ARGS);
-static int man_ign_pre(MAN_ARGS);
-static int man_in_pre(MAN_ARGS);
-static int man_literal_pre(MAN_ARGS);
-static void man_root_post(MAN_ARGS);
-static void man_root_pre(MAN_ARGS);
static int man_B_pre(MAN_ARGS);
static int man_HP_pre(MAN_ARGS);
-static int man_I_pre(MAN_ARGS);
static int man_IP_pre(MAN_ARGS);
+static int man_I_pre(MAN_ARGS);
+static int man_OP_pre(MAN_ARGS);
static int man_PP_pre(MAN_ARGS);
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_alt_pre(MAN_ARGS);
+static int man_br_pre(MAN_ARGS);
+static int man_ign_pre(MAN_ARGS);
+static int man_in_pre(MAN_ARGS);
+static int man_literal_pre(MAN_ARGS);
+static void man_root_post(MAN_ARGS);
+static void man_root_pre(MAN_ARGS);
static const struct htmlman mans[MAN_MAX] = {
{ man_br_pre, NULL }, /* br */
@@ -113,6 +112,7 @@ static const struct htmlman mans[MAN_MAX] = {
{ man_ign_pre, NULL }, /* AT */
{ man_in_pre, NULL }, /* in */
{ man_ign_pre, NULL }, /* ft */
+ { man_OP_pre, NULL }, /* OP */
};
/*
@@ -586,6 +586,37 @@ man_HP_pre(MAN_ARGS)
/* ARGSUSED */
static int
+man_OP_pre(MAN_ARGS)
+{
+ struct tag *tt;
+ struct htmlpair tag;
+
+ print_text(h, "[");
+ h->flags |= HTML_NOSPACE;
+ PAIR_CLASS_INIT(&tag, "opt");
+ tt = print_otag(h, TAG_SPAN, 1, &tag);
+
+ if (NULL != (n = n->child)) {
+ print_otag(h, TAG_B, 0, NULL);
+ print_text(h, n->string);
+ }
+
+ print_stagq(h, tt);
+
+ if (NULL != n && NULL != n->next) {
+ print_otag(h, TAG_I, 0, NULL);
+ print_text(h, n->next->string);
+ }
+
+ print_stagq(h, tt);
+ h->flags |= HTML_NOSPACE;
+ print_text(h, "]");
+ return(0);
+}
+
+
+/* ARGSUSED */
+static int
man_B_pre(MAN_ARGS)
{
diff --git a/man_macro.c b/man_macro.c
index 6afce4d0..4bbbc4fa 100644
--- a/man_macro.c
+++ b/man_macro.c
@@ -1,4 +1,4 @@
-/* $Id: man_macro.c,v 1.70 2011/12/04 00:44:12 schwarze Exp $ */
+/* $Id: man_macro.c,v 1.71 2012/01/03 15:16:24 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -84,6 +84,7 @@ const struct man_macro __man_macros[MAN_MAX] = {
{ in_line_eoln, 0 }, /* AT */
{ in_line_eoln, 0 }, /* in */
{ in_line_eoln, 0 }, /* ft */
+ { in_line_eoln, 0 }, /* OP */
};
const struct man_macro * const man_macros = __man_macros;
diff --git a/man_term.c b/man_term.c
index 180fc677..69c5c95e 100644
--- a/man_term.c
+++ b/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.126 2011/12/04 23:10:52 schwarze Exp $ */
+/* $Id: man_term.c,v 1.127 2012/01/03 15:16:24 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -68,21 +68,22 @@ static void print_man_foot(struct termp *, const void *);
static void print_bvspace(struct termp *,
const struct man_node *);
-static int pre_alternate(DECL_ARGS);
static int pre_B(DECL_ARGS);
static int pre_HP(DECL_ARGS);
static int pre_I(DECL_ARGS);
static int pre_IP(DECL_ARGS);
+static int pre_OP(DECL_ARGS);
static int pre_PP(DECL_ARGS);
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_alternate(DECL_ARGS);
+static int pre_ft(DECL_ARGS);
static int pre_ign(DECL_ARGS);
static int pre_in(DECL_ARGS);
static int pre_literal(DECL_ARGS);
static int pre_sp(DECL_ARGS);
-static int pre_ft(DECL_ARGS);
static void post_IP(DECL_ARGS);
static void post_HP(DECL_ARGS);
@@ -125,6 +126,7 @@ static const struct termact termacts[MAN_MAX] = {
{ pre_ign, NULL, 0 }, /* AT */
{ pre_in, NULL, MAN_NOTEXT }, /* in */
{ pre_ft, NULL, MAN_NOTEXT }, /* ft */
+ { pre_OP, NULL, 0 }, /* OP */
};
@@ -324,6 +326,29 @@ pre_B(DECL_ARGS)
/* ARGSUSED */
static int
+pre_OP(DECL_ARGS)
+{
+
+ term_word(p, "[");
+ p->flags |= TERMP_NOSPACE;
+
+ if (NULL != (n = n->child)) {
+ term_fontrepl(p, TERMFONT_BOLD);
+ term_word(p, n->string);
+ }
+ if (NULL != n && NULL != n->next) {
+ term_fontrepl(p, TERMFONT_UNDER);
+ term_word(p, n->next->string);
+ }
+
+ term_fontrepl(p, TERMFONT_NONE);
+ p->flags |= TERMP_NOSPACE;
+ term_word(p, "]");
+ return(0);
+}
+
+/* ARGSUSED */
+static int
pre_ft(DECL_ARGS)
{
const char *cp;
diff --git a/man_validate.c b/man_validate.c
index bf266ca6..e40b089f 100644
--- a/man_validate.c
+++ b/man_validate.c
@@ -1,4 +1,4 @@
-/* $Id: man_validate.c,v 1.79 2011/12/02 01:37:14 schwarze Exp $ */
+/* $Id: man_validate.c,v 1.80 2012/01/03 15:16:24 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -45,6 +45,7 @@ struct man_valid {
};
static int check_eq0(CHKARGS);
+static int check_eq2(CHKARGS);
static int check_le1(CHKARGS);
static int check_ge2(CHKARGS);
static int check_le5(CHKARGS);
@@ -66,6 +67,7 @@ static int pre_sec(CHKARGS);
static v_check posts_at[] = { post_AT, NULL };
static v_check posts_br[] = { post_vs, check_eq0, NULL };
static v_check posts_eq0[] = { check_eq0, NULL };
+static v_check posts_eq2[] = { check_eq2, NULL };
static v_check posts_fi[] = { check_eq0, post_fi, NULL };
static v_check posts_ft[] = { post_ft, NULL };
static v_check posts_nf[] = { check_eq0, post_nf, NULL };
@@ -99,8 +101,8 @@ static const struct man_valid man_valids[MAN_MAX] = {
{ NULL, NULL }, /* I */
{ NULL, NULL }, /* IR */
{ NULL, NULL }, /* RI */
- { NULL, posts_eq0 }, /* na */ /* FIXME: should warn only. */
- { NULL, posts_sp }, /* sp */ /* FIXME: should warn only. */
+ { NULL, posts_eq0 }, /* na */
+ { NULL, posts_sp }, /* sp */
{ NULL, posts_nf }, /* nf */
{ NULL, posts_fi }, /* fi */
{ NULL, NULL }, /* RE */
@@ -111,6 +113,7 @@ static const struct man_valid man_valids[MAN_MAX] = {
{ NULL, posts_at }, /* AT */
{ NULL, NULL }, /* in */
{ NULL, posts_ft }, /* ft */
+ { NULL, posts_eq2 }, /* OP */
};
@@ -232,6 +235,7 @@ check_##name(CHKARGS) \
}
INEQ_DEFINE(0, ==, eq0)
+INEQ_DEFINE(2, ==, eq2)
INEQ_DEFINE(1, <=, le1)
INEQ_DEFINE(2, >=, ge2)
INEQ_DEFINE(5, <=, le5)