[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 12/12: [troff]: Fix Savannah #64484.
From: |
G. Branden Robinson |
Subject: |
[groff] 12/12: [troff]: Fix Savannah #64484. |
Date: |
Tue, 19 Nov 2024 20:33:13 -0500 (EST) |
gbranden pushed a commit to branch master
in repository groff.
commit cba317296a9e835e44a3792b52232dce81d53407
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Tue Nov 19 18:55:54 2024 -0600
[troff]: Fix Savannah #64484.
This change restores groff 1.23.0's handling of characters in `device`
request arguments, except that {1} special character escape sequences
are interpreted (except for composite special characters, a planned
future development) and {2} unprintable character codes such as ASCII 2
are no longer emitted in GNU troff output by this means.
* src/roff/troff/input.cpp (device_request): Refactor and revise
argument interpretation. Reconstitute an encoded unbreakable space
code point as its escape sequence (spelled with the default escape
character). Throw warning in category "syntax" if a valid but
unprintable input character is encountered. Throw warning in category
"syntax" if an escape sequence other than `\[` is encountered. (A
reconstituted `\~` is not warned about.)
* src/roff/troff/troff.1.man (Warnings): Document additional
circumstances under which warnings in "syntax" category are thrown.
Fixes <https://savannah.gnu.org/bugs/?64484>.
---
ChangeLog | 23 +++++++++++++++++++++++
src/roff/troff/input.cpp | 38 ++++++++++++++++++++++++++++++++------
src/roff/troff/troff.1.man | 3 +++
3 files changed, 58 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3bb59a237..03df62bba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2024-11-19 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ [troff]: Fix Savannah #64484. This change restores groff
+ 1.23.0's handling of characters in `device` request arguments,
+ except that {1} special character escape sequences are
+ interpreted (except for composite special characters, a planned
+ future development) and {2} unprintable character codes such as
+ ASCII 2 are no longer emitted in GNU troff output by this means.
+
+ * src/roff/troff/input.cpp (device_request): Refactor and revise
+ argument interpretation. Reconstitute an encoded unbreakable
+ space code point as its escape sequence (spelled with the
+ default escape character). Throw warning in category "syntax"
+ if a valid but unprintable input character is encountered.
+ Throw warning in category "syntax" if an escape sequence other
+ than `\[` is encountered. (A reconstituted `\~` is not warned
+ about.)
+ * src/roff/troff/troff.1.man (Warnings): Document additional
+ circumstances under which warnings in "syntax" category are
+ thrown.
+
+ Fixes <https://savannah.gnu.org/bugs/?64484>.
+
2024-11-19 G. Branden Robinson <g.branden.robinson@gmail.com>
[groff]: Regression-test Savannah #64484.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 8fafa8a0a..0aeee3760 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -6013,17 +6013,43 @@ static void device_request()
}
if ((curdiv == topdiv) && (topdiv->before_first_page_status > 0))
topdiv->begin_page();
- // Null characters can correspond to node types like vmotion_node that
- // are unrepresentable in a device extension command, and got scrubbed
- // by `asciify`.
- for (int prevc = c; (c != '\0') && (c != '\n') && (c != EOF);
+ for (;
+ (c != '\0') && (c != '\n') && (c != EOF);
c = get_copy(0 /* nullptr */)) {
- if (!('\\' == c) && (prevc != '\\'))
+ // We may encounter some of the C0 and C1 character codes GNU troff
+ // uses for special purposes; see src/roff/troff/input.h. They
+ // produce nothing in grout. Warn only about the ones that are left
+ // for the user's purposes. Use octal because input.h does. Ignore
+ // 8-bit codes in general. grout is an ISO 646 file format.
+ if (ESCAPE_TILDE == c) {
+ mac.append('\\');
+ mac.append('~');
+ }
+ else if ((c < 015) || (c >= 0177))
+ warning (WARN_SYNTAX, "ignoring character code %1 in device"
+ " extension command request argument", c);
+ else if (c != '\\')
mac.append(c);
else {
int c1 = get_copy(0 /* nullptr */);
- if (c1 != '[')
+ if (c1 != '[') {
+ mac.append(c);
mac.append(c1);
+ string chardesc = "";
+ if (csprint(c1)) {
+ chardesc += "'";
+ chardesc += char(c1);
+ chardesc += "'";
+ }
+ else {
+ chardesc += "character code ";
+ chardesc += i_to_a(c1);
+ }
+ chardesc += '\0'; // make it safe for .contents()
+ warning (WARN_SYNTAX, "not interpreting escaped %1 in device"
+ " extension command request argument",
+ chardesc.contents());
+ }
else {
// Does the input resemble a valid (bracket-form) special
// character escape sequence?
diff --git a/src/roff/troff/troff.1.man b/src/roff/troff/troff.1.man
index 5a633658e..b75028493 100644
--- a/src/roff/troff/troff.1.man
+++ b/src/roff/troff/troff.1.man
@@ -755,6 +755,9 @@ It never occurs in compatibility mode.
A self-contradictory hyphenation mode was requested;
an empty or incomplete numeric expression was encountered;
an operand to a numeric operator was missing;
+a recognized but inapposite escape sequence
+or unprintable character code
+was used in a device extension command request;
an attempt was made to define a recursive,
empty,
or nonsensical character class;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 12/12: [troff]: Fix Savannah #64484.,
G. Branden Robinson <=