From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost (fantadrom.bsd.lv [local]) by fantadrom.bsd.lv (OpenSMTPD) with ESMTPA id fae646ed for ; Fri, 17 Aug 2018 21:08:57 -0500 (EST) Date: Fri, 17 Aug 2018 21:08:57 -0500 (EST) X-Mailinglist: mandoc-source Reply-To: source@mandoc.bsd.lv MIME-Version: 1.0 From: schwarze@mandoc.bsd.lv To: source@mandoc.bsd.lv Subject: mandoc: implement the GNU man-ext .SY/.YS (synopsis block) macro in X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Message-Id: Log Message: ----------- implement the GNU man-ext .SY/.YS (synopsis block) macro in man(7), used in most manual pages of the groff package Modified Files: -------------- mandoc: LICENSE TODO man.7 man_html.c man_macro.c man_term.c man_validate.c roff.c roff.h Revision Data ------------- Index: man_term.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/man_term.c,v retrieving revision 1.214 retrieving revision 1.215 diff -Lman_term.c -Lman_term.c -u -p -r1.214 -r1.215 --- man_term.c +++ 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_ter { 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) if (--mt->lmarginsz < MAXMARGINS) 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 Index: roff.h =================================================================== RCS file: /home/cvs/mandoc/mandoc/roff.h,v retrieving revision 1.60 retrieving revision 1.61 diff -Lroff.h -Lroff.h -u -p -r1.60 -r1.61 --- roff.h +++ roff.h @@ -1,7 +1,7 @@ /* $Id$ */ /* * 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, Index: LICENSE =================================================================== RCS file: /home/cvs/mandoc/mandoc/LICENSE,v retrieving revision 1.19 retrieving revision 1.20 diff -LLICENSE -LLICENSE -u -p -r1.19 -r1.20 --- LICENSE +++ LICENSE @@ -12,6 +12,7 @@ Copyright (c) 2013 Franco Fichtner Copyright (c) 2016 Ed Maste Copyright (c) 2017 Michael Stapelberg +Copyright (c) 2017 Anthony Bentley Copyright (c) 1998, 2004, 2010 Todd C. Miller Copyright (c) 2008, 2017 Otto Moerbeek Copyright (c) 2004 Ted Unangst Index: TODO =================================================================== RCS file: /home/cvs/mandoc/mandoc/TODO,v retrieving revision 1.265 retrieving revision 1.266 diff -LTODO -LTODO -u -p -r1.265 -r1.266 --- TODO +++ 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. Index: roff.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/roff.c,v retrieving revision 1.332 retrieving revision 1.333 diff -Lroff.c -Lroff.c -u -p -r1.332 -r1.333 --- roff.c +++ 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; Index: man_html.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/man_html.c,v retrieving revision 1.155 retrieving revision 1.156 diff -Lman_html.c -Lman_html.c -u -p -r1.155 -r1.156 --- man_html.c +++ 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_htm { 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 */ @@ -618,6 +621,27 @@ man_RS_pre(MAN_ARGS) return 0; if (n->type == ROFFT_BLOCK) print_otag(h, TAG_DIV, "c", "Bd-indent"); + 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; } Index: man_validate.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/man_validate.c,v retrieving revision 1.136 retrieving revision 1.137 diff -Lman_validate.c -Lman_validate.c -u -p -r1.136 -r1.137 --- man_validate.c +++ man_validate.c @@ -85,6 +85,8 @@ static const v_check man_valids[MAN_MAX NULL, /* PD */ post_AT, /* AT */ post_in, /* in */ + NULL, /* SY */ + NULL, /* YS */ post_OP, /* OP */ NULL, /* EX */ NULL, /* EE */ Index: man.7 =================================================================== RCS file: /home/cvs/mandoc/mandoc/man.7,v retrieving revision 1.138 retrieving revision 1.139 diff -Lman.7 -Lman.7 -u -p -r1.138 -r1.139 --- man.7 +++ man.7 @@ -1,7 +1,8 @@ .\" $Id$ .\" .\" 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 @@ -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 . Index: man_macro.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/man_macro.c,v retrieving revision 1.127 retrieving revision 1.128 diff -Lman_macro.c -Lman_macro.c -u -p -r1.127 -r1.128 --- man_macro.c +++ man_macro.c @@ -71,6 +71,8 @@ static const struct man_macro man_macros { 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 */ @@ -222,6 +224,9 @@ blk_close(MACRO_PROT_ARGS) line, ppos, "RE %d", target); return; } + break; + case MAN_YS: + ntok = MAN_SY; break; case MAN_UE: ntok = MAN_UR; -- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv