From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 20149 invoked from network); 19 Aug 2022 12:59:32 -0000 Received: from bsd.lv (HELO mandoc.bsd.lv) (66.111.2.12) by inbox.vuxu.org with ESMTPUTF8; 19 Aug 2022 12:59:32 -0000 Received: from fantadrom.bsd.lv (localhost [127.0.0.1]) by mandoc.bsd.lv (OpenSMTPD) with ESMTP id 7063ad85 for ; Fri, 19 Aug 2022 07:59:28 -0500 (EST) Received: from localhost (mandoc.bsd.lv [local]) by mandoc.bsd.lv (OpenSMTPD) with ESMTPA id 91cbf2b5 for ; Fri, 19 Aug 2022 07:59:28 -0500 (EST) Date: Fri, 19 Aug 2022 07:59:28 -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: Up to version 1.22.4, groff_mdoc(7) only considered the first X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Message-ID: <336a761f9c256e9a@mandoc.bsd.lv> Log Message: ----------- Up to version 1.22.4, groff_mdoc(7) only considered the first word when comparing section headers. For example, ".Sh SEE ELSEWHERE" and ".Sh SEE Em ALSO" were considered instances of a SEE ALSO section. In groff-current, exact matches with no sub-macros are required. Adjust mandoc behaviour. While here, also fix a very minor mandoc bug, even though no detrimental effect of the bug on formatting is known. While using sub-macros in the .Sh HEAD is bad style, the parsers accept it, so setting the section attribute on the HEAD needs to act recursively. Modified Files: -------------- mandoc: mdoc_state.c mandoc/regress/mdoc/Rs: break.in break.out_ascii break.out_markdown break.out_utf8 Revision Data ------------- Index: mdoc_state.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/mdoc_state.c,v retrieving revision 1.18 retrieving revision 1.19 diff -Lmdoc_state.c -Lmdoc_state.c -u -p -r1.18 -r1.19 --- mdoc_state.c +++ mdoc_state.c @@ -1,6 +1,6 @@ /* $Id$ */ /* - * Copyright (c) 2014, 2015, 2017, 2021 Ingo Schwarze + * Copyright (c) 2014,2015,2017,2018,2022 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 @@ -37,6 +37,7 @@ typedef void (*state_handler)(STATE_ARGS); +static void setsec(struct roff_node *, enum roff_sec); static void state_bl(STATE_ARGS); static void state_sh(STATE_ARGS); static void state_sm(STATE_ARGS); @@ -208,35 +209,36 @@ state_bl(STATE_ARGS) } static void -state_sh(STATE_ARGS) +setsec(struct roff_node *n, enum roff_sec sec) { struct roff_node *nch; - char *secname; + + n->sec = sec; + for (nch = n->child; nch != NULL; nch = nch->next) + setsec(nch, sec); +} + +/* + * Set the section attribute for the BLOCK, HEAD, and HEAD children. + * For other nodes, including the .Sh BODY, this is done when allocating + * the node data structures, but for .Sh BLOCK and HEAD, the section is + * still unknown at that time. + */ +static void +state_sh(STATE_ARGS) +{ + enum roff_sec sec; if (n->type != ROFFT_HEAD) return; - if ( ! (n->flags & NODE_VALID)) { - secname = NULL; - deroff(&secname, n); - - /* - * Set the section attribute for the BLOCK, HEAD, - * and HEAD children; the latter can only be TEXT - * nodes, so no recursion is needed. For other - * nodes, including the .Sh BODY, this is done - * when allocating the node data structures, but - * for .Sh BLOCK and HEAD, the section is still - * unknown at that time. - */ - - n->sec = n->parent->sec = secname == NULL ? - SEC_CUSTOM : mdoc_a2sec(secname); - for (nch = n->child; nch != NULL; nch = nch->next) - nch->sec = n->sec; - free(secname); + if ((n->flags & NODE_VALID) == 0) { + sec = n->child != NULL && n->child->type == ROFFT_TEXT && + n->child->next == NULL ? mdoc_a2sec(n->child->string) : + SEC_CUSTOM; + n->parent->sec = sec; + setsec(n, sec); } - if ((mdoc->lastsec = n->sec) == SEC_SYNOPSIS) { roff_setreg(mdoc->roff, "nS", 1, '='); mdoc->flags |= MDOC_SYNOPSIS; Index: break.out_markdown =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Rs/break.out_markdown,v retrieving revision 1.2 retrieving revision 1.3 diff -Lregress/mdoc/Rs/break.out_markdown -Lregress/mdoc/Rs/break.out_markdown -u -p -r1.2 -r1.3 --- regress/mdoc/Rs/break.out_markdown +++ regress/mdoc/Rs/break.out_markdown @@ -21,10 +21,9 @@ author, # SEE *ALSO* -reference after a blank line: - +reference on the same line: author, *journal*, 42\. -OpenBSD - July 4, 2017 +OpenBSD - August 19, 2022 Index: break.in =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Rs/break.in,v retrieving revision 1.2 retrieving revision 1.3 diff -Lregress/mdoc/Rs/break.in -Lregress/mdoc/Rs/break.in -u -p -r1.2 -r1.3 --- regress/mdoc/Rs/break.in +++ regress/mdoc/Rs/break.in @@ -1,4 +1,4 @@ -.\" $OpenBSD: break.in,v 1.5 2017/07/04 14:53:26 schwarze Exp $ +.\" $OpenBSD: break.in,v 1.6 2022/08/19 12:49:36 schwarze Exp $ .Dd $Mdocdate$ .Dt RS-BREAK 1 .Os @@ -20,7 +20,7 @@ reference after a blank line: .%N 42 .Re .Sh SEE Em ALSO -reference after a blank line: +reference on the same line: .Rs .%A author .%J journal Index: break.out_utf8 =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Rs/break.out_utf8,v retrieving revision 1.2 retrieving revision 1.3 diff -Lregress/mdoc/Rs/break.out_utf8 -Lregress/mdoc/Rs/break.out_utf8 -u -p -r1.2 -r1.3 --- regress/mdoc/Rs/break.out_utf8 +++ regress/mdoc/Rs/break.out_utf8 @@ -12,8 +12,6 @@ SSEEEE AALLSSOO author, _j_o_u_r_n_a_l, 42. SSEEEE _A_L_S_O - reference after a blank line: + reference on the same line: author, _j_o_u_r_n_a_l, 42. - author, _j_o_u_r_n_a_l, 42. - -OpenBSD July 4, 2017 OpenBSD +OpenBSD August 19, 2022 OpenBSD Index: break.out_ascii =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Rs/break.out_ascii,v retrieving revision 1.2 retrieving revision 1.3 diff -Lregress/mdoc/Rs/break.out_ascii -Lregress/mdoc/Rs/break.out_ascii -u -p -r1.2 -r1.3 --- regress/mdoc/Rs/break.out_ascii +++ regress/mdoc/Rs/break.out_ascii @@ -12,8 +12,6 @@ SSEEEE AALLSSOO author, _j_o_u_r_n_a_l, 42. SSEEEE _A_L_S_O - reference after a blank line: + reference on the same line: author, _j_o_u_r_n_a_l, 42. - author, _j_o_u_r_n_a_l, 42. - -OpenBSD July 4, 2017 OpenBSD +OpenBSD August 19, 2022 OpenBSD -- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv