summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2014-04-15 00:41:02 +0000
committerschwarze <schwarze@openbsd.org>2014-04-15 00:41:02 +0000
commit46133849853b47bc1e4493186963a7ec691901d3 (patch)
tree1a08c285ec1503cb8cbff8f0de94afd0d27a26d3
parentmore x removal; (diff)
downloadwireguard-openbsd-46133849853b47bc1e4493186963a7ec691901d3.tar.xz
wireguard-openbsd-46133849853b47bc1e4493186963a7ec691901d3.zip
Using macros in .Sh header lines, or having .Sm off or .Bk -words open
while processing .Sh, is not at all recommended, but it's not strictly a syntax violation either, and in any case, mandoc must not die in an assertion. I broke this in rev. 1.124. Crash found while trying to read the (rather broken) original 4.3BSD-Reno od(1) manual page.
-rw-r--r--regress/usr.bin/mandoc/mdoc/Rs/break.in9
-rw-r--r--regress/usr.bin/mandoc/mdoc/Rs/break.out_ascii7
-rw-r--r--usr.bin/mandoc/mdoc_validate.c20
3 files changed, 22 insertions, 14 deletions
diff --git a/regress/usr.bin/mandoc/mdoc/Rs/break.in b/regress/usr.bin/mandoc/mdoc/Rs/break.in
index 92b462e27f3..0e8d03012a5 100644
--- a/regress/usr.bin/mandoc/mdoc/Rs/break.in
+++ b/regress/usr.bin/mandoc/mdoc/Rs/break.in
@@ -1,4 +1,4 @@
-.Dd October 28, 2009
+.Dd April 15, 2014
.Dt RS-BREAK 1
.Os OpenBSD
.Sh NAME
@@ -18,3 +18,10 @@ reference after a blank line:
.%J journal
.%N 42
.Re
+.Sh SEE Em ALSO
+reference after a blank line:
+.Rs
+.%A author
+.%J journal
+.%N 42
+.Re
diff --git a/regress/usr.bin/mandoc/mdoc/Rs/break.out_ascii b/regress/usr.bin/mandoc/mdoc/Rs/break.out_ascii
index 3d0c0b0ec40..4587ced7e1f 100644
--- a/regress/usr.bin/mandoc/mdoc/Rs/break.out_ascii
+++ b/regress/usr.bin/mandoc/mdoc/Rs/break.out_ascii
@@ -11,4 +11,9 @@ SSEEEE AALLSSOO
author, _j_o_u_r_n_a_l, 42.
-OpenBSD October 28, 2009 OpenBSD
+SSEEEE _A_L_S_O
+ reference after a blank line:
+
+ author, _j_o_u_r_n_a_l, 42.
+
+OpenBSD April 15, 2014 OpenBSD
diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c
index 0986ef42fd5..f507a5f9065 100644
--- a/usr.bin/mandoc/mdoc_validate.c
+++ b/usr.bin/mandoc/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.126 2014/03/31 00:02:45 dlg Exp $ */
+/* $Id: mdoc_validate.c,v 1.127 2014/04/15 00:41:02 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -1946,7 +1946,7 @@ static int
post_sh_head(POST_ARGS)
{
struct mdoc_node *n;
- const char *secname;
+ char *secname;
enum mdoc_sec sec;
/*
@@ -1958,15 +1958,8 @@ post_sh_head(POST_ARGS)
secname = NULL;
sec = SEC_CUSTOM;
- n = mdoc->last;
- if (n->child) {
- assert(1 == n->nchild);
- n = n->child;
- assert(NULL != n);
- assert(MDOC_TEXT == n->type);
- secname = n->string;
- sec = a2sec(secname);
- }
+ mdoc_deroff(&secname, mdoc->last);
+ sec = NULL == secname ? SEC_CUSTOM : a2sec(secname);
/* The NAME should be first. */
@@ -2003,8 +1996,10 @@ post_sh_head(POST_ARGS)
/* We don't care about custom sections after this. */
- if (SEC_CUSTOM == sec)
+ if (SEC_CUSTOM == sec) {
+ free(secname);
return(1);
+ }
/*
* Check whether our non-custom section is being repeated or is
@@ -2048,6 +2043,7 @@ post_sh_head(POST_ARGS)
break;
}
+ free(secname);
return(1);
}