gbranden pushed a commit to branch master
in repository groff.
commit ea40e5ee197f9081afd07320283c464bcd011f9b
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Nov 1 23:52:48 2026 -0600
[troff]: Fix Savannah #68845.
* src/roff/troff/env.cpp (char_as_unicode_buf): New `static` `inline`
function formats an `unsigned char` (a "groff character") as a Unicode
code point in idiomatic "U+FFFF" notation.
(environment::dump): Report values of control and no-break control
characters.
Fixes <https://savannah.gnu.org/bugs/?68845>.
NEWS: Add item.
---
ChangeLog | 11 +++++++++++
NEWS | 3 +++
src/roff/troff/env.cpp | 26 ++++++++++++++++++++++++++
3 files changed, 40 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index b06bb1bf3..3e4ea0f41 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2026-11-01 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/env.cpp (char_as_unicode_buf): New `static`
+ `inline` function formats an `unsigned char` (a "groff
+ character") as a Unicode code point in idiomatic "U+FFFF"
+ notation.
+ (environment::dump): Report values of control and no-break
+ control characters.
+
+ Fixes <https://savannah.gnu.org/bugs/?68845>.
+
2026-11-01 G. Branden Robinson <[email protected]>
[troff]: Implement new `.sv` read-only register.
diff --git a/NEWS b/NEWS
index 7603411ce..d1e760397 100644
--- a/NEWS
+++ b/NEWS
@@ -27,6 +27,9 @@ troff
saved by the most recent `sv` request, if it has not yet been output
with the `os` request.
+* The `pev` request now reports the environment's selected control and
+ no-break control characters.
+
* The formatter now emits a warning in category "style" if -crementing
interpolation (such as `\n+[myreg]` or `\n-[count]`) is (uselessly)
applied to a non-auto-crementing register.
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index d0d98e531..0d0edebca 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -3619,6 +3619,21 @@ const char
*environment::get_requested_point_size_string()
return sptoa(curenv->get_requested_point_size());
}
+// TODO: Promote this static buffer and function to libgroff?
+//
+// C++11: constexpr size_t char_as_unicode_buf_size
+// = sizeof("U+10FFFF" + 1);
+const size_t char_as_unicode_buf_size = 9; // "U+10FFFF" + 1 /* '\0' */
+static char char_as_unicode_buf[char_as_unicode_buf_size];
+
+static inline const char *char_as_unicode_code_point(unsigned char c)
+{
+ (void) memset(char_as_unicode_buf, 0, char_as_unicode_buf_size);
+ (void) snprintf(char_as_unicode_buf, char_as_unicode_buf_size,
+ "U+%04X", c);
+ return char_as_unicode_buf;
+}
+
void environment::dump()
{
// At the time this request is invoked, the following values are zero
@@ -3776,6 +3791,17 @@ void environment::dump()
errprint(" previous fill color: %1\n",
get_prev_fill_color_string());
errprint(" fill color: %1\n", get_fill_color_string());
+ errprint(" control character: ", control_character);
+ if (csprint(control_character))
+ errprint("%1\n", control_character);
+ else
+ errprint("%1\n", char_as_unicode_code_point(control_character));
+ errprint(" no-break control character: ");
+ if (csprint(no_break_control_character))
+ errprint("%1\n", no_break_control_character);
+ else
+ errprint("%1\n",
+ char_as_unicode_code_point(no_break_control_character));
fflush(stderr);
}
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit