From: schwarze Date: Sat, 18 Aug 2018 02:03:41 +0000 (+0000) Subject: implement the GNU man-ext .SY/.YS (synopsis block) macro in man, X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5e5a9c6148e1b705903cbeca01022c7077619321;p=openbsd implement the GNU man-ext .SY/.YS (synopsis block) macro in man, used in most manual pages of the groff package --- diff --git a/share/man/man7/man.7 b/share/man/man7/man.7 index db988002887..faaaeca9010 100644 --- a/share/man/man7/man.7 +++ b/share/man/man7/man.7 @@ -1,7 +1,8 @@ -.\" $OpenBSD: man.7,v 1.50 2018/08/16 23:40:19 schwarze Exp $ +.\" $OpenBSD: man.7,v 1.51 2018/08/18 02:03:41 schwarze Exp $ .\" .\" Copyright (c) 2009, 2010, 2011, 2012 Kristaps Dzonsons -.\" Copyright (c) 2011-2015 Ingo Schwarze +.\" Copyright (c) 2011-2015, 2017, 2018 Ingo Schwarze +.\" Copyright (c) 2017 Anthony Bentley .\" Copyright (c) 2010 Joerg Sonnenberger .\" .\" Permission to use, copy, modify, and distribute this software for any @@ -16,7 +17,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: August 16 2018 $ +.Dd $Mdocdate: August 18 2018 $ .Dt MAN 7 .Os .Sh NAME @@ -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/usr.bin/mandoc/man_html.c b/usr.bin/mandoc/man_html.c index 9f1867071b5..a0ef1f75a51 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.108 2018/08/17 20:31:52 schwarze Exp $ */ +/* $OpenBSD: man_html.c,v 1.109 2018/08/18 02:03:41 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons * Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze @@ -59,6 +59,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); @@ -99,6 +100,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 */ @@ -619,6 +622,27 @@ man_RS_pre(MAN_ARGS) return 1; } +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) { diff --git a/usr.bin/mandoc/man_macro.c b/usr.bin/mandoc/man_macro.c index 30c26ba4da2..7e760adb45f 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.89 2018/08/17 20:31:52 schwarze Exp $ */ +/* $OpenBSD: man_macro.c,v 1.90 2018/08/18 02:03:41 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2012-2015, 2017, 2018 Ingo Schwarze @@ -69,6 +69,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 */ @@ -221,6 +223,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/usr.bin/mandoc/man_term.c b/usr.bin/mandoc/man_term.c index d4a7708989e..bdcd51af32c 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.167 2018/08/17 20:31:52 schwarze Exp $ */ +/* $OpenBSD: man_term.c,v 1.168 2018/08/18 02:03:41 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2015, 2017, 2018 Ingo Schwarze @@ -76,6 +76,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); @@ -88,6 +89,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); @@ -122,6 +124,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 */ @@ -846,6 +850,62 @@ post_RS(DECL_ARGS) mt->lmargincur = mt->lmarginsz; } +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/usr.bin/mandoc/man_validate.c b/usr.bin/mandoc/man_validate.c index 01e38bc6f83..c0d1a6f9a65 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.107 2018/08/16 23:40:19 schwarze Exp $ */ +/* $OpenBSD: man_validate.c,v 1.108 2018/08/18 02:03:41 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2012-2018 Ingo Schwarze @@ -83,6 +83,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/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c index c2f6f982300..364c6b1cb79 100644 --- a/usr.bin/mandoc/roff.c +++ b/usr.bin/mandoc/roff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: roff.c,v 1.204 2018/08/16 23:40:19 schwarze Exp $ */ +/* $OpenBSD: roff.c,v 1.205 2018/08/18 02:03:41 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons * Copyright (c) 2010-2015, 2017, 2018 Ingo Schwarze @@ -333,7 +333,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/usr.bin/mandoc/roff.h b/usr.bin/mandoc/roff.h index 1c5fd059b12..3fa35361f79 100644 --- a/usr.bin/mandoc/roff.h +++ b/usr.bin/mandoc/roff.h @@ -1,7 +1,7 @@ -/* $OpenBSD: roff.h,v 1.42 2018/08/16 23:40:19 schwarze Exp $ */ +/* $OpenBSD: roff.h,v 1.43 2018/08/18 02:03:41 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons - * Copyright (c) 2013, 2014, 2015, 2017 Ingo Schwarze + * Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze * * 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,