gbranden pushed a commit to branch master
in repository groff.
commit f51804f3cb7fa260ade301b2b77d9489ffa7eaaf
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Nov 22 03:17:32 2026 -0600
[grotty]: Implement `-O` option.
...to suppress operation of groff's "continuous underlining" extension.
* src/devices/grotty/tty.cpp: Add new global Boolean
`want_continuous_underlining` to parameterize it. Default true.
(tty_printer::special): Recognize `x u` grout command only if
`want_continuous_underlining` is true.
(main): Inform getopt_long(3) of new option letter. Handle it.
(usage): Document it.
* src/devices/grotty/grotty.1.man (Synopsis, Options): Document it.
* src/devices/grotty/tests/O-option-works.sh:
* src/devices/grotty/grotty.am: Test it.
Fixes <https://savannah.gnu.org/bugs/?68863>.
NEWS: Add item.
---
ChangeLog | 20 +++++++++++
NEWS | 13 +++++++
src/devices/grotty/grotty.1.man | 12 +++++--
src/devices/grotty/grotty.am | 1 +
src/devices/grotty/tests/O-option-works.sh | 58 ++++++++++++++++++++++++++++++
src/devices/grotty/tty.cpp | 13 ++++---
6 files changed, 111 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 20968aaeb..e14ebab6f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2026-11-22 G. Branden Robinson <[email protected]>
+
+ [grotty]: Implement `-O` option to suppress operation of groff's
+ "continuous underlining" extension.
+
+ * src/devices/grotty/tty.cpp: Add new global Boolean
+ `want_continuous_underlining` to parameterize it. Default true.
+ (tty_printer::special): Recognize `x u` grout command only if
+ `want_continuous_underlining` is true.
+ (main): Inform getopt_long(3) of new option letter. Handle it.
+ (usage): Document it.
+
+ * src/devices/grotty/grotty.1.man (Synopsis, Options): Document
+ it.
+
+ * src/devices/grotty/tests/O-option-works.sh:
+ * src/devices/grotty/grotty.am: Test it.
+
+ Fixes <https://savannah.gnu.org/bugs/?68863>.
+
2026-11-22 G. Branden Robinson <[email protected]>
[grotty]: Unit-test continuous underlining.
diff --git a/NEWS b/NEWS
index 338758d32..048c28805 100644
--- a/NEWS
+++ b/NEWS
@@ -55,6 +55,19 @@ soelim
* soelim now recognizes an option `-x` that promotes failure to open
any included file from a warning to a fatal error.
+Output drivers
+--------------
+
+* grotty now supports a `-O` option that suppresses recognition of
+ groff's extended `u` device command, which implements continuous
+ underlining. The only practical consequence this has is that spaces
+ within a continuously underlined area don't become `_`. Graphical
+ characters _do_ still get underlined, other options notwithstanding.
+ The advantage (and motivation) is that by specifying `-cboOu`, you
+ can force grotty to produce plain text output--meaning neither
+ overstriking sequences nor ISO 6429 escape sequences appear in its
+ output.
+
VERSION 1.25.0
==============
diff --git a/src/devices/grotty/grotty.1.man b/src/devices/grotty/grotty.1.man
index 79709ede2..c8ca08dbd 100644
--- a/src/devices/grotty/grotty.1.man
+++ b/src/devices/grotty/grotty.1.man
@@ -52,7 +52,7 @@ output driver for typewriter-like (terminal) devices
.\" ====================================================================
.
.SY grotty
-.RB [ \-dfhot ]
+.RB [ \-dfhoOt ]
.RB [ \-i \||\| \-r ]
.RB [ \-F\~\c
.IR font-directory ]
@@ -62,7 +62,7 @@ output driver for typewriter-like (terminal) devices
.
.P
.SY "grotty \-c"
-.RB [ \-bBdfhouU ]
+.RB [ \-bBdfhoOuU ]
.RB [ \-F\~\c
.IR font-directory ]
.RI [ file\~ .\|.\|.]
@@ -596,6 +596,14 @@ and
.
.
.TP
+.B \-O
+Suppress recognition of continuous underlining device command.
+.\" The only practical consequence this has is that spaces within a
+.\" continuously underlined area don't become `_`. Graphical characters
+.\" _do_ still get underlined, other options notwithstanding.
+.
+.
+.TP
.B \-r
Render fonts marked as slanted
with the SGR attribute for reverse video text
diff --git a/src/devices/grotty/grotty.am b/src/devices/grotty/grotty.am
index e637cb274..3da08a882 100644
--- a/src/devices/grotty/grotty.am
+++ b/src/devices/grotty/grotty.am
@@ -34,6 +34,7 @@ EXTRA_DIST += \
src/devices/grotty/grotty.1.man
grotty_TESTS = \
+ src/devices/grotty/tests/O-option-works.sh \
src/devices/grotty/tests/basic-latin-glyphs-map-correctly.sh \
src/devices/grotty/tests/continuous-underlining-works.sh \
src/devices/grotty/tests/do-not-segv-on-huge-vertical-motion.sh \
diff --git a/src/devices/grotty/tests/O-option-works.sh
b/src/devices/grotty/tests/O-option-works.sh
new file mode 100755
index 000000000..cf3a44799
--- /dev/null
+++ b/src/devices/grotty/tests/O-option-works.sh
@@ -0,0 +1,58 @@
+#!/bin/sh
+#
+# Copyright 2026 G. Branden Robinson
+#
+# This file is part of groff, the GNU roff typesetting system.
+#
+# groff is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# groff is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+grotty="${abs_top_builddir:-.}/grotty"
+
+input='#
+x T ascii
+x res 240 24 40
+x init
+p1
+V40
+H0
+x font 2 I
+f2
+s10
+V40
+H0
+md
+DFd
+x u 1
+tabc
+wh24
+tdef
+x font 1 R
+f1
+V40
+H168
+x u 0
+n40 0
+x trailer
+V2640
+x stop
+#'
+
+output=$(printf '%s\n' "$input" \
+ | "$grotty" -F font -F build/font -cboOu \
+ | sed '/^$/d')
+echo "$output"
+echo "$output" | od -c
+echo "$output" | od -c | grep -Eq '^0000000.*a +b +c + +d +e +f'
+
+# vim:set autoindent expandtab shiftwidth=4 tabstop=4 textwidth=72:
diff --git a/src/devices/grotty/tty.cpp b/src/devices/grotty/tty.cpp
index 40f9fb4df..7538cc01a 100644
--- a/src/devices/grotty/tty.cpp
+++ b/src/devices/grotty/tty.cpp
@@ -73,6 +73,7 @@ static bool do_bold;
static bool want_italics_by_underlining = true;
static bool do_underline;
static bool want_glyph_composition_by_overstriking = true;
+static bool want_continuous_underlining = true;
static bool allow_drawing_commands = true;
static bool want_sgr_italics = false;
static bool do_sgr_italics;
@@ -485,7 +486,7 @@ void tty_printer::simple_add_char(const output_character c,
void tty_printer::special(char *arg, const environment *env, char type)
{
- if (type == 'u') {
+ if ((type == 'u') && want_continuous_underlining) {
add_char(*arg - '0', 0, env->hpos, env->vpos, env->col, env->fill,
CU_MODE);
return;
@@ -1060,7 +1061,7 @@ int main(int argc, char **argv)
{ "version", no_argument, 0 /* nullptr */, 'v' },
{ 0 /* nullptr */, 0, 0 /* nullptr */, 0 }
};
- while ((c = getopt_long(argc, argv, ":bBcdfF:hiI:ortuUv",
+ while ((c = getopt_long(argc, argv, ":bBcdfF:hiI:oOrtuUv",
long_options, 0 /* nullptr */))
!= EOF)
switch (c) {
@@ -1087,6 +1088,10 @@ int main(int argc, char **argv)
// Do not underline.
want_italics_by_underlining = false;
break;
+ case 'O':
+ // Do not continuously underline.
+ want_continuous_underlining = false;
+ break;
case 'o':
// Do not overstrike (other than emboldening and underlining).
want_glyph_composition_by_overstriking = false;
@@ -1156,8 +1161,8 @@ int main(int argc, char **argv)
static void usage(FILE *stream)
{
fprintf(stream,
-"usage: %s [-dfhot] [-i|-r] [-F font-directory] [file ...]\n"
-"usage: %s -c [-bBdfhouU] [-F font-directory] [file ...]\n"
+"usage: %s [-dfhoOt] [-i|-r] [-F font-directory] [file ...]\n"
+"usage: %s -c [-bBdfhoOuU] [-F font-directory] [file ...]\n"
"usage: %s {-v | --version}\n"
"usage: %s --help\n",
program_name, program_name, program_name, program_name);
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit