From: schwarze Date: Sat, 18 Aug 2018 21:36:53 +0000 (+0000) Subject: support the highly surprising escape sequence \# (line continuation X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=2c723d0874c54630707bc6bc3baf2946a48b0612;p=openbsd support the highly surprising escape sequence \# (line continuation with comment); used for example by gropdf(1) --- diff --git a/share/man/man7/roff.7 b/share/man/man7/roff.7 index 6a7849ed8d7..b2edb41e8f7 100644 --- a/share/man/man7/roff.7 +++ b/share/man/man7/roff.7 @@ -1,4 +1,4 @@ -.\" $OpenBSD: roff.7,v 1.79 2018/08/16 14:01:35 schwarze Exp $ +.\" $OpenBSD: roff.7,v 1.80 2018/08/18 21:36:53 schwarze Exp $ .\" .\" Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons .\" Copyright (c) 2010-2018 Ingo Schwarze @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: August 16 2018 $ +.Dd $Mdocdate: August 18 2018 $ .Dt ROFF 7 .Os .Sh NAME @@ -1817,6 +1817,12 @@ is an unpaddable space-sized non-breaking space character; see .Ss \e\(dq The rest of the input line is treated as .Sx Comments . +.Ss \e# +Line continuation with comment. +Discard the rest of the physical input line and continue the logical +input line on the next physical input line, joining the text on +both lines together as if it were on a single input line. +This is a groff extension. .Ss \e% Hyphenation allowed at this point of the word; ignored by .Xr mandoc 1 . diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c index 364c6b1cb79..1e8b65eaef6 100644 --- a/usr.bin/mandoc/roff.c +++ b/usr.bin/mandoc/roff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: roff.c,v 1.205 2018/08/18 02:03:41 schwarze Exp $ */ +/* $OpenBSD: roff.c,v 1.206 2018/08/18 21:36:53 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons * Copyright (c) 2010-2015, 2017, 2018 Ingo Schwarze @@ -1203,7 +1203,14 @@ roff_res(struct roff *r, struct buf *buf, int ln, int pos) r->man->next = ROFF_NEXT_SIBLING; } - /* Discard comments. */ + /* Line continuation with comment. */ + + if (stesc[1] == '#') { + *stesc = '\0'; + return ROFF_APPEND; + } + + /* Discard normal comments. */ while (stesc > start && stesc[-1] == ' ') stesc--;