summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2020-04-01 20:10:17 +0000
committerschwarze <schwarze@openbsd.org>2020-04-01 20:10:17 +0000
commitba1a607627d994e26a3f78625de29a0f013288c5 (patch)
treef0cdb2eb14bb3217f4d0e9784798683234ddc83e
parentIf no -q options are used, expose first 8 midi(4) devices to sndiod clients (diff)
downloadwireguard-openbsd-ba1a607627d994e26a3f78625de29a0f013288c5.tar.xz
wireguard-openbsd-ba1a607627d994e26a3f78625de29a0f013288c5.zip
Just like we are already doing it in HTML output, automatically tag
section and subsection headers in terminal output, too. Even though admittedly, commands like "/SEE" and "/ Subsec" work, too, there is no downside, and besides, with the recent improvements in the tagging framework, implementation cost is negligible.
-rw-r--r--regress/usr.bin/mandoc/mdoc/Cm/tag.out_tag2
-rw-r--r--regress/usr.bin/mandoc/mdoc/Dv/tag.out_tag2
-rw-r--r--regress/usr.bin/mandoc/mdoc/Em/tag.out_tag2
-rw-r--r--regress/usr.bin/mandoc/mdoc/Er/tag.out_tag3
-rw-r--r--regress/usr.bin/mandoc/mdoc/Ev/tag.out_tag2
-rw-r--r--regress/usr.bin/mandoc/mdoc/Fl/tag.out_tag2
-rw-r--r--regress/usr.bin/mandoc/mdoc/Fo/tag.out_tag2
-rw-r--r--regress/usr.bin/mandoc/mdoc/Ic/tag.out_tag2
-rw-r--r--regress/usr.bin/mandoc/mdoc/Li/tag.out_tag2
-rw-r--r--regress/usr.bin/mandoc/mdoc/Ms/tag.out_tag2
-rw-r--r--regress/usr.bin/mandoc/mdoc/No/tag.out_tag2
-rw-r--r--regress/usr.bin/mandoc/mdoc/Sh/Makefile5
-rw-r--r--regress/usr.bin/mandoc/mdoc/Sh/tag.in10
-rw-r--r--regress/usr.bin/mandoc/mdoc/Sh/tag.out_ascii11
-rw-r--r--regress/usr.bin/mandoc/mdoc/Sh/tag.out_html14
-rw-r--r--regress/usr.bin/mandoc/mdoc/Sh/tag.out_lint3
-rw-r--r--regress/usr.bin/mandoc/mdoc/Sh/tag.out_markdown14
-rw-r--r--regress/usr.bin/mandoc/mdoc/Sh/tag.out_tag7
-rw-r--r--regress/usr.bin/mandoc/mdoc/Sy/tag.out_tag2
-rw-r--r--regress/usr.bin/mandoc/mdoc/Tg/warn.out_tag2
-rw-r--r--usr.bin/mandoc/mdoc_html.c4
-rw-r--r--usr.bin/mandoc/mdoc_validate.c62
22 files changed, 124 insertions, 33 deletions
diff --git a/regress/usr.bin/mandoc/mdoc/Cm/tag.out_tag b/regress/usr.bin/mandoc/mdoc/Cm/tag.out_tag
index 0b97edbcf0f..3a3a6b138f6 100644
--- a/regress/usr.bin/mandoc/mdoc/Cm/tag.out_tag
+++ b/regress/usr.bin/mandoc/mdoc/Cm/tag.out_tag
@@ -1,3 +1,5 @@
+NAME 3
+DESCRIPTION 6
one 9
two 9
three 12
diff --git a/regress/usr.bin/mandoc/mdoc/Dv/tag.out_tag b/regress/usr.bin/mandoc/mdoc/Dv/tag.out_tag
index 94f0cfb2c0d..848d769fae7 100644
--- a/regress/usr.bin/mandoc/mdoc/Dv/tag.out_tag
+++ b/regress/usr.bin/mandoc/mdoc/Dv/tag.out_tag
@@ -1,3 +1,5 @@
+NAME 3
+DESCRIPTION 6
one 9
two 9
three 12
diff --git a/regress/usr.bin/mandoc/mdoc/Em/tag.out_tag b/regress/usr.bin/mandoc/mdoc/Em/tag.out_tag
index c2fbaf59646..dd032f4f1f0 100644
--- a/regress/usr.bin/mandoc/mdoc/Em/tag.out_tag
+++ b/regress/usr.bin/mandoc/mdoc/Em/tag.out_tag
@@ -1,3 +1,5 @@
+NAME 3
+DESCRIPTION 6
one 9
two 9
three 12
diff --git a/regress/usr.bin/mandoc/mdoc/Er/tag.out_tag b/regress/usr.bin/mandoc/mdoc/Er/tag.out_tag
index b00a67187e0..c074e6cdadf 100644
--- a/regress/usr.bin/mandoc/mdoc/Er/tag.out_tag
+++ b/regress/usr.bin/mandoc/mdoc/Er/tag.out_tag
@@ -1,2 +1,5 @@
+NAME 3
+DESCRIPTION 6
two 10
+ERRORS 12
ENOENT 13
diff --git a/regress/usr.bin/mandoc/mdoc/Ev/tag.out_tag b/regress/usr.bin/mandoc/mdoc/Ev/tag.out_tag
index 94f0cfb2c0d..848d769fae7 100644
--- a/regress/usr.bin/mandoc/mdoc/Ev/tag.out_tag
+++ b/regress/usr.bin/mandoc/mdoc/Ev/tag.out_tag
@@ -1,3 +1,5 @@
+NAME 3
+DESCRIPTION 6
one 9
two 9
three 12
diff --git a/regress/usr.bin/mandoc/mdoc/Fl/tag.out_tag b/regress/usr.bin/mandoc/mdoc/Fl/tag.out_tag
index 89a94151c0d..a3710cac4a1 100644
--- a/regress/usr.bin/mandoc/mdoc/Fl/tag.out_tag
+++ b/regress/usr.bin/mandoc/mdoc/Fl/tag.out_tag
@@ -1,3 +1,5 @@
+NAME 3
+DESCRIPTION 6
a 9
b 9
c 12
diff --git a/regress/usr.bin/mandoc/mdoc/Fo/tag.out_tag b/regress/usr.bin/mandoc/mdoc/Fo/tag.out_tag
index 2387023c8f4..901861d18d4 100644
--- a/regress/usr.bin/mandoc/mdoc/Fo/tag.out_tag
+++ b/regress/usr.bin/mandoc/mdoc/Fo/tag.out_tag
@@ -1,3 +1,5 @@
+NAME 3
+DESCRIPTION 6
first 9
second 11
e3 13
diff --git a/regress/usr.bin/mandoc/mdoc/Ic/tag.out_tag b/regress/usr.bin/mandoc/mdoc/Ic/tag.out_tag
index 94f0cfb2c0d..848d769fae7 100644
--- a/regress/usr.bin/mandoc/mdoc/Ic/tag.out_tag
+++ b/regress/usr.bin/mandoc/mdoc/Ic/tag.out_tag
@@ -1,3 +1,5 @@
+NAME 3
+DESCRIPTION 6
one 9
two 9
three 12
diff --git a/regress/usr.bin/mandoc/mdoc/Li/tag.out_tag b/regress/usr.bin/mandoc/mdoc/Li/tag.out_tag
index 94f0cfb2c0d..848d769fae7 100644
--- a/regress/usr.bin/mandoc/mdoc/Li/tag.out_tag
+++ b/regress/usr.bin/mandoc/mdoc/Li/tag.out_tag
@@ -1,3 +1,5 @@
+NAME 3
+DESCRIPTION 6
one 9
two 9
three 12
diff --git a/regress/usr.bin/mandoc/mdoc/Ms/tag.out_tag b/regress/usr.bin/mandoc/mdoc/Ms/tag.out_tag
index 94f0cfb2c0d..848d769fae7 100644
--- a/regress/usr.bin/mandoc/mdoc/Ms/tag.out_tag
+++ b/regress/usr.bin/mandoc/mdoc/Ms/tag.out_tag
@@ -1,3 +1,5 @@
+NAME 3
+DESCRIPTION 6
one 9
two 9
three 12
diff --git a/regress/usr.bin/mandoc/mdoc/No/tag.out_tag b/regress/usr.bin/mandoc/mdoc/No/tag.out_tag
index 94f0cfb2c0d..848d769fae7 100644
--- a/regress/usr.bin/mandoc/mdoc/No/tag.out_tag
+++ b/regress/usr.bin/mandoc/mdoc/No/tag.out_tag
@@ -1,3 +1,5 @@
+NAME 3
+DESCRIPTION 6
one 9
two 9
three 12
diff --git a/regress/usr.bin/mandoc/mdoc/Sh/Makefile b/regress/usr.bin/mandoc/mdoc/Sh/Makefile
index 4b37bb2abe0..ea21e5025fd 100644
--- a/regress/usr.bin/mandoc/mdoc/Sh/Makefile
+++ b/regress/usr.bin/mandoc/mdoc/Sh/Makefile
@@ -1,11 +1,12 @@
-# $OpenBSD: Makefile,v 1.13 2020/02/27 21:38:27 schwarze Exp $
+# $OpenBSD: Makefile,v 1.14 2020/04/01 20:10:18 schwarze Exp $
REGRESS_TARGETS = badNAME before empty emptyNAME first nohead order
REGRESS_TARGETS += orderNAME paragraph parbefore parborder punctNAME
REGRESS_TARGETS += subbefore tag transp
LINT_TARGETS = badNAME before empty emptyNAME first nohead order
-LINT_TARGETS += orderNAME parbefore parborder punctNAME subbefore
+LINT_TARGETS += orderNAME parbefore parborder punctNAME subbefore tag
HTML_TARGETS = paragraph tag
+TAG_TARGETS = tag
# groff-1.22.3 defects:
# - .Pp before .Sh NAME causes a blank line before the header line
diff --git a/regress/usr.bin/mandoc/mdoc/Sh/tag.in b/regress/usr.bin/mandoc/mdoc/Sh/tag.in
index 0e0e5fef16e..da8a884a200 100644
--- a/regress/usr.bin/mandoc/mdoc/Sh/tag.in
+++ b/regress/usr.bin/mandoc/mdoc/Sh/tag.in
@@ -1,5 +1,5 @@
-.\" $OpenBSD: tag.in,v 1.1 2020/02/27 21:38:27 schwarze Exp $
-.Dd $Mdocdate: February 27 2020 $
+.\" $OpenBSD: tag.in,v 1.2 2020/04/01 20:10:18 schwarze Exp $
+.Dd $Mdocdate: April 1 2020 $
.Dt SH-TAG 1
.Os
.Sh NAME
@@ -11,11 +11,17 @@ Text in the description.
BEGINTEST
.Pp
Text in the subsection.
+.Sh DESCRIPTION
+Text in duplicate description section.
.Tg examples
.Sh EXAMPLES
Text introducing examples.
.Tg example
.Ss Subsection
Example text.
+.Sh "\& WEIRD SECTION "
+Text in weird section.
+.Sh \ \&
+Text in section with empty header.
.Pp
ENDTEST
diff --git a/regress/usr.bin/mandoc/mdoc/Sh/tag.out_ascii b/regress/usr.bin/mandoc/mdoc/Sh/tag.out_ascii
index df0ab050a1e..309cb5597bf 100644
--- a/regress/usr.bin/mandoc/mdoc/Sh/tag.out_ascii
+++ b/regress/usr.bin/mandoc/mdoc/Sh/tag.out_ascii
@@ -11,12 +11,21 @@ DDEESSCCRRIIPPTTIIOONN
Text in the subsection.
+DDEESSCCRRIIPPTTIIOONN
+ Text in duplicate description section.
+
EEXXAAMMPPLLEESS
Text introducing examples.
SSuubbsseeccttiioonn
Example text.
+ WWEEIIRRDD SSEECCTTIIOONN
+ Text in weird section.
+
+
+ Text in section with empty header.
+
ENDTEST
-OpenBSD February 27, 2020 OpenBSD
+OpenBSD April 1, 2020 OpenBSD
diff --git a/regress/usr.bin/mandoc/mdoc/Sh/tag.out_html b/regress/usr.bin/mandoc/mdoc/Sh/tag.out_html
index 9722aa8c3c5..49c45fdb18e 100644
--- a/regress/usr.bin/mandoc/mdoc/Sh/tag.out_html
+++ b/regress/usr.bin/mandoc/mdoc/Sh/tag.out_html
@@ -2,8 +2,22 @@
</section>
</section>
<section class="Sh">
+<h1 class="Sh" id="DESCRIPTION_2"><a class="permalink" href="#DESCRIPTION_2">DESCRIPTION</a></h1>
+<p class="Pp">Text in duplicate description section.</p>
+</section>
+<section class="Sh">
<h1 class="Sh" id="examples"><a class="permalink" href="#examples">EXAMPLES</a></h1>
<p class="Pp">Text introducing examples.</p>
<section class="Ss">
<h2 class="Ss" id="example"><a class="permalink" href="#example">Subsection</a></h2>
<p class="Pp">Example text.</p>
+</section>
+</section>
+<section class="Sh">
+<h1 class="Sh" id="WEIRD_SECTION"><a class="permalink" href="#WEIRD_SECTION">
+ WEIRD SECTION </a></h1>
+<p class="Pp">Text in weird section.</p>
+</section>
+<section class="Sh">
+<h1 class="Sh">&#x00A0;</h1>
+<p class="Pp">Text in section with empty header.</p>
diff --git a/regress/usr.bin/mandoc/mdoc/Sh/tag.out_lint b/regress/usr.bin/mandoc/mdoc/Sh/tag.out_lint
new file mode 100644
index 00000000000..cfb1dfad13e
--- /dev/null
+++ b/regress/usr.bin/mandoc/mdoc/Sh/tag.out_lint
@@ -0,0 +1,3 @@
+mandoc: tag.in:14:2: WARNING: duplicate section title: Sh DESCRIPTION
+mandoc: tag.in:22:7: WARNING: tab in filled text
+mandoc: tag.in:22:22: WARNING: tab in filled text
diff --git a/regress/usr.bin/mandoc/mdoc/Sh/tag.out_markdown b/regress/usr.bin/mandoc/mdoc/Sh/tag.out_markdown
index 2813f8f0d28..75a1e58e437 100644
--- a/regress/usr.bin/mandoc/mdoc/Sh/tag.out_markdown
+++ b/regress/usr.bin/mandoc/mdoc/Sh/tag.out_markdown
@@ -14,6 +14,10 @@ BEGINTEST
Text in the subsection.
+# DESCRIPTION
+
+Text in duplicate description section.
+
# EXAMPLES
Text introducing examples.
@@ -22,6 +26,14 @@ Text introducing examples.
Example text.
+# WEIRD SECTION
+
+Text in weird section.
+
+# &#160;
+
+Text in section with empty header.
+
ENDTEST
-OpenBSD - February 27, 2020
+OpenBSD - April 1, 2020
diff --git a/regress/usr.bin/mandoc/mdoc/Sh/tag.out_tag b/regress/usr.bin/mandoc/mdoc/Sh/tag.out_tag
new file mode 100644
index 00000000000..04b11882b7d
--- /dev/null
+++ b/regress/usr.bin/mandoc/mdoc/Sh/tag.out_tag
@@ -0,0 +1,7 @@
+NAME 3
+DESCRIPTION 6
+Subsection 9
+DESCRIPTION 14
+examples 17
+example 20
+WEIRD_SECTION 23
diff --git a/regress/usr.bin/mandoc/mdoc/Sy/tag.out_tag b/regress/usr.bin/mandoc/mdoc/Sy/tag.out_tag
index c2fbaf59646..dd032f4f1f0 100644
--- a/regress/usr.bin/mandoc/mdoc/Sy/tag.out_tag
+++ b/regress/usr.bin/mandoc/mdoc/Sy/tag.out_tag
@@ -1,3 +1,5 @@
+NAME 3
+DESCRIPTION 6
one 9
two 9
three 12
diff --git a/regress/usr.bin/mandoc/mdoc/Tg/warn.out_tag b/regress/usr.bin/mandoc/mdoc/Tg/warn.out_tag
index e1fc141c346..6426c3b57e3 100644
--- a/regress/usr.bin/mandoc/mdoc/Tg/warn.out_tag
+++ b/regress/usr.bin/mandoc/mdoc/Tg/warn.out_tag
@@ -1,3 +1,5 @@
+NAME 3
+DESCRIPTION 6
start 9
macro 9
sub 9
diff --git a/usr.bin/mandoc/mdoc_html.c b/usr.bin/mandoc/mdoc_html.c
index e20126a9bd4..5bf9519941f 100644
--- a/usr.bin/mandoc/mdoc_html.c
+++ b/usr.bin/mandoc/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_html.c,v 1.211 2020/03/13 00:31:05 schwarze Exp $ */
+/* $OpenBSD: mdoc_html.c,v 1.212 2020/04/01 20:10:17 schwarze Exp $ */
/*
* Copyright (c) 2014-2020 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -567,7 +567,6 @@ mdoc_sh_pre(MDOC_ARGS)
print_otag(h, TAG_SECTION, "c", "Sh");
break;
case ROFFT_HEAD:
- n->flags |= NODE_ID;
print_otag_id(h, TAG_H1, "Sh", n);
break;
case ROFFT_BODY:
@@ -589,7 +588,6 @@ mdoc_ss_pre(MDOC_ARGS)
print_otag(h, TAG_SECTION, "c", "Ss");
break;
case ROFFT_HEAD:
- n->flags |= NODE_ID;
print_otag_id(h, TAG_H2, "Ss", n);
break;
case ROFFT_BODY:
diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c
index c5497fb87f2..689cab24a95 100644
--- a/usr.bin/mandoc/mdoc_validate.c
+++ b/usr.bin/mandoc/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_validate.c,v 1.295 2020/03/13 00:31:05 schwarze Exp $ */
+/* $OpenBSD: mdoc_validate.c,v 1.296 2020/04/01 20:10:17 schwarze Exp $ */
/*
* Copyright (c) 2010-2020 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -94,7 +94,6 @@ static void post_fn(POST_ARGS);
static void post_fname(POST_ARGS);
static void post_fo(POST_ARGS);
static void post_hyph(POST_ARGS);
-static void post_ignpar(POST_ARGS);
static void post_it(POST_ARGS);
static void post_lb(POST_ARGS);
static void post_nd(POST_ARGS);
@@ -107,6 +106,7 @@ static void post_prevpar(POST_ARGS);
static void post_root(POST_ARGS);
static void post_rs(POST_ARGS);
static void post_rv(POST_ARGS);
+static void post_section(POST_ARGS);
static void post_sh(POST_ARGS);
static void post_sh_head(POST_ARGS);
static void post_sh_name(POST_ARGS);
@@ -127,7 +127,7 @@ static const v_post mdoc_valids[MDOC_MAX - MDOC_Dd] = {
post_dt, /* Dt */
post_os, /* Os */
post_sh, /* Sh */
- post_ignpar, /* Ss */
+ post_section, /* Ss */
post_par, /* Pp */
post_display, /* D1 */
post_display, /* Dl */
@@ -2187,7 +2187,7 @@ post_sx(POST_ARGS)
static void
post_sh(POST_ARGS)
{
- post_ignpar(mdoc);
+ post_section(mdoc);
switch (mdoc->last->type) {
case ROFFT_HEAD:
@@ -2520,15 +2520,31 @@ post_xr(POST_ARGS)
}
static void
-post_ignpar(POST_ARGS)
+post_section(POST_ARGS)
{
- struct roff_node *np;
+ struct roff_node *n, *nch;
+ char *cp, *tag;
- switch (mdoc->last->type) {
+ n = mdoc->last;
+ switch (n->type) {
case ROFFT_BLOCK:
post_prevpar(mdoc);
return;
case ROFFT_HEAD:
+ tag = NULL;
+ deroff(&tag, n);
+ if (tag != NULL) {
+ for (cp = tag; *cp != '\0'; cp++)
+ if (*cp == ' ')
+ *cp = '_';
+ if ((nch = n->child) != NULL &&
+ nch->type == ROFFT_TEXT &&
+ strcmp(nch->string, tag) == 0)
+ tag_put(NULL, TAG_WEAK, n);
+ else
+ tag_put(tag, TAG_FALLBACK, n);
+ free(tag);
+ }
post_delim(mdoc);
post_hyph(mdoc);
return;
@@ -2537,23 +2553,21 @@ post_ignpar(POST_ARGS)
default:
return;
}
-
- if ((np = mdoc->last->child) != NULL)
- if (np->tok == MDOC_Pp ||
- np->tok == ROFF_br || np->tok == ROFF_sp) {
- mandoc_msg(MANDOCERR_PAR_SKIP, np->line, np->pos,
- "%s after %s", roff_name[np->tok],
- roff_name[mdoc->last->tok]);
- roff_node_delete(mdoc, np);
- }
-
- if ((np = mdoc->last->last) != NULL)
- if (np->tok == MDOC_Pp || np->tok == ROFF_br) {
- mandoc_msg(MANDOCERR_PAR_SKIP, np->line, np->pos,
- "%s at the end of %s", roff_name[np->tok],
- roff_name[mdoc->last->tok]);
- roff_node_delete(mdoc, np);
- }
+ if ((nch = n->child) != NULL &&
+ (nch->tok == MDOC_Pp || nch->tok == ROFF_br ||
+ nch->tok == ROFF_sp)) {
+ mandoc_msg(MANDOCERR_PAR_SKIP, nch->line, nch->pos,
+ "%s after %s", roff_name[nch->tok],
+ roff_name[n->tok]);
+ roff_node_delete(mdoc, nch);
+ }
+ if ((nch = n->last) != NULL &&
+ (nch->tok == MDOC_Pp || nch->tok == ROFF_br)) {
+ mandoc_msg(MANDOCERR_PAR_SKIP, nch->line, nch->pos,
+ "%s at the end of %s", roff_name[nch->tok],
+ roff_name[n->tok]);
+ roff_node_delete(mdoc, nch);
+ }
}
static void