gbranden pushed a commit to branch master
in repository groff.
commit b4389abb267c36b3ca3b32c5643e4ab7e0fa8324
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Aug 30 01:22:00 2024 -0500
[troff]: Detect special chars in `\X` arg better.
* src/roff/troff/input.cpp (encode_special_character_for_device_output):
Improve detection of non-Unicode special character escape sequences.
Continues fixing Savannah #63074.
Exhibit:
$ printf '\\X@\\[notdef]\\[bs]\\[u1000]\\[bracketrighttp]\\[u23A4]@\n.pl
1v\n' | ./build/test-groff -ww -Z | grep '^x X'
troff:<standard input>:1: error: special character 'notdef' is unusable
within a device control escape sequence
troff:<standard input>:1: error: special character 'bs' is unusable within
a device control escape sequence
x X \[u1000]\[u23A4]\[u23A4]
You can still get an error (though I plan to make that a warning in the
'char' category since input processing continues), but only for the
small handful of groff special character identifiers that lack a mapping
to a Unicode character--like the Bell System logo, shown above.
...or if it just plain doesn't exist, as with 'notdef'.
---
ChangeLog | 6 ++++++
src/roff/troff/input.cpp | 3 +--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 139118b47..63a60b5d8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-08-30 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/input.cpp
+ (encode_special_character_for_device_output): Improve detection
+ of non-Unicode special character escape sequences.
+
2024-08-30 G. Branden Robinson <[email protected]>
[troff]: Reject some nonsense in `\X` arguments.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index ad63047c6..16cc0e7ad 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -5740,8 +5740,7 @@ static void
encode_special_character_for_device_output(macro *mac)
// special character escape sequence already, try to convert it
// into one. Output drivers don't (and shouldn't) know anything
// about a troff formatter's special character identifiers.
- if ((strlen(sc) < 3)
- || (!csxdigit(sc[1]) && (!csxdigit(sc[2])))) {
+ if ((strlen(sc) < 3) || (sc[0] != 'u')) {
const char *un = glyph_name_to_unicode(sc);
if (un != 0 /* nullptr */)
strncpy(character, un, UNIBUFSZ);
_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit