summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2014-11-17 06:44:35 +0000
committerschwarze <schwarze@openbsd.org>2014-11-17 06:44:35 +0000
commit6f9818f67f5fe8cf9e8d6bca47a78366acf3c3e9 (patch)
treeb0777b4cd8d9a9c2df65f3e459255c8fb7db05ea
parentcheck spacing and behaviour in the SEE ALSO section as well (diff)
downloadwireguard-openbsd-6f9818f67f5fe8cf9e8d6bca47a78366acf3c3e9.tar.xz
wireguard-openbsd-6f9818f67f5fe8cf9e8d6bca47a78366acf3c3e9.zip
Multiple fixes with respect to in-line macros:
* .No selects the default font; relevant e.g. in .Bf blocks * no need to force empty .Li elements * closing delimiters as leading macro arguments do not suppress space * opening delimiters at the end of a macro line do not suppress space * correctly handle delimiter spacing in -Tman As a side effect, these fixes let mandoc warn about empty .No macros as requested by bentley@.
-rw-r--r--regress/usr.bin/mandoc/mdoc/Em/Makefile6
-rw-r--r--regress/usr.bin/mandoc/mdoc/Em/punct.in82
-rw-r--r--regress/usr.bin/mandoc/mdoc/Em/punct.out_ascii26
-rw-r--r--regress/usr.bin/mandoc/mdoc/Em/punct.out_lint24
-rw-r--r--regress/usr.bin/mandoc/mdoc/Li/punct.in77
-rw-r--r--regress/usr.bin/mandoc/mdoc/Li/punct.out_ascii21
-rw-r--r--regress/usr.bin/mandoc/mdoc/Li/punct.out_lint25
-rw-r--r--regress/usr.bin/mandoc/mdoc/No/Makefile5
-rw-r--r--regress/usr.bin/mandoc/mdoc/No/punct.in90
-rw-r--r--regress/usr.bin/mandoc/mdoc/No/punct.out_ascii25
-rw-r--r--regress/usr.bin/mandoc/mdoc/Sy/Makefile6
-rw-r--r--regress/usr.bin/mandoc/mdoc/Sy/punct.in82
-rw-r--r--regress/usr.bin/mandoc/mdoc/Sy/punct.out_ascii26
-rw-r--r--regress/usr.bin/mandoc/mdoc/Sy/punct.out_lint24
-rw-r--r--usr.bin/mandoc/libmdoc.h5
-rw-r--r--usr.bin/mandoc/mdoc_html.c15
-rw-r--r--usr.bin/mandoc/mdoc_macro.c78
-rw-r--r--usr.bin/mandoc/mdoc_man.c6
-rw-r--r--usr.bin/mandoc/mdoc_term.c4
-rw-r--r--usr.bin/mandoc/mdoc_validate.c22
20 files changed, 567 insertions, 82 deletions
diff --git a/regress/usr.bin/mandoc/mdoc/Em/Makefile b/regress/usr.bin/mandoc/mdoc/Em/Makefile
index cfe3ad0b4b2..13de4337a20 100644
--- a/regress/usr.bin/mandoc/mdoc/Em/Makefile
+++ b/regress/usr.bin/mandoc/mdoc/Em/Makefile
@@ -1,6 +1,6 @@
-# $OpenBSD: Makefile,v 1.2 2014/07/02 20:18:42 schwarze Exp $
+# $OpenBSD: Makefile,v 1.3 2014/11/17 06:44:35 schwarze Exp $
-REGRESS_TARGETS = font noarg
-LINT_TARGETS = noarg
+REGRESS_TARGETS = font noarg punct
+LINT_TARGETS = noarg punct
.include <bsd.regress.mk>
diff --git a/regress/usr.bin/mandoc/mdoc/Em/punct.in b/regress/usr.bin/mandoc/mdoc/Em/punct.in
new file mode 100644
index 00000000000..b49ca505da5
--- /dev/null
+++ b/regress/usr.bin/mandoc/mdoc/Em/punct.in
@@ -0,0 +1,82 @@
+.Dd November 17, 2014
+.Dt EM-PUNCT 1
+.Os OpenBSD
+.Sh NAME
+.Nm Em-punct
+.Nd punctuation following an emphasis macro
+.Sh DESCRIPTION
+Leading punctuation:
+.Em ( b
+.Em [ b
+.Em | b
+.Em . b
+.Em , b
+.Em ; b
+.Em : b
+.Em ? b
+.Em ! b
+.Em ) b
+.Em ] b
+.Pp
+Trailing punctuation:
+.Em a (
+.Em a [
+.Em a |
+.Em a .
+.Em a ,
+.Em a ;
+.Em a :
+.Em a ?
+.Em a !
+.Em a )
+.Em a ]
+.Pp
+Middle punctuation:
+.Em a ( b
+.Em a [ b
+.Em a | b
+.Em a . b
+.Em a , b
+.Em a ; b
+.Em a : b
+.Em a ? b
+.Em a ! b
+.Em a ) b
+.Em a ] b
+.Pp
+Isolated punctuation:
+.Em a Em ( Em b
+.Em a Em [ Em b
+.Em a Em | Em b
+.Em a Em . Em b
+.Em a Em , Em b
+.Em a Em ; Em b
+.Em a Em : Em b
+.Em a Em ? Em b
+.Em a Em ! Em b
+.Em a Em ) Em b
+.Em a Em ] Em b
+.Pp
+Isolated trailing punctuation:
+.Em a Em (
+.Em a Em [
+.Em a Em |
+.Em a Em .
+.Em a Em ,
+.Em a Em ;
+.Em a Em :
+.Em a Em ?
+.Em a Em !
+.Em a Em )
+.Em a Em ]
+.Pp
+Multiple isolated punctuation:
+.Em a Em ( [ Em b
+.Em a Em ) ] Em b
+.Pp
+Multiple punctuation:
+.Em [ ( arg ) ] .
+.Pp
+Quoted:
+.Em "a . b Nm"
+.Em ". b Nm"
diff --git a/regress/usr.bin/mandoc/mdoc/Em/punct.out_ascii b/regress/usr.bin/mandoc/mdoc/Em/punct.out_ascii
new file mode 100644
index 00000000000..4396e6692f6
--- /dev/null
+++ b/regress/usr.bin/mandoc/mdoc/Em/punct.out_ascii
@@ -0,0 +1,26 @@
+EM-PUNCT(1) General Commands Manual EM-PUNCT(1)
+
+NNAAMMEE
+ EEmm--ppuunncctt - punctuation following an emphasis macro
+
+DDEESSCCRRIIPPTTIIOONN
+ Leading punctuation: (_b [_b | _b . _b , _b ; _b : _b ? _b ! _b ) _b ] _b
+
+ Trailing punctuation: _a ( _a [ _a | _a. _a, _a; _a: _a? _a! _a) _a]
+
+ Middle punctuation: _a (_b _a [_b _a | _b _a. _b _a, _b _a; _b _a: _b _a? _b _a! _b _a) _b _a]
+ _b
+
+ Isolated punctuation: _a (_b _a [_b _a | _b _a . _b _a , _b _a ; _b _a : _b _a ? _b _a ! _b
+ _a ) _b _a ] _b
+
+ Isolated trailing punctuation: _a ( _a [ _a | _a . _a , _a ; _a : _a ? _a ! _a )
+ _a ]
+
+ Multiple isolated punctuation: _a ([_b _a )] _b
+
+ Multiple punctuation: [(_a_r_g)].
+
+ Quoted: _a _. _b _N_m _. _b _N_m
+
+OpenBSD November 17, 2014 OpenBSD
diff --git a/regress/usr.bin/mandoc/mdoc/Em/punct.out_lint b/regress/usr.bin/mandoc/mdoc/Em/punct.out_lint
new file mode 100644
index 00000000000..7d16f436a58
--- /dev/null
+++ b/regress/usr.bin/mandoc/mdoc/Em/punct.out_lint
@@ -0,0 +1,24 @@
+mandoc: punct.in:48:7: WARNING: skipping empty macro: Em
+mandoc: punct.in:49:7: WARNING: skipping empty macro: Em
+mandoc: punct.in:50:7: WARNING: skipping empty macro: Em
+mandoc: punct.in:51:7: WARNING: skipping empty macro: Em
+mandoc: punct.in:52:7: WARNING: skipping empty macro: Em
+mandoc: punct.in:53:7: WARNING: skipping empty macro: Em
+mandoc: punct.in:54:7: WARNING: skipping empty macro: Em
+mandoc: punct.in:55:7: WARNING: skipping empty macro: Em
+mandoc: punct.in:56:7: WARNING: skipping empty macro: Em
+mandoc: punct.in:57:7: WARNING: skipping empty macro: Em
+mandoc: punct.in:58:7: WARNING: skipping empty macro: Em
+mandoc: punct.in:61:7: WARNING: skipping empty macro: Em
+mandoc: punct.in:62:7: WARNING: skipping empty macro: Em
+mandoc: punct.in:63:7: WARNING: skipping empty macro: Em
+mandoc: punct.in:64:7: WARNING: skipping empty macro: Em
+mandoc: punct.in:65:7: WARNING: skipping empty macro: Em
+mandoc: punct.in:66:7: WARNING: skipping empty macro: Em
+mandoc: punct.in:67:7: WARNING: skipping empty macro: Em
+mandoc: punct.in:68:7: WARNING: skipping empty macro: Em
+mandoc: punct.in:69:7: WARNING: skipping empty macro: Em
+mandoc: punct.in:70:7: WARNING: skipping empty macro: Em
+mandoc: punct.in:71:7: WARNING: skipping empty macro: Em
+mandoc: punct.in:74:7: WARNING: skipping empty macro: Em
+mandoc: punct.in:75:7: WARNING: skipping empty macro: Em
diff --git a/regress/usr.bin/mandoc/mdoc/Li/punct.in b/regress/usr.bin/mandoc/mdoc/Li/punct.in
index a733a16596e..331e55da8e7 100644
--- a/regress/usr.bin/mandoc/mdoc/Li/punct.in
+++ b/regress/usr.bin/mandoc/mdoc/Li/punct.in
@@ -1,18 +1,83 @@
-.Dd April 8, 2010
+.Dd November 17, 2014
.Dt LI-PUNCT 1
.Os OpenBSD
.Sh NAME
.Nm Li-punct
.Nd punctuation following a literal macro
.Sh DESCRIPTION
-.Li before . after Nm
+Leading punctuation:
+.Li ( b
+.Li [ b
+.Li | b
+.Li . b
+.Li , b
+.Li ; b
+.Li : b
+.Li ? b
+.Li ! b
+.Li ) b
+.Li ] b
.Pp
-.Li "before . after Nm"
+Trailing punctuation:
+.Li a (
+.Li a [
+.Li a |
+.Li a .
+.Li a ,
+.Li a ;
+.Li a :
+.Li a ?
+.Li a !
+.Li a )
+.Li a ]
.Pp
-.Li . after Nm
+Middle punctuation:
+.Li a ( b
+.Li a [ b
+.Li a | b
+.Li a . b
+.Li a , b
+.Li a ; b
+.Li a : b
+.Li a ? b
+.Li a ! b
+.Li a ) b
+.Li a ] b
.Pp
-.Li ". after Nm"
+Isolated punctuation:
+.Li a Li ( Li b
+.Li a Li [ Li b
+.Li a Li | Li b
+.Li a Li . Li b
+.Li a Li , Li b
+.Li a Li ; Li b
+.Li a Li : Li b
+.Li a Li ? Li b
+.Li a Li ! Li b
+.Li a Li ) Li b
+.Li a Li ] Li b
.Pp
-.Li .
+Isolated trailing punctuation:
+.Li a Li (
+.Li a Li [
+.Li a Li |
+.Li a Li .
+.Li a Li ,
+.Li a Li ;
+.Li a Li :
+.Li a Li ?
+.Li a Li !
+.Li a Li )
+.Li a Li ]
.Pp
+Multiple isolated punctuation:
+.Li a Li ( [ Li b
+.Li a Li ) ] Li b
+.Pp
+Multiple punctuation:
+.Li [ ( arg ) ] .
+.Pp
+Quoted:
+.Li "a . b Nm"
+.Li ". b Nm"
.Li "."
diff --git a/regress/usr.bin/mandoc/mdoc/Li/punct.out_ascii b/regress/usr.bin/mandoc/mdoc/Li/punct.out_ascii
index dd96c926dfa..ae7d3f62dd4 100644
--- a/regress/usr.bin/mandoc/mdoc/Li/punct.out_ascii
+++ b/regress/usr.bin/mandoc/mdoc/Li/punct.out_ascii
@@ -4,16 +4,23 @@ NNAAMMEE
LLii--ppuunncctt - punctuation following a literal macro
DDEESSCCRRIIPPTTIIOONN
- before. after LLii--ppuunncctt
+ Leading punctuation: (b [b | b . b , b ; b : b ? b ! b ) b ] b
- before . after Nm
+ Trailing punctuation: a ( a [ a | a. a, a; a: a? a! a) a]
- . after LLii--ppuunncctt
+ Middle punctuation: a (b a [b a | b a. b a, b a; b a: b a? b a! b a) b a]
+ b
- . after Nm
+ Isolated punctuation: a (b a [b a | b a . b a , b a ; b a : b a ? b a ! b
+ a ) b a ] b
- .
+ Isolated trailing punctuation: a ( a [ a | a . a , a ; a : a ? a ! a )
+ a ]
- .
+ Multiple isolated punctuation: a ([b a )] b
-OpenBSD April 8, 2010 OpenBSD
+ Multiple punctuation: [(arg)].
+
+ Quoted: a . b Nm . b Nm .
+
+OpenBSD November 17, 2014 OpenBSD
diff --git a/regress/usr.bin/mandoc/mdoc/Li/punct.out_lint b/regress/usr.bin/mandoc/mdoc/Li/punct.out_lint
index 83206b9fe01..3abdf12f7b2 100644
--- a/regress/usr.bin/mandoc/mdoc/Li/punct.out_lint
+++ b/regress/usr.bin/mandoc/mdoc/Li/punct.out_lint
@@ -1 +1,24 @@
-mandoc: punct.in:16:2: WARNING: skipping empty macro: Li
+mandoc: punct.in:48:7: WARNING: skipping empty macro: Li
+mandoc: punct.in:49:7: WARNING: skipping empty macro: Li
+mandoc: punct.in:50:7: WARNING: skipping empty macro: Li
+mandoc: punct.in:51:7: WARNING: skipping empty macro: Li
+mandoc: punct.in:52:7: WARNING: skipping empty macro: Li
+mandoc: punct.in:53:7: WARNING: skipping empty macro: Li
+mandoc: punct.in:54:7: WARNING: skipping empty macro: Li
+mandoc: punct.in:55:7: WARNING: skipping empty macro: Li
+mandoc: punct.in:56:7: WARNING: skipping empty macro: Li
+mandoc: punct.in:57:7: WARNING: skipping empty macro: Li
+mandoc: punct.in:58:7: WARNING: skipping empty macro: Li
+mandoc: punct.in:61:7: WARNING: skipping empty macro: Li
+mandoc: punct.in:62:7: WARNING: skipping empty macro: Li
+mandoc: punct.in:63:7: WARNING: skipping empty macro: Li
+mandoc: punct.in:64:7: WARNING: skipping empty macro: Li
+mandoc: punct.in:65:7: WARNING: skipping empty macro: Li
+mandoc: punct.in:66:7: WARNING: skipping empty macro: Li
+mandoc: punct.in:67:7: WARNING: skipping empty macro: Li
+mandoc: punct.in:68:7: WARNING: skipping empty macro: Li
+mandoc: punct.in:69:7: WARNING: skipping empty macro: Li
+mandoc: punct.in:70:7: WARNING: skipping empty macro: Li
+mandoc: punct.in:71:7: WARNING: skipping empty macro: Li
+mandoc: punct.in:74:7: WARNING: skipping empty macro: Li
+mandoc: punct.in:75:7: WARNING: skipping empty macro: Li
diff --git a/regress/usr.bin/mandoc/mdoc/No/Makefile b/regress/usr.bin/mandoc/mdoc/No/Makefile
index 62085defb3a..3110bf2b06d 100644
--- a/regress/usr.bin/mandoc/mdoc/No/Makefile
+++ b/regress/usr.bin/mandoc/mdoc/No/Makefile
@@ -1,5 +1,6 @@
-# $OpenBSD: Makefile,v 1.3 2012/07/09 09:30:28 schwarze Exp $
+# $OpenBSD: Makefile,v 1.4 2014/11/17 06:44:35 schwarze Exp $
-REGRESS_TARGETS=punct spacing
+REGRESS_TARGETS = punct spacing
+LINT_TARGETS = punct
.include <bsd.regress.mk>
diff --git a/regress/usr.bin/mandoc/mdoc/No/punct.in b/regress/usr.bin/mandoc/mdoc/No/punct.in
index 2175bcaec8e..b4d8ef73343 100644
--- a/regress/usr.bin/mandoc/mdoc/No/punct.in
+++ b/regress/usr.bin/mandoc/mdoc/No/punct.in
@@ -1,25 +1,83 @@
-.Dd October 1, 2010
+.Dd November 17, 2014
.Dt NO-PUNCT 1
.Os OpenBSD
.Sh NAME
.Nm No-punct
.Nd punctuation after the normal macro
.Sh DESCRIPTION
-One arg:
-.No one
-Two args:
-.No one two
-Trailing punctuation:
-.No arg .
Leading punctuation:
-.No ( arg
+.No ( b
+.No [ b
+.No | b
+.No . b
+.No , b
+.No ; b
+.No : b
+.No ? b
+.No ! b
+.No ) b
+.No ] b
+.Pp
+Trailing punctuation:
+.No a (
+.No a [
+.No a |
+.No a .
+.No a ,
+.No a ;
+.No a :
+.No a ?
+.No a !
+.No a )
+.No a ]
+.Pp
+Middle punctuation:
+.No a ( b
+.No a [ b
+.No a | b
+.No a . b
+.No a , b
+.No a ; b
+.No a : b
+.No a ? b
+.No a ! b
+.No a ) b
+.No a ] b
+.Pp
+Isolated punctuation:
+.No a No ( No b
+.No a No [ No b
+.No a No | No b
+.No a No . No b
+.No a No , No b
+.No a No ; No b
+.No a No : No b
+.No a No ? No b
+.No a No ! No b
+.No a No ) No b
+.No a No ] No b
+.Pp
+Isolated trailing punctuation:
+.No a No (
+.No a No [
+.No a No |
+.No a No .
+.No a No ,
+.No a No ;
+.No a No :
+.No a No ?
+.No a No !
+.No a No )
+.No a No ]
+.Pp
+Multiple isolated punctuation:
+.No a No ( [ No b
+.No a No ) ] No b
+.Pp
Multiple punctuation:
.No [ ( arg ) ] .
-Isolated opening punctuation:
-.No pre No ( No post .
-Isolated closing punctuation:
-.No pre No ) No post .
-Multiple opening punctuation:
-.No pre No ( [ No post .
-Multiple closing punctuation:
-.No pre No ) ] No post .
+.Pp
+Quoted:
+.No "a . b Nm"
+.No ". b Nm"
+.No "."
diff --git a/regress/usr.bin/mandoc/mdoc/No/punct.out_ascii b/regress/usr.bin/mandoc/mdoc/No/punct.out_ascii
index c5f951ef38d..eca39c42e46 100644
--- a/regress/usr.bin/mandoc/mdoc/No/punct.out_ascii
+++ b/regress/usr.bin/mandoc/mdoc/No/punct.out_ascii
@@ -4,10 +4,23 @@ NNAAMMEE
NNoo--ppuunncctt - punctuation after the normal macro
DDEESSCCRRIIPPTTIIOONN
- One arg: one Two args: one two Trailing punctuation: arg. Leading
- punctuation: (arg Multiple punctuation: [(arg)]. Isolated opening
- punctuation: pre (post. Isolated closing punctuation: pre ) post.
- Multiple opening punctuation: pre ([post. Multiple closing punctuation:
- pre )] post.
+ Leading punctuation: (b [b | b . b , b ; b : b ? b ! b ) b ] b
-OpenBSD October 1, 2010 OpenBSD
+ Trailing punctuation: a ( a [ a | a. a, a; a: a? a! a) a]
+
+ Middle punctuation: a (b a [b a | b a. b a, b a; b a: b a? b a! b a) b a]
+ b
+
+ Isolated punctuation: a (b a [b a | b a . b a , b a ; b a : b a ? b a ! b
+ a ) b a ] b
+
+ Isolated trailing punctuation: a ( a [ a | a . a , a ; a : a ? a ! a )
+ a ]
+
+ Multiple isolated punctuation: a ([b a )] b
+
+ Multiple punctuation: [(arg)].
+
+ Quoted: a . b Nm . b Nm .
+
+OpenBSD November 17, 2014 OpenBSD
diff --git a/regress/usr.bin/mandoc/mdoc/Sy/Makefile b/regress/usr.bin/mandoc/mdoc/Sy/Makefile
index 1be2a84aeb4..36c1859b55b 100644
--- a/regress/usr.bin/mandoc/mdoc/Sy/Makefile
+++ b/regress/usr.bin/mandoc/mdoc/Sy/Makefile
@@ -1,6 +1,6 @@
-# $OpenBSD: Makefile,v 1.4 2014/07/02 20:18:42 schwarze Exp $
+# $OpenBSD: Makefile,v 1.5 2014/11/17 06:44:35 schwarze Exp $
-REGRESS_TARGETS = noarg font
-LINT_TARGETS = noarg
+REGRESS_TARGETS = noarg font punct
+LINT_TARGETS = noarg punct
.include <bsd.regress.mk>
diff --git a/regress/usr.bin/mandoc/mdoc/Sy/punct.in b/regress/usr.bin/mandoc/mdoc/Sy/punct.in
new file mode 100644
index 00000000000..4f51886b0ad
--- /dev/null
+++ b/regress/usr.bin/mandoc/mdoc/Sy/punct.in
@@ -0,0 +1,82 @@
+.Dd November 17, 2014
+.Dt SY-PUNCT 1
+.Os OpenBSD
+.Sh NAME
+.Nm Sy-punct
+.Nd punctuation following a symbolic macro
+.Sh DESCRIPTION
+Leading punctuation:
+.Sy ( b
+.Sy [ b
+.Sy | b
+.Sy . b
+.Sy , b
+.Sy ; b
+.Sy : b
+.Sy ? b
+.Sy ! b
+.Sy ) b
+.Sy ] b
+.Pp
+Trailing punctuation:
+.Sy a (
+.Sy a [
+.Sy a |
+.Sy a .
+.Sy a ,
+.Sy a ;
+.Sy a :
+.Sy a ?
+.Sy a !
+.Sy a )
+.Sy a ]
+.Pp
+Middle punctuation:
+.Sy a ( b
+.Sy a [ b
+.Sy a | b
+.Sy a . b
+.Sy a , b
+.Sy a ; b
+.Sy a : b
+.Sy a ? b
+.Sy a ! b
+.Sy a ) b
+.Sy a ] b
+.Pp
+Isolated punctuation:
+.Sy a Sy ( Sy b
+.Sy a Sy [ Sy b
+.Sy a Sy | Sy b
+.Sy a Sy . Sy b
+.Sy a Sy , Sy b
+.Sy a Sy ; Sy b
+.Sy a Sy : Sy b
+.Sy a Sy ? Sy b
+.Sy a Sy ! Sy b
+.Sy a Sy ) Sy b
+.Sy a Sy ] Sy b
+.Pp
+Isolated trailing punctuation:
+.Sy a Sy (
+.Sy a Sy [
+.Sy a Sy |
+.Sy a Sy .
+.Sy a Sy ,
+.Sy a Sy ;
+.Sy a Sy :
+.Sy a Sy ?
+.Sy a Sy !
+.Sy a Sy )
+.Sy a Sy ]
+.Pp
+Multiple isolated punctuation:
+.Sy a Sy ( [ Sy b
+.Sy a Sy ) ] Sy b
+.Pp
+Multiple punctuation:
+.Sy [ ( arg ) ] .
+.Pp
+Quoted:
+.Sy "a . b Nm"
+.Sy ". b Nm"
diff --git a/regress/usr.bin/mandoc/mdoc/Sy/punct.out_ascii b/regress/usr.bin/mandoc/mdoc/Sy/punct.out_ascii
new file mode 100644
index 00000000000..39bed0ba4e8
--- /dev/null
+++ b/regress/usr.bin/mandoc/mdoc/Sy/punct.out_ascii
@@ -0,0 +1,26 @@
+SY-PUNCT(1) General Commands Manual SY-PUNCT(1)
+
+NNAAMMEE
+ SSyy--ppuunncctt - punctuation following a symbolic macro
+
+DDEESSCCRRIIPPTTIIOONN
+ Leading punctuation: (bb [bb | bb . bb , bb ; bb : bb ? bb ! bb ) bb ] bb
+
+ Trailing punctuation: aa ( aa [ aa | aa. aa, aa; aa: aa? aa! aa) aa]
+
+ Middle punctuation: aa (bb aa [bb aa | bb aa. bb aa, bb aa; bb aa: bb aa? bb aa! bb aa) bb aa]
+ bb
+
+ Isolated punctuation: aa (bb aa [bb aa | bb aa . bb aa , bb aa ; bb aa : bb aa ? bb aa ! bb
+ aa ) bb aa ] bb
+
+ Isolated trailing punctuation: aa ( aa [ aa | aa . aa , aa ; aa : aa ? aa ! aa )
+ aa ]
+
+ Multiple isolated punctuation: aa ([bb aa )] bb
+
+ Multiple punctuation: [(aarrgg)].
+
+ Quoted: aa .. bb NNmm .. bb NNmm
+
+OpenBSD November 17, 2014 OpenBSD
diff --git a/regress/usr.bin/mandoc/mdoc/Sy/punct.out_lint b/regress/usr.bin/mandoc/mdoc/Sy/punct.out_lint
new file mode 100644
index 00000000000..0073a308f6f
--- /dev/null
+++ b/regress/usr.bin/mandoc/mdoc/Sy/punct.out_lint
@@ -0,0 +1,24 @@
+mandoc: punct.in:48:7: WARNING: skipping empty macro: Sy
+mandoc: punct.in:49:7: WARNING: skipping empty macro: Sy
+mandoc: punct.in:50:7: WARNING: skipping empty macro: Sy
+mandoc: punct.in:51:7: WARNING: skipping empty macro: Sy
+mandoc: punct.in:52:7: WARNING: skipping empty macro: Sy
+mandoc: punct.in:53:7: WARNING: skipping empty macro: Sy
+mandoc: punct.in:54:7: WARNING: skipping empty macro: Sy
+mandoc: punct.in:55:7: WARNING: skipping empty macro: Sy
+mandoc: punct.in:56:7: WARNING: skipping empty macro: Sy
+mandoc: punct.in:57:7: WARNING: skipping empty macro: Sy
+mandoc: punct.in:58:7: WARNING: skipping empty macro: Sy
+mandoc: punct.in:61:7: WARNING: skipping empty macro: Sy
+mandoc: punct.in:62:7: WARNING: skipping empty macro: Sy
+mandoc: punct.in:63:7: WARNING: skipping empty macro: Sy
+mandoc: punct.in:64:7: WARNING: skipping empty macro: Sy
+mandoc: punct.in:65:7: WARNING: skipping empty macro: Sy
+mandoc: punct.in:66:7: WARNING: skipping empty macro: Sy
+mandoc: punct.in:67:7: WARNING: skipping empty macro: Sy
+mandoc: punct.in:68:7: WARNING: skipping empty macro: Sy
+mandoc: punct.in:69:7: WARNING: skipping empty macro: Sy
+mandoc: punct.in:70:7: WARNING: skipping empty macro: Sy
+mandoc: punct.in:71:7: WARNING: skipping empty macro: Sy
+mandoc: punct.in:74:7: WARNING: skipping empty macro: Sy
+mandoc: punct.in:75:7: WARNING: skipping empty macro: Sy
diff --git a/usr.bin/mandoc/libmdoc.h b/usr.bin/mandoc/libmdoc.h
index 95030a2116b..b95bc28c8b9 100644
--- a/usr.bin/mandoc/libmdoc.h
+++ b/usr.bin/mandoc/libmdoc.h
@@ -1,7 +1,7 @@
-/* $Id: libmdoc.h,v 1.58 2014/08/08 15:57:05 schwarze Exp $ */
+/* $OpenBSD: libmdoc.h,v 1.59 2014/11/17 06:44:35 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2013 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2013, 2014 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 @@ struct mdoc {
#define MDOC_SYNOPSIS (1 << 7) /* SYNOPSIS-style formatting */
#define MDOC_KEEP (1 << 8) /* in a word keep */
#define MDOC_SMOFF (1 << 9) /* spacing is off */
+#define MDOC_NODELIMC (1 << 10) /* disable closing delimiter handling */
enum mdoc_next next; /* where to put the next node */
struct mdoc_node *last; /* the last node parsed */
struct mdoc_node *first; /* the first node parsed */
diff --git a/usr.bin/mandoc/mdoc_html.c b/usr.bin/mandoc/mdoc_html.c
index 961b8b6bdad..2d22fa747cd 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.84 2014/10/30 20:05:33 schwarze Exp $ */
+/* $OpenBSD: mdoc_html.c,v 1.85 2014/11/17 06:44:35 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -96,6 +96,7 @@ static int mdoc_mt_pre(MDOC_ARGS);
static int mdoc_ms_pre(MDOC_ARGS);
static int mdoc_nd_pre(MDOC_ARGS);
static int mdoc_nm_pre(MDOC_ARGS);
+static int mdoc_no_pre(MDOC_ARGS);
static int mdoc_ns_pre(MDOC_ARGS);
static int mdoc_pa_pre(MDOC_ARGS);
static void mdoc_pf_post(MDOC_ARGS);
@@ -190,7 +191,7 @@ static const struct htmlmdoc mdocs[MDOC_MAX] = {
{mdoc_quote_pre, mdoc_quote_post}, /* Eo */
{mdoc_xx_pre, NULL}, /* Fx */
{mdoc_ms_pre, NULL}, /* Ms */
- {mdoc_igndelim_pre, NULL}, /* No */
+ {mdoc_no_pre, NULL}, /* No */
{mdoc_ns_pre, NULL}, /* Ns */
{mdoc_xx_pre, NULL}, /* Nx */
{mdoc_xx_pre, NULL}, /* Ox */
@@ -1882,6 +1883,16 @@ mdoc_rs_pre(MDOC_ARGS)
}
static int
+mdoc_no_pre(MDOC_ARGS)
+{
+ struct htmlpair tag;
+
+ PAIR_CLASS_INIT(&tag, "none");
+ print_otag(h, TAG_CODE, 1, &tag);
+ return(1);
+}
+
+static int
mdoc_li_pre(MDOC_ARGS)
{
struct htmlpair tag;
diff --git a/usr.bin/mandoc/mdoc_macro.c b/usr.bin/mandoc/mdoc_macro.c
index aa845549c51..647ce0127de 100644
--- a/usr.bin/mandoc/mdoc_macro.c
+++ b/usr.bin/mandoc/mdoc_macro.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_macro.c,v 1.99 2014/09/07 00:04:47 schwarze Exp $ */
+/* $OpenBSD: mdoc_macro.c,v 1.100 2014/11/17 06:44:35 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,6 +15,8 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#include <sys/types.h>
+
#include <assert.h>
#include <ctype.h>
#include <stdlib.h>
@@ -143,8 +145,7 @@ const struct mdoc_macro __mdoc_macros[MDOC_MAX] = {
{ blk_part_exp, MDOC_CALLABLE | MDOC_PARSED | MDOC_EXPLICIT }, /* Eo */
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Fx */
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Ms */
- { in_line_argn, MDOC_CALLABLE | MDOC_PARSED |
- MDOC_IGNDELIM | MDOC_JOIN }, /* No */
+ { in_line, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* No */
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED |
MDOC_IGNDELIM | MDOC_JOIN }, /* Ns */
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Nx */
@@ -623,24 +624,22 @@ dword(struct mdoc *mdoc, int line, int col, const char *p,
if ( ! mdoc_word_alloc(mdoc, line, col, p))
return(0);
- if (DELIM_OPEN == d)
- mdoc->last->flags |= MDOC_DELIMO;
-
/*
- * Closing delimiters only suppress the preceding space
- * when they follow something, not when they start a new
- * block or element, and not when they follow `No'.
- *
- * XXX Explicitly special-casing MDOC_No here feels
- * like a layering violation. Find a better way
- * and solve this in the code related to `No'!
+ * If the word consists of a bare delimiter,
+ * flag the new node accordingly,
+ * unless doing so was vetoed by the invoking macro.
+ * Always clear the veto, it is only valid for one word.
*/
- else if (DELIM_CLOSE == d && mdoc->last->prev &&
- mdoc->last->prev->tok != MDOC_No &&
+ if (d == DELIM_OPEN)
+ mdoc->last->flags |= MDOC_DELIMO;
+ else if (d == DELIM_CLOSE &&
+ ! (mdoc->flags & MDOC_NODELIMC) &&
mdoc->last->parent->tok != MDOC_Fd)
mdoc->last->flags |= MDOC_DELIMC;
+ mdoc->flags &= ~MDOC_NODELIMC;
+
return(1);
}
@@ -839,7 +838,7 @@ blk_exp_close(MACRO_PROT_ARGS)
static int
in_line(MACRO_PROT_ARGS)
{
- int la, scope, cnt, mayopen, nc, nl;
+ int la, scope, cnt, firstarg, mayopen, nc, nl;
enum margverr av;
enum mdoct ntok;
enum margserr ac;
@@ -890,17 +889,40 @@ in_line(MACRO_PROT_ARGS)
return(0);
}
+ d = DELIM_NONE;
+ firstarg = 1;
mayopen = 1;
for (cnt = scope = 0;; ) {
la = *pos;
ac = mdoc_args(mdoc, line, pos, buf, tok, &p);
- if (ARGS_ERROR == ac)
+ if (ac == ARGS_ERROR)
return(0);
- if (ARGS_EOLN == ac)
+
+ /*
+ * At the end of a macro line,
+ * opening delimiters do not suppress spacing.
+ */
+
+ if (ac == ARGS_EOLN) {
+ if (d == DELIM_OPEN)
+ mdoc->last->flags &= ~MDOC_DELIMO;
break;
- if (ARGS_PUNCT == ac)
+ }
+
+ /*
+ * The rest of the macro line is only punctuation,
+ * to be handled by append_delims().
+ * If there were no other arguments,
+ * do not allow the first one to suppress spacing,
+ * even if it turns out to be a closing one.
+ */
+
+ if (ac == ARGS_PUNCT) {
+ if (cnt == 0 && nc == 0)
+ mdoc->flags |= MDOC_NODELIMC;
break;
+ }
ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p);
@@ -945,20 +967,19 @@ in_line(MACRO_PROT_ARGS)
if (DELIM_NONE != d) {
/*
* If we encounter closing punctuation, no word
- * has been omitted, no scope is open, and we're
+ * has been emitted, no scope is open, and we're
* allowed to have an empty element, then start
* a new scope.
*/
if ((d == DELIM_CLOSE ||
(d == DELIM_MIDDLE && tok == MDOC_Fl)) &&
- (nc || tok == MDOC_Li) &&
- !scope && !cnt && mayopen) {
+ !cnt && !scope && nc && mayopen) {
if ( ! mdoc_elem_alloc(mdoc,
line, ppos, tok, arg))
return(0);
scope = 1;
cnt++;
- if (MDOC_Li == tok || MDOC_Nm == tok)
+ if (MDOC_Nm == tok)
mayopen = 0;
}
/*
@@ -980,6 +1001,15 @@ in_line(MACRO_PROT_ARGS)
return(0);
/*
+ * If the first argument is a closing delimiter,
+ * do not suppress spacing before it.
+ */
+
+ if (firstarg && d == DELIM_CLOSE && !nc)
+ mdoc->last->flags &= ~MDOC_DELIMC;
+ firstarg = 0;
+
+ /*
* `Fl' macros have their scope re-opened with each new
* word so that the `-' can be added to each one without
* having to parse out spaces.
@@ -1529,8 +1559,6 @@ in_line_argn(MACRO_PROT_ARGS)
switch (tok) {
case MDOC_Ap:
/* FALLTHROUGH */
- case MDOC_No:
- /* FALLTHROUGH */
case MDOC_Ns:
/* FALLTHROUGH */
case MDOC_Ux:
diff --git a/usr.bin/mandoc/mdoc_man.c b/usr.bin/mandoc/mdoc_man.c
index 12230259bde..3e5e5e2eca2 100644
--- a/usr.bin/mandoc/mdoc_man.c
+++ b/usr.bin/mandoc/mdoc_man.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_man.c,v 1.70 2014/11/06 22:27:52 schwarze Exp $ */
+/* $OpenBSD: mdoc_man.c,v 1.71 2014/11/17 06:44:35 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -592,7 +592,11 @@ print_node(DECL_ARGS)
printf("\\&");
outflags &= ~MMAN_spc;
}
+ if (outflags & MMAN_Sm && ! (n->flags & MDOC_DELIMC))
+ outflags |= MMAN_spc_force;
print_word(n->string);
+ if (outflags & MMAN_Sm && ! (n->flags & MDOC_DELIMO))
+ outflags |= MMAN_spc;
} else {
/*
* Conditionally run the pre-node action handler for a
diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c
index 21ba99a3e0f..83c89aed33b 100644
--- a/usr.bin/mandoc/mdoc_term.c
+++ b/usr.bin/mandoc/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_term.c,v 1.188 2014/11/10 21:54:29 schwarze Exp $ */
+/* $OpenBSD: mdoc_term.c,v 1.189 2014/11/17 06:44:35 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -191,7 +191,7 @@ static const struct termact termacts[MDOC_MAX] = {
{ termp_quote_pre, termp_quote_post }, /* Eo */
{ termp_xx_pre, NULL }, /* Fx */
{ termp_bold_pre, NULL }, /* Ms */
- { NULL, NULL }, /* No */
+ { termp_li_pre, NULL }, /* No */
{ termp_ns_pre, NULL }, /* Ns */
{ termp_xx_pre, NULL }, /* Nx */
{ termp_xx_pre, NULL }, /* Ox */
diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c
index a367317ca28..634fe9303fd 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.170 2014/10/30 20:05:33 schwarze Exp $ */
+/* $OpenBSD: mdoc_validate.c,v 1.171 2014/11/17 06:44:35 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -208,7 +208,7 @@ static const struct valids mdoc_valids[MDOC_MAX] = {
{ NULL, NULL }, /* Eo */
{ NULL, NULL }, /* Fx */
{ NULL, NULL }, /* Ms */
- { NULL, ewarn_eq0 }, /* No */
+ { NULL, NULL }, /* No */
{ NULL, post_ns }, /* Ns */
{ NULL, NULL }, /* Nx */
{ NULL, NULL }, /* Ox */
@@ -352,6 +352,20 @@ mdoc_valid_post(struct mdoc *mdoc)
case MDOC_ROOT:
return(post_root(mdoc));
default:
+
+ /*
+ * Closing delimiters are not special at the
+ * beginning of a block, opening delimiters
+ * are not special at the end.
+ */
+
+ if (n->child != NULL)
+ n->child->flags &= ~MDOC_DELIMC;
+ if (n->last != NULL)
+ n->last->flags &= ~MDOC_DELIMO;
+
+ /* Call the macro's postprocessor. */
+
p = mdoc_valids[n->tok].post;
return(*p ? (*p)(mdoc) : 1);
}
@@ -1161,10 +1175,6 @@ post_defaults(POST_ARGS)
if ( ! mdoc_word_alloc(mdoc, nn->line, nn->pos, "..."))
return(0);
break;
- case MDOC_Li:
- if ( ! mdoc_word_alloc(mdoc, nn->line, nn->pos, ""))
- return(0);
- break;
case MDOC_Pa:
/* FALLTHROUGH */
case MDOC_Mt: