From 5d8f5ae1b0575990b0694e2dd99e76ad04202256 Mon Sep 17 00:00:00 2001 From: schwarze Date: Sat, 3 Jun 2017 15:54:09 +0000 Subject: [PATCH] ignore blank lines in man(7) next line scope; strange groff edge case behaviour found in multimedia/mjpegtools --- regress/usr.bin/mandoc/man/B/Makefile | 10 +++++++--- regress/usr.bin/mandoc/man/B/blank.in | 9 +++++++++ regress/usr.bin/mandoc/man/B/blank.out_ascii | 13 +++++++++++++ regress/usr.bin/mandoc/man/B/blank.out_lint | 1 + regress/usr.bin/mandoc/man/SH/Makefile | 3 ++- regress/usr.bin/mandoc/man/SH/noarg.in | 4 ++++ regress/usr.bin/mandoc/man/SH/noarg.out_ascii | 3 +++ regress/usr.bin/mandoc/man/SH/noarg.out_lint | 1 + regress/usr.bin/mandoc/man/SS/Makefile | 3 ++- regress/usr.bin/mandoc/man/SS/noarg.in | 4 ++++ regress/usr.bin/mandoc/man/SS/noarg.out_ascii | 3 +++ regress/usr.bin/mandoc/man/SS/noarg.out_lint | 1 + regress/usr.bin/mandoc/man/TP/Makefile | 3 ++- regress/usr.bin/mandoc/man/TP/broken.in | 4 ++++ regress/usr.bin/mandoc/man/TP/broken.out_ascii | 2 ++ regress/usr.bin/mandoc/man/TP/broken.out_lint | 1 + usr.bin/mandoc/man.c | 13 +++++++------ usr.bin/mandoc/mandoc.h | 3 ++- usr.bin/mandoc/read.c | 3 ++- 19 files changed, 70 insertions(+), 14 deletions(-) create mode 100644 regress/usr.bin/mandoc/man/B/blank.in create mode 100644 regress/usr.bin/mandoc/man/B/blank.out_ascii create mode 100644 regress/usr.bin/mandoc/man/B/blank.out_lint diff --git a/regress/usr.bin/mandoc/man/B/Makefile b/regress/usr.bin/mandoc/man/B/Makefile index 8e4d72a9523..ac010e1ba62 100644 --- a/regress/usr.bin/mandoc/man/B/Makefile +++ b/regress/usr.bin/mandoc/man/B/Makefile @@ -1,6 +1,10 @@ -# $OpenBSD: Makefile,v 1.1 2014/08/14 02:00:52 schwarze Exp $ +# $OpenBSD: Makefile,v 1.2 2017/06/03 15:54:09 schwarze Exp $ -REGRESS_TARGETS = args -LINT_TARGETS = args +REGRESS_TARGETS = args blank +LINT_TARGETS = args blank + +# groff-1.22.3 defect: +# - A blank line in next line scope causes a blank line. +SKIP_GROFF = blank .include diff --git a/regress/usr.bin/mandoc/man/B/blank.in b/regress/usr.bin/mandoc/man/B/blank.in new file mode 100644 index 00000000000..eef5126f533 --- /dev/null +++ b/regress/usr.bin/mandoc/man/B/blank.in @@ -0,0 +1,9 @@ +.TH B-BLANK 1 "June 3, 2017" OpenBSD +.SH NAME +B-blank \- blank line in font macro next line scope +.SH DESCRIPTION +A blank line in +.B + +bold +next line scope. diff --git a/regress/usr.bin/mandoc/man/B/blank.out_ascii b/regress/usr.bin/mandoc/man/B/blank.out_ascii new file mode 100644 index 00000000000..4ecf27d81f1 --- /dev/null +++ b/regress/usr.bin/mandoc/man/B/blank.out_ascii @@ -0,0 +1,13 @@ +B-BLANK(1) General Commands Manual B-BLANK(1) + + + +NNAAMMEE + B-blank - blank line in font macro next line scope + +DDEESSCCRRIIPPTTIIOONN + A blank line in bboolldd next line scope. + + + +OpenBSD June 3, 2017 B-BLANK(1) diff --git a/regress/usr.bin/mandoc/man/B/blank.out_lint b/regress/usr.bin/mandoc/man/B/blank.out_lint new file mode 100644 index 00000000000..22e683eab2c --- /dev/null +++ b/regress/usr.bin/mandoc/man/B/blank.out_lint @@ -0,0 +1 @@ +mandoc: blank.in:7:1: WARNING: skipping blank line in line scope diff --git a/regress/usr.bin/mandoc/man/SH/Makefile b/regress/usr.bin/mandoc/man/SH/Makefile index f94a4cae89a..7fff2ef5873 100644 --- a/regress/usr.bin/mandoc/man/SH/Makefile +++ b/regress/usr.bin/mandoc/man/SH/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.4 2015/04/04 18:52:12 schwarze Exp $ +# $OpenBSD: Makefile,v 1.5 2017/06/03 15:54:09 schwarze Exp $ REGRESS_TARGETS = broken broken_eline empty_before longarg noarg LINT_TARGETS = broken broken_eline empty_before noarg @@ -10,6 +10,7 @@ LINT_TARGETS = broken broken_eline empty_before noarg # - If .HP breaks .SH, a line is broken after the next input line. # - If .RS/RE/nf/fi breaks .SH, the next input line becomes bold. # - .UR does not break .SH. +# - blank line in .SH next line scope causes blank lines and bogus indent SKIP_GROFF = broken broken_eline noarg diff --git a/regress/usr.bin/mandoc/man/SH/noarg.in b/regress/usr.bin/mandoc/man/SH/noarg.in index 58ccac7c0d8..087ac834a48 100644 --- a/regress/usr.bin/mandoc/man/SH/noarg.in +++ b/regress/usr.bin/mandoc/man/SH/noarg.in @@ -40,3 +40,7 @@ no-fill mode .SH .fi back in fill mode +.SH + +SEE ALSO +broken(1) diff --git a/regress/usr.bin/mandoc/man/SH/noarg.out_ascii b/regress/usr.bin/mandoc/man/SH/noarg.out_ascii index bc3490dfdac..903f85d8465 100644 --- a/regress/usr.bin/mandoc/man/SH/noarg.out_ascii +++ b/regress/usr.bin/mandoc/man/SH/noarg.out_ascii @@ -27,6 +27,9 @@ DDEESSCCRRIIPPTTIIOONN back in fill mode +SSEEEE AALLSSOO + broken(1) + OpenBSD March 20, 2015 SH-NOARG(1) diff --git a/regress/usr.bin/mandoc/man/SH/noarg.out_lint b/regress/usr.bin/mandoc/man/SH/noarg.out_lint index a1bb39b42f8..3f9d130d455 100644 --- a/regress/usr.bin/mandoc/man/SH/noarg.out_lint +++ b/regress/usr.bin/mandoc/man/SH/noarg.out_lint @@ -11,3 +11,4 @@ mandoc: noarg.in:31:2: WARNING: line scope broken: UR breaks SH mandoc: noarg.in:34:2: WARNING: line scope broken: UE breaks SH mandoc: noarg.in:35:2: ERROR: skipping end of block that is not open: UE mandoc: noarg.in:41:2: WARNING: fill mode already enabled, skipping: fi +mandoc: noarg.in:44:1: WARNING: skipping blank line in line scope diff --git a/regress/usr.bin/mandoc/man/SS/Makefile b/regress/usr.bin/mandoc/man/SS/Makefile index e76a4ee92a5..237830e0ba2 100644 --- a/regress/usr.bin/mandoc/man/SS/Makefile +++ b/regress/usr.bin/mandoc/man/SS/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.2 2015/04/04 18:52:12 schwarze Exp $ +# $OpenBSD: Makefile,v 1.3 2017/06/03 15:54:09 schwarze Exp $ REGRESS_TARGETS = broken broken_eline longarg noarg LINT_TARGETS = broken broken_eline noarg @@ -10,6 +10,7 @@ LINT_TARGETS = broken broken_eline noarg # - If .HP breaks .SS, a line is broken after the next input line. # - If .RS/RE/nf/fi breaks .SS, the next input line becomes bold. # - .UR does not break .SS. +# - blank line in .SS next-line scope causes a blank line SKIP_GROFF = broken broken_eline noarg diff --git a/regress/usr.bin/mandoc/man/SS/noarg.in b/regress/usr.bin/mandoc/man/SS/noarg.in index 85470b010d6..a0ee10593a4 100644 --- a/regress/usr.bin/mandoc/man/SS/noarg.in +++ b/regress/usr.bin/mandoc/man/SS/noarg.in @@ -40,3 +40,7 @@ no-fill mode .SS .fi back in fill mode +.SS + +Subsection +with a blank line diff --git a/regress/usr.bin/mandoc/man/SS/noarg.out_ascii b/regress/usr.bin/mandoc/man/SS/noarg.out_ascii index 60fd85ff06d..20bafc63c57 100644 --- a/regress/usr.bin/mandoc/man/SS/noarg.out_ascii +++ b/regress/usr.bin/mandoc/man/SS/noarg.out_ascii @@ -27,6 +27,9 @@ DDEESSCCRRIIPPTTIIOONN back in fill mode + SSuubbsseeccttiioonn + with a blank line + OpenBSD March 20, 2015 SS-NOARG(1) diff --git a/regress/usr.bin/mandoc/man/SS/noarg.out_lint b/regress/usr.bin/mandoc/man/SS/noarg.out_lint index 1715179230d..8af88544f10 100644 --- a/regress/usr.bin/mandoc/man/SS/noarg.out_lint +++ b/regress/usr.bin/mandoc/man/SS/noarg.out_lint @@ -11,3 +11,4 @@ mandoc: noarg.in:31:2: WARNING: line scope broken: UR breaks SS mandoc: noarg.in:34:2: WARNING: line scope broken: UE breaks SS mandoc: noarg.in:35:2: ERROR: skipping end of block that is not open: UE mandoc: noarg.in:41:2: WARNING: fill mode already enabled, skipping: fi +mandoc: noarg.in:44:1: WARNING: skipping blank line in line scope diff --git a/regress/usr.bin/mandoc/man/TP/Makefile b/regress/usr.bin/mandoc/man/TP/Makefile index b867ba635a5..6c9fc6b9de4 100644 --- a/regress/usr.bin/mandoc/man/TP/Makefile +++ b/regress/usr.bin/mandoc/man/TP/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.12 2015/09/21 13:24:32 schwarze Exp $ +# $OpenBSD: Makefile,v 1.13 2017/06/03 15:54:09 schwarze Exp $ REGRESS_TARGETS = badarg broken double eof fill literal longhead REGRESS_TARGETS += macrotag manyargs sameline spacing width @@ -8,6 +8,7 @@ LINT_TARGETS = broken double eof # groff-1.22.3 defects: # - If .TP precedes .RE, the latter does not properly reset indentation. # - If the last line of the file is .TP, groff does not print a page footer. +# - A blank line in .TP next line scope causes a blank line. SKIP_GROFF = broken eof diff --git a/regress/usr.bin/mandoc/man/TP/broken.in b/regress/usr.bin/mandoc/man/TP/broken.in index c111caeb9e1..5638ea33722 100644 --- a/regress/usr.bin/mandoc/man/TP/broken.in +++ b/regress/usr.bin/mandoc/man/TP/broken.in @@ -11,3 +11,7 @@ text .RE regular text +.TP + +head +body diff --git a/regress/usr.bin/mandoc/man/TP/broken.out_ascii b/regress/usr.bin/mandoc/man/TP/broken.out_ascii index e19efdf0275..68fab4f0ba0 100644 --- a/regress/usr.bin/mandoc/man/TP/broken.out_ascii +++ b/regress/usr.bin/mandoc/man/TP/broken.out_ascii @@ -10,6 +10,8 @@ DDEESSCCRRIIPPTTIIOONN indented text regular text + head body + OpenBSD December 16, 2014 TP-BROKEN(1) diff --git a/regress/usr.bin/mandoc/man/TP/broken.out_lint b/regress/usr.bin/mandoc/man/TP/broken.out_lint index 3a1024fcd17..1a3a433b25f 100644 --- a/regress/usr.bin/mandoc/man/TP/broken.out_lint +++ b/regress/usr.bin/mandoc/man/TP/broken.out_lint @@ -1 +1,2 @@ mandoc: broken.in:10:2: WARNING: line scope broken: RE breaks TP +mandoc: broken.in:15:1: WARNING: skipping blank line in line scope diff --git a/usr.bin/mandoc/man.c b/usr.bin/mandoc/man.c index c89fe0789ee..ba7cdd8d386 100644 --- a/usr.bin/mandoc/man.c +++ b/usr.bin/mandoc/man.c @@ -1,4 +1,4 @@ -/* $OpenBSD: man.c,v 1.121 2017/05/08 20:33:40 schwarze Exp $ */ +/* $OpenBSD: man.c,v 1.122 2017/06/03 15:54:09 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2013, 2014, 2015, 2017 Ingo Schwarze @@ -87,14 +87,15 @@ man_ptext(struct roff_man *man, int line, char *buf, int offs) /* Skip leading whitespace. */ ; /* - * Blank lines are ignored right after headings - * but add a single vertical space elsewhere. + * Blank lines are ignored in next line scope and right + * after headings but add a single vertical space elsewhere. */ if (buf[i] == '\0') { - man_breakscope(man, ROFF_sp); - /* Allocate a blank entry. */ - if (man->last->tok != MAN_SH && + if (man->flags & (MAN_ELINE | MAN_BLINE)) + mandoc_msg(MANDOCERR_BLK_BLANK, man->parse, + line, 0, NULL); + else if (man->last->tok != MAN_SH && man->last->tok != MAN_SS) { roff_elem_alloc(man, line, offs, ROFF_sp); man->next = ROFF_NEXT_SIBLING; diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h index 83e49f0e5fb..f6e49fdb70b 100644 --- a/usr.bin/mandoc/mandoc.h +++ b/usr.bin/mandoc/mandoc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mandoc.h,v 1.163 2017/06/02 19:21:03 schwarze Exp $ */ +/* $OpenBSD: mandoc.h,v 1.164 2017/06/03 15:54:09 schwarze Exp $ */ /* * Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons * Copyright (c) 2010-2017 Ingo Schwarze @@ -97,6 +97,7 @@ enum mandocerr { MANDOCERR_FI_SKIP, /* fill mode already enabled, skipping: fi */ MANDOCERR_NF_SKIP, /* fill mode already disabled, skipping: nf */ MANDOCERR_BLK_LINE, /* line scope broken: macro breaks macro */ + MANDOCERR_BLK_BLANK, /* skipping blank line in line scope */ /* related to missing arguments */ MANDOCERR_REQ_EMPTY, /* skipping empty request: request */ diff --git a/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c index 6fb8c1fc324..6909bda9e3b 100644 --- a/usr.bin/mandoc/read.c +++ b/usr.bin/mandoc/read.c @@ -1,4 +1,4 @@ -/* $OpenBSD: read.c,v 1.140 2017/06/01 15:24:41 schwarze Exp $ */ +/* $OpenBSD: read.c,v 1.141 2017/06/03 15:54:09 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010-2017 Ingo Schwarze @@ -135,6 +135,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "fill mode already enabled, skipping", "fill mode already disabled, skipping", "line scope broken", + "skipping blank line in line scope", /* related to missing macro arguments */ "skipping empty request", -- 2.20.1