[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 87/105: [troff]: Don't quote a character with itself.
From: |
G. Branden Robinson |
Subject: |
[groff] 87/105: [troff]: Don't quote a character with itself. |
Date: |
Mon, 22 May 2023 03:39:12 -0400 (EDT) |
gbranden pushed a commit to branch branden-2023-05-22
in repository groff.
commit bf2b364b50f28a1904f67ebfe93eec0430a2897f
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sun May 7 00:26:11 2023 -0500
[troff]: Don't quote a character with itself.
...in diagnostics.
* src/roff/troff/input.cpp (token::description, input_char_description):
When quoting the ' character in diagnostics, use double-quotes, not
apostrophes.
Also swap order of a comparison to avoid inadvertent lvalue assignment.
---
ChangeLog | 8 ++++++++
src/roff/troff/input.cpp | 19 +++++++++++++++----
2 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 7c63b172a..d958ae137 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-05-07 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ [troff]: Don't quote a character with itself in diagnostics.
+
+ * src/roff/troff/input.cpp (token::description)
+ (input_char_description): When quoting the ' character in
+ diagnostics, use double-quotes, not apostrophes.
+
2023-05-06 G. Branden Robinson <g.branden.robinson@gmail.com>
[troff]: Trivially refactor.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index adfbf0bef..9f5759c04 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -2404,8 +2404,12 @@ const char *token::description()
case TOKEN_BACKSPACE:
return "a backspace character";
case TOKEN_CHAR:
- if (c == INPUT_DELETE)
+ if (INPUT_DELETE == c)
return "a delete character";
+ else if ('\'' == c) {
+ (void) snprintf(buf, bufsz, "character \"%c\"", c);
+ return buf;
+ }
else {
(void) snprintf(buf, bufsz, "character '%c'", c);
return buf;
@@ -6682,9 +6686,16 @@ const char *input_char_description(int c)
return buf;
}
if (csprint(c)) {
- buf[0] = '\'';
- buf[1] = c;
- buf[2] = '\'';
+ if ('\'' == c) {
+ buf[0] = '"';
+ buf[1] = c;
+ buf[2] = '"';
+ }
+ else {
+ buf[0] = '\'';
+ buf[1] = c;
+ buf[2] = '\'';
+ }
return buf;
}
sprintf(buf, "character code %d", c);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 87/105: [troff]: Don't quote a character with itself.,
G. Branden Robinson <=