summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2018-08-18 02:08:27 +0000
committerIngo Schwarze <schwarze@openbsd.org>2018-08-18 02:08:27 +0000
commit0dca371a35715658277a48885367f1eb97158c75 (patch)
treef0e4615581362ce6003973c6573dc0743f516feb
parenta55868d2cb7c07237689f307d3a55b33b257de09 (diff)
downloadmandoc-0dca371a35715658277a48885367f1eb97158c75.tar.gz
implement the GNU man-ext .SY/.YS (synopsis block) macro in man(7),
used in most manual pages of the groff package
-rw-r--r--LICENSE1
-rw-r--r--TODO3
-rw-r--r--man.719
-rw-r--r--man_html.c24
-rw-r--r--man_macro.c5
-rw-r--r--man_term.c60
-rw-r--r--man_validate.c2
-rw-r--r--roff.c3
-rw-r--r--roff.h4
9 files changed, 115 insertions, 6 deletions
diff --git a/LICENSE b/LICENSE
index f01e5377..27debb64 100644
--- a/LICENSE
+++ b/LICENSE
@@ -12,6 +12,7 @@ Copyright (c) 2013 Franco Fichtner <franco@lastsummer.de>
Copyright (c) 2014 Baptiste Daroussin <bapt@freebsd.org>
Copyright (c) 2016 Ed Maste <emaste@freebsd.org>
Copyright (c) 2017 Michael Stapelberg <stapelberg@debian.org>
+Copyright (c) 2017 Anthony Bentley <bentley@openbsd.org>
Copyright (c) 1998, 2004, 2010 Todd C. Miller <Todd.Miller@courtesan.com>
Copyright (c) 2008, 2017 Otto Moerbeek <otto@drijf.net>
Copyright (c) 2004 Ted Unangst <tedu@openbsd.org>
diff --git a/TODO b/TODO
index 8c71bf63..2701a745 100644
--- a/TODO
+++ b/TODO
@@ -162,9 +162,6 @@ are mere guesses, and some may be wrong.
--- missing man features -----------------------------------------------
-- .SY and .YS,
- used by many groff manual pages
-
- groff_www(7) .MTO and .URL
These macros were used by the GNU grep(1) man page.
The groff_www(7) manual page itself uses them, too.
diff --git a/man.7 b/man.7
index b5dbc603..77c3219f 100644
--- a/man.7
+++ b/man.7
@@ -1,7 +1,8 @@
.\" $Id$
.\"
.\" Copyright (c) 2009, 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
-.\" Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org>
+.\" Copyright (c) 2011-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
+.\" Copyright (c) 2017 Anthony Bentley <bentley@openbsd.org>
.\" Copyright (c) 2010 Joerg Sonnenberger <joerg@netbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
@@ -630,6 +631,18 @@ Begin a sub-section.
The scope of a sub-section is closed by a subsequent sub-section,
section, or end of file.
The paragraph left-margin width is reset to the default.
+.Ss \&SY
+Begin a synopsis block with the following syntax:
+.Bd -unfilled -offset indent
+.Pf \. Sx \&SY Ar command
+.Ar arguments
+.Pf \. Sx \&YS
+.Ed
+.Pp
+This is a non-standard GNU extension
+and very rarely used even in GNU manual pages.
+Formatting is similar to
+.Sx \&IP .
.Ss \&TH
Sets the title of the manual page for use in the page header
and footer with the following syntax:
@@ -718,6 +731,10 @@ It has the following syntax:
link description to be shown
.Pf \. Sx UE
.Ed
+.Ss \&YS
+End a synopsis block started by
+.Pf \. Sx SY .
+This is a non-standard GNU extension.
.Ss \&fi
End literal mode begun by
.Sx \&nf .
diff --git a/man_html.c b/man_html.c
index 2d451a51..3c91d068 100644
--- a/man_html.c
+++ b/man_html.c
@@ -61,6 +61,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_SY_pre(MAN_ARGS);
static int man_UR_pre(MAN_ARGS);
static int man_alt_pre(MAN_ARGS);
static int man_ign_pre(MAN_ARGS);
@@ -101,6 +102,8 @@ static const struct man_html_act man_html_acts[MAN_MAX - MAN_TH] = {
{ man_ign_pre, NULL }, /* PD */
{ man_ign_pre, NULL }, /* AT */
{ man_in_pre, NULL }, /* in */
+ { man_SY_pre, NULL }, /* SY */
+ { NULL, NULL }, /* YS */
{ man_OP_pre, NULL }, /* OP */
{ NULL, NULL }, /* EX */
{ NULL, NULL }, /* EE */
@@ -622,6 +625,27 @@ man_RS_pre(MAN_ARGS)
}
static int
+man_SY_pre(MAN_ARGS)
+{
+ switch (n->type) {
+ case ROFFT_BLOCK:
+ print_otag(h, TAG_TABLE, "c", "Nm");
+ print_otag(h, TAG_TR, "");
+ break;
+ case ROFFT_HEAD:
+ print_otag(h, TAG_TD, "");
+ print_otag(h, TAG_CODE, "cT", "Nm");
+ break;
+ case ROFFT_BODY:
+ print_otag(h, TAG_TD, "");
+ break;
+ default:
+ abort();
+ }
+ return 1;
+}
+
+static int
man_UR_pre(MAN_ARGS)
{
char *cp;
diff --git a/man_macro.c b/man_macro.c
index 65f1afb8..43249161 100644
--- a/man_macro.c
+++ b/man_macro.c
@@ -71,6 +71,8 @@ static const struct man_macro man_macros[MAN_MAX - MAN_TH] = {
{ in_line_eoln, MAN_NSCOPED }, /* PD */
{ in_line_eoln, 0 }, /* AT */
{ in_line_eoln, MAN_NSCOPED }, /* in */
+ { blk_exp, MAN_BSCOPE }, /* SY */
+ { blk_close, MAN_BSCOPE }, /* YS */
{ in_line_eoln, 0 }, /* OP */
{ in_line_eoln, MAN_BSCOPE }, /* EX */
{ in_line_eoln, MAN_BSCOPE }, /* EE */
@@ -223,6 +225,9 @@ blk_close(MACRO_PROT_ARGS)
return;
}
break;
+ case MAN_YS:
+ ntok = MAN_SY;
+ break;
case MAN_UE:
ntok = MAN_UR;
break;
diff --git a/man_term.c b/man_term.c
index 8c70a98c..58e86bfc 100644
--- a/man_term.c
+++ b/man_term.c
@@ -78,6 +78,7 @@ 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_SY(DECL_ARGS);
static int pre_TP(DECL_ARGS);
static int pre_UR(DECL_ARGS);
static int pre_alternate(DECL_ARGS);
@@ -90,6 +91,7 @@ static void post_HP(DECL_ARGS);
static void post_RS(DECL_ARGS);
static void post_SH(DECL_ARGS);
static void post_SS(DECL_ARGS);
+static void post_SY(DECL_ARGS);
static void post_TP(DECL_ARGS);
static void post_UR(DECL_ARGS);
@@ -124,6 +126,8 @@ static const struct man_term_act man_term_acts[MAN_MAX - MAN_TH] = {
{ pre_PD, NULL, MAN_NOTEXT }, /* PD */
{ pre_ign, NULL, 0 }, /* AT */
{ pre_in, NULL, MAN_NOTEXT }, /* in */
+ { pre_SY, post_SY, 0 }, /* SY */
+ { NULL, NULL, 0 }, /* YS */
{ pre_OP, NULL, 0 }, /* OP */
{ pre_literal, NULL, 0 }, /* EX */
{ pre_literal, NULL, 0 }, /* EE */
@@ -849,6 +853,62 @@ post_RS(DECL_ARGS)
}
static int
+pre_SY(DECL_ARGS)
+{
+ const struct roff_node *nn;
+ int len;
+
+ switch (n->type) {
+ case ROFFT_BLOCK:
+ print_bvspace(p, n, mt->pardist);
+ return 1;
+ case ROFFT_HEAD:
+ case ROFFT_BODY:
+ break;
+ default:
+ abort();
+ }
+
+ nn = n->parent->head->child;
+ len = nn == NULL ? 0 : term_strlen(p, nn->string) + 1;
+
+ switch (n->type) {
+ case ROFFT_HEAD:
+ p->tcol->offset = mt->offset;
+ p->tcol->rmargin = mt->offset + len;
+ p->flags |= TERMP_NOBREAK;
+ term_fontrepl(p, TERMFONT_BOLD);
+ break;
+ case ROFFT_BODY:
+ mt->lmargin[mt->lmargincur] = len;
+ p->tcol->offset = mt->offset + len;
+ p->tcol->rmargin = p->maxrmargin;
+ p->flags |= TERMP_NOSPACE;
+ break;
+ default:
+ abort();
+ }
+ return 1;
+}
+
+static void
+post_SY(DECL_ARGS)
+{
+ switch (n->type) {
+ case ROFFT_HEAD:
+ term_flushln(p);
+ p->flags &= ~TERMP_NOBREAK;
+ break;
+ case ROFFT_BODY:
+ term_newln(p);
+ p->tcol->offset = mt->offset;
+ break;
+ default:
+ break;
+ }
+}
+
+static int
pre_UR(DECL_ARGS)
{
diff --git a/man_validate.c b/man_validate.c
index 8a1c33e9..fb859562 100644
--- a/man_validate.c
+++ b/man_validate.c
@@ -85,6 +85,8 @@ static const v_check man_valids[MAN_MAX - MAN_TH] = {
NULL, /* PD */
post_AT, /* AT */
post_in, /* in */
+ NULL, /* SY */
+ NULL, /* YS */
post_OP, /* OP */
NULL, /* EX */
NULL, /* EE */
diff --git a/roff.c b/roff.c
index ea01b57f..91f4b1fb 100644
--- a/roff.c
+++ b/roff.c
@@ -335,7 +335,8 @@ const char *__roff_name[MAN_MAX + 1] = {
"nf", "fi",
"RE", "RS", "DT", "UC",
"PD", "AT", "in",
- "OP", "EX", "EE", "UR",
+ "SY", "YS", "OP",
+ "EX", "EE", "UR",
"UE", "MT", "ME", NULL
};
const char *const *roff_name = __roff_name;
diff --git a/roff.h b/roff.h
index cb00c0a3..5cc8c15e 100644
--- a/roff.h
+++ b/roff.h
@@ -1,7 +1,7 @@
/* $Id$ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2013, 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2013,2014,2015,2017,2018 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
@@ -464,6 +464,8 @@ enum roff_tok {
MAN_PD,
MAN_AT,
MAN_in,
+ MAN_SY,
+ MAN_YS,
MAN_OP,
MAN_EX,
MAN_EE,