[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 34/34: [troff]: Refactor.
From: |
G. Branden Robinson |
Subject: |
[groff] 34/34: [troff]: Refactor. |
Date: |
Mon, 16 Sep 2024 20:48:37 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit c4259eb20a66ab9da95741f6cc01d626b3abe632
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sun Sep 15 06:08:23 2024 -0500
[troff]: Refactor.
`\X` reads its delimited argument in interpretation mode and the
`device` request reads its argument in copy mode. We want parity in
special character handling for these formatter instructions, but one
works with tokenized input and the other with tokens that happen to be a
sequence of ordinary characters. (In other words, in `\X'\[em]` and
`.device \[em]`, the escape sequence "knows" that it is dealing with a
the valid special character named "em", whereas the request merely
handles '\', '[', 'e', 'm', and ']' in series.) This change is in
service of the grueling march toward resolution of
<https://savannah.gnu.org/bugs/?63074>.
* src/roff/troff/input.cpp (map_special_character_for_device_output):
New function handles all of the potential special (including
composite) character identifier rewriting formerly in...
(encode_special_character_for_device_output): ...this function, which
now simply calls the foregoing after extracting the special character
identifier from the `charinfo` of the current token.
---
ChangeLog | 23 +++++++++++++++++++++++
src/roff/troff/input.cpp | 23 ++++++++++++++---------
2 files changed, 37 insertions(+), 9 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 17183149c..8d27bff93 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2024-09-15 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ [troff]: Refactor. `\X` reads its delimited argument in
+ interpretation mode and the `device` request reads its argument
+ in copy mode. We want parity in special character handling for
+ these formatter instructions, but one works with tokenized
+ input and the other with tokens that happen to be a sequence of
+ ordinary characters. (In other words, in `\X'\[em]` and
+ `.device \[em]`, the escape sequence "knows" that it is dealing
+ with a the valid special character named "em", whereas the
+ request merely handles '\', '[', 'e', 'm', and ']' in series.)
+ This change is in service of the grueling march toward
+ resolution of <https://savannah.gnu.org/bugs/?63074>.
+
+ * src/roff/troff/input.cpp
+ (map_special_character_for_device_output): New function handles
+ all of the potential special (including composite) character
+ identifier rewriting formerly in...
+ (encode_special_character_for_device_output): ...this function,
+ which now simply calls the foregoing after extracting the
+ special character identifier from the `charinfo` of the current
+ token.
+
2024-09-15 G. Branden Robinson <g.branden.robinson@gmail.com>
* src/roff/troff/input.cpp (do_device_extension): Make `\X`
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 6f133803e..560e19a29 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -5736,16 +5736,9 @@ static node *do_non_interpreted() // \?
return new non_interpreted_node(mac);
}
-// This is a helper function for `encode_character_for_device_output()`.
-static void encode_special_character_for_device_output(macro *mac)
+static void map_special_character_for_device_output(macro *mac,
+ const char *sc)
{
- const char *sc;
- if (font::use_charnames_in_special) {
- charinfo *ci = tok.get_char(true /* required */);
- sc = ci->get_symbol()->contents();
- }
- else
- sc = tok.get_char(true /* required */)->get_symbol()->contents();
if (strcmp("-", sc) == 0)
mac->append('-');
else if (strcmp("dq", sc) == 0)
@@ -5827,6 +5820,18 @@ static void
encode_special_character_for_device_output(macro *mac)
}
}
+static void encode_special_character_for_device_output(macro *mac)
+{
+ const char *sc;
+ if (font::use_charnames_in_special) {
+ charinfo *ci = tok.get_char(true /* required */);
+ sc = ci->get_symbol()->contents();
+ }
+ else
+ sc = tok.get_char(true /* required */)->get_symbol()->contents();
+ map_special_character_for_device_output(mac, sc);
+}
+
// In troff output, we translate the escape character to '\', but it is
// up to the postprocessor to interpret it as such. (This mostly
// matters for device extension commands.)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 34/34: [troff]: Refactor.,
G. Branden Robinson <=