gbranden pushed a commit to branch master
in repository groff.

commit 3fea676b03b0ae008dbba12d5047bcc75d0b27e3
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Nov 30 04:37:36 2025 -0600

    [troff]: Fix syntax warning diagnostic regression.
    
    ...introduced in recent days' commits.  Now that we're scrupulous about
    the data type of an input character to GNU troff, our diagnostic
    apparatus takes us at our word when we pass it unsigned chars, and it
    formats them as decimal integers instead of characters.  Use value
    constructors to pass C++ `char`s where appropriate.
    
    * src/roff/troff/input.cpp (is_conditional_expression_true):
    * src/roff/troff/number.cpp (is_valid_term): Do it.
---
 ChangeLog                 | 12 ++++++++++++
 src/roff/troff/input.cpp  |  2 +-
 src/roff/troff/number.cpp | 12 ++++++++----
 3 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1c8711e1d..e18aa580e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2025-11-30  G. Branden Robinson <[email protected]>
+
+       [troff]: Fix regression in syntax warning diagnostics introduced
+       in recent days' commits.  Now that we're scrupulous about the
+       data type of an input character to GNU troff, our diagnostic
+       apparatus takes us at our word when we pass it unsigned chars,
+       and it formats them as decimal integers instead of characters.
+       Use value constructors to pass C++ `char`s where appropriate.
+
+       * src/roff/troff/input.cpp (is_conditional_expression_true):
+       * src/roff/troff/number.cpp (is_valid_term): Do it.
+
 2025-11-30  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/input.cpp (read_size): Clarify diagnostic when
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 6a0a86315..cf0743c8b 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -7050,7 +7050,7 @@ static bool is_conditional_expression_true()
       warning(WARN_SYNTAX,
              "conditional expression operator '%1' is not portable to"
              " AT&T troff",
-             c);
+             char(c));
              // TODO: "; treating as output comparison delimiter", c);
       break;
     default:
diff --git a/src/roff/troff/number.cpp b/src/roff/troff/number.cpp
index 16a685f75..4b45c0833 100644
--- a/src/roff/troff/number.cpp
+++ b/src/roff/troff/number.cpp
@@ -498,7 +498,8 @@ static bool is_valid_term(units *u, int scaling_unit,
   case '>':
   case '<':
   case '=':
-    warning(WARN_SYNTAX, "empty left operand to '%1' operator", c);
+    warning(WARN_SYNTAX, "empty left operand to '%1' operator",
+           char(c));
     *u = 0;
     return !is_mandatory;
   default:
@@ -528,12 +529,15 @@ static bool is_valid_term(units *u, int scaling_unit,
       && (strchr(SCALING_UNITS, c) != 0 /* nullptr */)) {
     switch (scaling_unit) {
     case 0:
-      warning(WARN_SCALE, "scaling unit '%1' invalid in context", c);
+      // We know it's a recognized scaling unit because it matched the
+      // `strchr()` above, so we don't use `tok.description()`.
+      warning(WARN_SCALE, "scaling unit not valid in context"
+             " (got '%1')", char(c));
       break;
     case 'f':
       if (c != 'f' && c != 'u') {
        warning(WARN_SCALE, "'%1' scaling unit invalid in context;"
-               " use 'f' or 'u'", c);
+               " use 'f' or 'u'", char(c));
        break;
       }
       si = c;
@@ -541,7 +545,7 @@ static bool is_valid_term(units *u, int scaling_unit,
     case 'z':
       if (c != 'u' && c != 'z' && c != 'p' && c != 's') {
        warning(WARN_SCALE, "'%1' scaling unit invalid in context;"
-               " use 'z', 'p', 's', or 'u'", c);
+               " use 'z', 'p', 's', or 'u'", char(c));
        break;
       }
       si = c;

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to