* mandoc: Up to version 1.22.4, groff_mdoc(7) only considered the first
@ 2022-08-19 12:59 schwarze
0 siblings, 0 replies; only message in thread
From: schwarze @ 2022-08-19 12:59 UTC (permalink / raw)
To: source
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 <schwarze@openbsd.org>
+ * Copyright (c) 2014,2015,2017,2018,2022 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
@@ -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 @@ S\bSE\bEE\bE A\bAL\bLS\bSO\bO
author, _\bj_\bo_\bu_\br_\bn_\ba_\bl, 42.
S\bSE\bEE\bE _\bA_\bL_\bS_\bO
- reference after a blank line:
+ reference on the same line: author, _\bj_\bo_\bu_\br_\bn_\ba_\bl, 42.
- author, _\bj_\bo_\bu_\br_\bn_\ba_\bl, 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 @@ S\bSE\bEE\bE A\bAL\bLS\bSO\bO
author, _\bj_\bo_\bu_\br_\bn_\ba_\bl, 42.
S\bSE\bEE\bE _\bA_\bL_\bS_\bO
- reference after a blank line:
+ reference on the same line: author, _\bj_\bo_\bu_\br_\bn_\ba_\bl, 42.
- author, _\bj_\bo_\bu_\br_\bn_\ba_\bl, 42.
-
-OpenBSD July 4, 2017 OpenBSD
+OpenBSD August 19, 2022 OpenBSD
--
To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-08-19 12:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-19 12:59 mandoc: Up to version 1.22.4, groff_mdoc(7) only considered the first schwarze
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).