Update of bug #68845 (group groff):
Summary: [troff] make `pev` request report environment's
control and no-break control characters => [PATCH] [troff] make `pev` request
report environment's control and no-break control characters
_______________________________________________________
Follow-up Comment #1:
Even works for weird ones.
$ printf '.cc \002\n\002c2 \004\n\002pev\n' | ./build/test-groff 2>&1 | grep
'control char'
control character: U+0002
no-break control character: U+0004
diff --git a/ChangeLog b/ChangeLog
index 4cc5bf38b..20f1ff0c5 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]>
* src/roff/troff/div.cpp (need_vertical_space_request)
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 6282c897a..f2fb12c58 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
@@ -3775,6 +3790,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);
}
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?68845>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc
Description: PGP signature
