URL: <https://savannah.gnu.org/bugs/?65137>
Summary: [troff] support construction of arbitrary byte sequences in device control commands Group: GNU roff Submitter: gbranden Submitted: Mon 08 Jan 2024 10:13:02 AM UTC Category: Core Severity: 1 - Wish Item Group: Feature change Status: None Privacy: Public Assigned to: None Open/Closed: Open Discussion Lock: Any Planned Release: None _______________________________________________________ Follow-up Comments: ------------------------------------------------------- Date: Mon 08 Jan 2024 10:13:02 AM UTC By: G. Branden Robinson <gbranden> This is my generalization of Deri's `stringhex` request in the deri-gropdf-ng branch. In my working copy, I embedded the idea where the code would go. diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp index a0b987634..f6e5b1279 100644 --- a/src/roff/troff/input.cpp +++ b/src/roff/troff/input.cpp @@ -5571,7 +5571,7 @@ static node *do_non_interpreted() return new non_interpreted_node(mac); } -static void encode_char(macro *mac, char c) +static void encode_char_for_device_control(macro *mac, char c) { if (c == '\0') { if (tok.is_stretchable_space() @@ -5600,6 +5600,13 @@ static void encode_char(macro *mac, char c) else if (strcmp("ti", sc) == 0) mac->append('~'); else { + // TODO: Support '\[uXXXX]' for all devices to support + // transmission of arbitrary data to the output device. It's a + // misnomer--this doesn't necessarily represent a Unicode code + // point, but this syntax beats inventing a new one for this + // esoteric purpose. Whether one sends \[uAABB], + // \[u00AA]\[u00BB], or the latter's byte-swapped counterpart is + // an interface detail that the output device must specify. if (font::use_charnames_in_special) { if (sc[0] != (char)0) { mac->append('\\'); @@ -5612,9 +5619,14 @@ static void encode_char(macro *mac, char c) mac->append(']'); } else - error("special character '%1' cannot be used within" - " device control escape sequence", sc); + error("special character '%1' cannot be used within a" + " device control escape sequence", sc); } + else + // TODO: Put '\[uXXXX]' support here. Don't allow + // '\[uXXXX_YYYY]'. + error("special character '%1' cannot be used within a device" + " control escape sequence", sc); } } else if (!(tok.is_hyphen_indicator() @@ -5668,7 +5680,7 @@ static node *do_special() c = '\b'; else c = tok.ch(); - encode_char(&mac, c); + encode_char_for_device_control(&mac, c); } return new special_node(mac); } _______________________________________________________ Reply to this item at: <https://savannah.gnu.org/bugs/?65137> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/