Update of bug #68130 (group groff):
Planned Release: None => 1.25.0
Summary: [troff] add `.ul` register for parity with `.ce`,
`.it`, and `.rj' => [PATCH] [troff] add `.ul` register for parity with `.ce`,
`.it`, and `.rj'
_______________________________________________________
Follow-up Comment #1:
Pretty straightforward to do.
diff --git a/ChangeLog b/ChangeLog
index d210d22a3..1bbdb3bb3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2026-03-14 G. Branden Robinson <[email protected]>
+
+ [troff]: Implement `.ul` register for orthogonal completeness
+ with respect to the `.ce`, `.rj`, and `.itc` registers.
+
+ * src/roff/troff/env.h (class environment): Declare new accessor
+ member function `get_underlined_line_count()`.
+ * src/roff/troff/env.cpp
+ (environment::get_underlined_line_count): Define it.
+ (init_env_requests): Wire up `.ul` register name to
+ `get_underlined_line_count()`.
+
+ * src/roff/groff/tests/dot-ul-register-works.sh: Test it.
+ * src/roff/groff/groff.am (groff_TESTS): Run test.
+
+ * doc/groff.texi.in (Artificial Fonts):
+ * man/groff.7.man (Read-only registers):
+ * man/groff_diff.7.man (New registers):
+ * NEWS: Document it.
+
+ Fixes <https://savannah.gnu.org/bugs/?68130>.
+
2026-03-10 G. Branden Robinson <[email protected]>
[troff]: Fix Savannah #68137.
diff --git a/NEWS b/NEWS
index 0bff96225..bdb002fc1 100644
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,10 @@ troff
* GNU troff, the formatter, now issues warnings in the "delim",
"syntax", and "escape" categories by default.
+* A new read-only register `.ul` reports the count of productive input
+ lines remaining to be be underlined in the environment (as configured
+ by either the `cu` or `ul` requests).
+
VERSION 1.24.1
==============
diff --git a/doc/groff.texi.in b/doc/groff.texi.in
index 41291d29b..756098c2b 100644
--- a/doc/groff.texi.in
+++ b/doc/groff.texi.in
@@ -13901,7 +13901,8 @@
never incremented or decremented.
@endDefesc
-@Defreq {ul, [@Var{lines}]}
+@DefreqList {ul, [@Var{lines}]}
+@DefregListEndx {.ul}
@cindex underlining (@code{ul})
The @code{ul} request normally underlines subsequent lines if a TTY
output device is used. Otherwise, the lines are printed in italics
@@ -13918,9 +13919,13 @@
is possible to change fonts, but after the last line affected by
@code{ul} the saved font is restored.
-This number of lines still to be underlined is associated with the
-environment (@pxref{Environments}). The underline font can be changed
-with the @code{uf} request.
+The count of lines still to be underlined
+is associated with the environment
+and is available in the read-only register
+@samp{.ul};
+it is associated with the environment.@footnote{@xref{Environments}.}
+@code{uf}
+request changes the underline font.
@c XXX @xref should be changed to grotty
diff --git a/man/groff.7.man b/man/groff.7.man
index 71c6b565e..dd43b5622 100644
--- a/man/groff.7.man
+++ b/man/groff.7.man
@@ -7552,6 +7552,16 @@ .SS "Read-only registers"
option.
.
.TP
+.REG .ul
+Count of input lines remaining to be underlined
+in the environment.
+.
+See
+.request cu
+and
+.request ul .
+.
+.TP
.REG .v
The environment's vertical line spacing;
see
diff --git a/man/groff_diff.7.man b/man/groff_diff.7.man
index bfa76526d..43b8a174f 100644
--- a/man/groff_diff.7.man
+++ b/man/groff_diff.7.man
@@ -5255,6 +5255,13 @@ .SS "New registers"
.
.
.TP
+.B \[rs]n[.ul]
+Interpolate count of input lines remaining to be underlined
+(continuously or not)
+in the environment.
+.
+.
+.TP
.B \[rs]n[.vpt]
Interpolate\~1 if vertical position traps are enabled,
0\~otherwise.
diff --git a/src/roff/groff/groff.am b/src/roff/groff/groff.am
index 4654731ee..d821dc73d 100644
--- a/src/roff/groff/groff.am
+++ b/src/roff/groff/groff.am
@@ -74,6 +74,7 @@ groff_TESTS = \
src/roff/groff/tests/dot-nm-register-works.sh \
src/roff/groff/tests/dot-nn-register-works.sh \
src/roff/groff/tests/dot-trap-register-works.sh \
+ src/roff/groff/tests/dot-ul-register-works.sh \
src/roff/groff/tests/double-do-request-does-not-fail-assertion.sh \
src/roff/groff/tests/draw-arc.sh \
src/roff/groff/tests/draw-circle.sh \
diff --git a/src/roff/groff/tests/dot-ul-register-works.sh
b/src/roff/groff/tests/dot-ul-register-works.sh
new file mode 100755
index 000000000..1635b85ce
--- /dev/null
+++ b/src/roff/groff/tests/dot-ul-register-works.sh
@@ -0,0 +1,59 @@
+#!/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/>.
+
+groff="${abs_top_builddir:-.}/test-groff"
+
+# Unit test .ul register.
+
+input='.
+.ec @
+.nf
+.ul 2
+foo @n[.ul]
+bar @n[.ul]
+baz @n[.ul]
+.cu 1
+qux @n[.ul]
+jat @n[.ul]
+.'
+
+# Omitting `-P -cbou` would better illustrate the `cu` and `ul` requests
+# themselves, but is more tedious to pattern-match.
+#
+# Expected output:
+# foo 2
+# bar 1
+# baz 0
+# qux 1
+# jat 0
+output=$(echo "$input" | $groff -T ascii -P -cbou)
+echo "$output"
+echo "$output" | grep -qx "foo 2" || exit 1
+echo "$output" | grep -qx "bar 1" || exit 1
+echo "$output" | grep -qx "baz 0" || exit 1
+# Backspace-overstriking still occurs when the continuous underlining
+# device extension is used. That's probably correct given the
+# long-standing semantics of grotty(1)'s `-o` and `-u` options, but it
+# may also militate for a means of obtaining "least common denominator
+# of video terminal and Teletype Model 37" output, which is what some
+# external tools expect of grotty anyway. See Savannah #67947.
+echo "$output" | grep -qx "qux.*1" || exit 1
+echo "$output" | grep -qx "jat 0" || exit 1
+
+# vim:set autoindent expandtab shiftwidth=2 tabstop=2 textwidth=72:
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index a229f34c1..07d3aa4e7 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -475,6 +475,11 @@ int environment::get_hyphen_line_count()
return hyphen_line_count;
}
+int environment::get_underlined_line_count()
+{
+ return underlined_line_count;
+}
+
int environment::get_centered_line_count()
{
return centered_line_count;
@@ -4434,6 +4439,7 @@ void init_env_requests()
init_string_env_reg(".sty", get_style_name_string);
init_string_env_reg(".tabs", get_tabs);
init_int_env_reg(".u", get_fill);
+ init_int_env_reg(".ul", get_underlined_line_count);
init_vunits_env_reg(".v", get_vertical_spacing);
init_hunits_env_reg(".w", get_prev_char_width);
init_int_env_reg(".zoom", get_zoom);
diff --git a/src/roff/troff/env.h b/src/roff/troff/env.h
index 10607b8aa..25612b1f9 100644
--- a/src/roff/troff/env.h
+++ b/src/roff/troff/env.h
@@ -328,6 +328,7 @@ public:
int get_hyphen_line_count();
hunits get_hyphenation_space();
hunits get_hyphenation_margin();
+ int get_underlined_line_count();
int get_centered_line_count();
int get_input_trap_line_count();
int get_input_trap_respects_continuation();
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?68130>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc
Description: PGP signature
