From f1c726aa8f5cc9c8ab96782dcfdfd0d2875eb42e Mon Sep 17 00:00:00 2001 From: schwarze Date: Tue, 16 Aug 2022 22:59:48 +0000 Subject: [PATCH] Restore the traditional behaviour of the man(7) single-font macros .B, .I, .SM, and .SB that the next-line scope extends to the end of the next logical input line and is not extended if that line ends with a \c (no-space) escape sequence. While improving a loosely related feature in the man(7) .TP macro, a regression entered the groff codebase in groff commit 3549fd9f (28-Apr-2017) caused by the usual sloppiness of Bjarni Ingi Gislason. Since that time, groff wrongly had \c extend next-line scope to a second line for these macros. In man.c rev. 1.127 (25-Aug-2018) i synched mandoc behaviour with groff in this respect, unfortunately failing to notice the recent regression in groff. The groff regression was finally fixed by gbranden@ in commit 09c028f3 (07-Jun-2022). With the present commit, mandoc is back in sync with both GNU and Heirloom roff regarding the interaction of single-font macros with \c. --- usr.bin/mandoc/man.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/usr.bin/mandoc/man.c b/usr.bin/mandoc/man.c index 0a522b6dbf3..b719de723a0 100644 --- a/usr.bin/mandoc/man.c +++ b/usr.bin/mandoc/man.c @@ -1,4 +1,4 @@ -/* $OpenBSD: man.c,v 1.136 2022/04/28 10:17:37 schwarze Exp $ */ +/* $OpenBSD: man.c,v 1.137 2022/08/16 22:59:48 schwarze Exp $ */ /* * Copyright (c) 2013-2015,2017-2019,2022 Ingo Schwarze * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons @@ -74,16 +74,7 @@ man_hasc(char *start) void man_descope(struct roff_man *man, int line, int offs, char *start) { - /* Trailing \c keeps next-line scope open. */ - - if (start != NULL && man_hasc(start) != NULL) - return; - - /* - * Co-ordinate what happens with having a next-line scope open: - * first close out the element scopes (if applicable), - * then close out the block scope (also if applicable). - */ + /* First close out all next-line element scopes, if any. */ if (man->flags & MAN_ELINE) { while (man->last->parent->type != ROFFT_ROOT && @@ -91,6 +82,14 @@ man_descope(struct roff_man *man, int line, int offs, char *start) man_unscope(man, man->last->parent); man->flags &= ~MAN_ELINE; } + + /* Trailing \c keeps next-line block scope open. */ + + if (start != NULL && man_hasc(start) != NULL) + return; + + /* Close out the next-line block scope, if there is one. */ + if ( ! (man->flags & MAN_BLINE)) return; man_unscope(man, man->last->parent); -- 2.20.1