[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 02/04: [troff]: Enable ASCII in device control escapes.
From: |
G. Branden Robinson |
Subject: |
[groff] 02/04: [troff]: Enable ASCII in device control escapes. |
Date: |
Fri, 1 Oct 2021 07:53:03 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 9d61b3d142842589b90d7eda0ed3270fbbf6166f
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Fri Oct 1 19:20:25 2021 +1000
[troff]: Enable ASCII in device control escapes.
[troff]: Convert special character glyphs corresponding to Unicode Basic
Latin ("ASCII") code points to those code points when they occur in
device escapes. (They should be correct for IBM code page 1047 as well,
but this is untested.) This is necessary for encoding URLs in device
control commands. Special character identifiers are presumed to be the
defaults documented in groff_char(7); this is a design gap that we
should consider addressing. (We don't have a way to ask "is this the
special character corresponding to Unicode basic Latin code point X?")
* src/roff/troff/input.cpp (encode_char): Do it.
I'm not documenting this in NEWS as it feels like a pretty dusty corner
even though I'm about to leverage it for something of much higher
visibility.
---
ChangeLog | 14 ++++++++++++++
src/roff/troff/input.cpp | 19 +++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 84c5ac8..1653477 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2021-10-01 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ [troff]: Convert special character glyphs corresponding to
+ Unicode Basic Latin ("ASCII") code points to those code points
+ when they occur in device escapes. (They should be correct for
+ IBM code page 1047 as well, but this is untested.) This is
+ necessary for encoding URLs in device control commands. Special
+ character identifiers are presumed to be the defaults documented
+ in groff_char(7); this is a design gap that we should consider
+ addressing. (We don't have a way to ask "is this the special
+ character corresponding to Unicode basic Latin code point X?")
+
+ * src/roff/troff/input.cpp (encode_char): Do it.
+
2021-09-30 G. Branden Robinson <g.branden.robinson@gmail.com>
[man, mdoc]: Draw line after each page more consistently in
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index ed8f71a..700399b 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -5414,6 +5414,25 @@ static void encode_char(macro *mac, char c)
else if (tok.is_stretchable_space()
|| tok.is_unstretchable_space())
mac->append(' ');
+ else if (tok.is_special()) {
+ const char *sc = tok.get_char()->get_symbol()->contents();
+ if (strcmp("-", sc) == 0)
+ mac->append('-');
+ else if (strcmp("aq", sc) == 0)
+ mac->append('\'');
+ else if (strcmp("dq", sc) == 0)
+ mac->append('"');
+ else if (strcmp("ga", sc) == 0)
+ mac->append('`');
+ else if (strcmp("ha", sc) == 0)
+ mac->append('^');
+ else if (strcmp("rs", sc) == 0)
+ mac->append('\\');
+ else if (strcmp("ti", sc) == 0)
+ mac->append('^');
+ else
+ error("special character '%1' cannot be used within \\X", sc);
+ }
else if (!(tok.is_hyphen_indicator()
|| tok.is_dummy()
|| tok.is_transparent_dummy()
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 02/04: [troff]: Enable ASCII in device control escapes.,
G. Branden Robinson <=