From aa5d553d4a2da96856c7afbc2aec5739c63a1a81 Mon Sep 17 00:00:00 2001 From: schwarze Date: Fri, 20 May 2022 13:06:26 +0000 Subject: [PATCH] Re-classify the roff(7) \r (reverse line feed) escape sequence from "ignore" to "unsupported" because when an input file uses it, mandoc(1) is likely to significantly misformat the output, usually showing parts of the output in a different order than the author intended. --- regress/usr.bin/mandoc/roff/esc/Makefile | 11 ++++++----- regress/usr.bin/mandoc/roff/esc/r.in | 13 +++++++++++++ regress/usr.bin/mandoc/roff/esc/r.out_ascii | 11 +++++++++++ regress/usr.bin/mandoc/roff/esc/r.out_lint | 1 + share/man/man7/roff.7 | 10 +++++----- usr.bin/mandoc/roff_escape.c | 4 ++-- 6 files changed, 38 insertions(+), 12 deletions(-) create mode 100644 regress/usr.bin/mandoc/roff/esc/r.in create mode 100644 regress/usr.bin/mandoc/roff/esc/r.out_ascii create mode 100644 regress/usr.bin/mandoc/roff/esc/r.out_lint diff --git a/regress/usr.bin/mandoc/roff/esc/Makefile b/regress/usr.bin/mandoc/roff/esc/Makefile index 111e59bc715..bd39e37883d 100644 --- a/regress/usr.bin/mandoc/roff/esc/Makefile +++ b/regress/usr.bin/mandoc/roff/esc/Makefile @@ -1,15 +1,16 @@ -# $OpenBSD: Makefile,v 1.20 2022/05/01 16:18:59 schwarze Exp $ +# $OpenBSD: Makefile,v 1.21 2022/05/20 13:06:27 schwarze Exp $ REGRESS_TARGETS = one two multi comment -REGRESS_TARGETS += B bs_man bs_mdoc c c_man E1 e f h hneg l O1 o p w z +REGRESS_TARGETS += B bs_man bs_mdoc c c_man E1 e f h hneg l O1 o p r w z REGRESS_TARGETS += ignore invalid unsupp HTML_TARGETS = f -LINT_TARGETS = comment B h l O1 w ignore invalid unsupp +LINT_TARGETS = comment B h l O1 r w ignore invalid unsupp -# mandoc defect: +# mandoc defects: # - \h with a negative argument replaces output characters # instead of overstriking them +# - \r does not return to the previous output line -SKIP_GROFF = hneg +SKIP_GROFF = hneg r .include diff --git a/regress/usr.bin/mandoc/roff/esc/r.in b/regress/usr.bin/mandoc/roff/esc/r.in new file mode 100644 index 00000000000..835121d9517 --- /dev/null +++ b/regress/usr.bin/mandoc/roff/esc/r.in @@ -0,0 +1,13 @@ +.\" $OpenBSD: r.in,v 1.1 2022/05/20 13:06:27 schwarze Exp $ +.Dd $Mdocdate: May 20 2022 $ +.Dt ESC-R 1 +.Os +.Sh NAME +.Nm esc-r +.Nd the roff reverse line feed escape sequence +.Sh DESCRIPTION +.Bd -literal +first line +before\rafter +last line +.Ed diff --git a/regress/usr.bin/mandoc/roff/esc/r.out_ascii b/regress/usr.bin/mandoc/roff/esc/r.out_ascii new file mode 100644 index 00000000000..83ec9425d9c --- /dev/null +++ b/regress/usr.bin/mandoc/roff/esc/r.out_ascii @@ -0,0 +1,11 @@ +ESC-R(1) General Commands Manual ESC-R(1) + +NNAAMMEE + eesscc--rr - the roff reverse line feed escape sequence + +DDEESSCCRRIIPPTTIIOONN + first line + beforeafter + last line + +OpenBSD May 20, 2022 OpenBSD diff --git a/regress/usr.bin/mandoc/roff/esc/r.out_lint b/regress/usr.bin/mandoc/roff/esc/r.out_lint new file mode 100644 index 00000000000..d86f19ff4ad --- /dev/null +++ b/regress/usr.bin/mandoc/roff/esc/r.out_lint @@ -0,0 +1 @@ +mandoc: r.in:11:7: UNSUPP: unsupported escape sequence: \r diff --git a/share/man/man7/roff.7 b/share/man/man7/roff.7 index b32f27d5ae1..cd334c0f30c 100644 --- a/share/man/man7/roff.7 +++ b/share/man/man7/roff.7 @@ -1,7 +1,7 @@ -.\" $OpenBSD: roff.7,v 1.97 2022/01/01 03:59:22 jsg Exp $ +.\" $OpenBSD: roff.7,v 1.98 2022/05/20 13:06:27 schwarze Exp $ .\" +.\" Copyright (c) 2010-2019, 2022 Ingo Schwarze .\" Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons -.\" Copyright (c) 2010-2019 Ingo Schwarze .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above @@ -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: January 1 2022 $ +.Dd $Mdocdate: May 20 2022 $ .Dt ROFF 7 .Os .Sh NAME @@ -2166,8 +2166,8 @@ Break the output line at the end of the current word. Set number register; ignored by .Xr mandoc 1 . .It Ic \er -Move up by one line; ignored by -.Xr mandoc 1 . +Reverse line feed: move up by one output line. +Currently unsupported. .It Ic \eS\(aq Ns Ar number Ns Ic \(aq Slant output; ignored by .Xr mandoc 1 . diff --git a/usr.bin/mandoc/roff_escape.c b/usr.bin/mandoc/roff_escape.c index 4571873d152..0780cce2a0f 100644 --- a/usr.bin/mandoc/roff_escape.c +++ b/usr.bin/mandoc/roff_escape.c @@ -1,4 +1,4 @@ -/* $OpenBSD: roff_escape.c,v 1.1 2022/05/19 15:17:51 schwarze Exp $ */ +/* $OpenBSD: roff_escape.c,v 1.2 2022/05/20 13:06:26 schwarze Exp $ */ /* * Copyright (c) 2011, 2012, 2013, 2014, 2015, 2017, 2018, 2020, 2022 * Ingo Schwarze @@ -103,6 +103,7 @@ roff_escape(const char *buf, const int ln, const int aesc, case '!': case '?': + case 'r': rval = ESCAPE_UNSUPP; goto out; @@ -114,7 +115,6 @@ roff_escape(const char *buf, const int ln, const int aesc, case '^': case 'a': case 'd': - case 'r': case 't': case 'u': case '{': -- 2.20.1