gbranden pushed a commit to branch master
in repository groff.

commit 437c81577ea9cfba5ce81958d82370f21921fc27
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Nov 27 02:22:18 2025 -0600

    [troff]: Modestly refactor (2/8).
    
    * src/roff/troff/reg.cpp (assign_register_format_request):
      Construct integer from character literal.  Store return value of
      `tok.ch()` in local variable of `int`, not `char`, type.
---
 ChangeLog              |  8 ++++++--
 src/roff/troff/reg.cpp | 10 +++++-----
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 077553c9d..1f3bcbba2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,8 +8,12 @@
        lay foundation for future migration of GNU troff's internal
        character type to a custom, wider type.
 
-       * src/roff/troff/div.cpp (return_request): Construct integer
-       from character literal.
+       * src/roff/troff/div.cpp (return_request):
+       * src/roff/troff/reg.cpp (assign_register_format_request):
+       Construct integer from character literal.
+       * src/roff/troff/reg.cpp (assign_register_format_request):
+       Store return value of `tok.ch()` in local variable of `int`, not
+       `char`, type.
 
 2025-11-27  G. Branden Robinson <[email protected]>
 
diff --git a/src/roff/troff/reg.cpp b/src/roff/troff/reg.cpp
index c1ae3a371..de010981a 100644
--- a/src/roff/troff/reg.cpp
+++ b/src/roff/troff/reg.cpp
@@ -447,7 +447,7 @@ static void assign_register_format_request()
     register_dictionary.define(nm, r);
   }
   tok.skip_spaces();
-  char c = tok.ch();
+  int c = tok.ch(); // safely compares to char literals; TODO: grochar
   if (csdigit(c)) {
     int n = 0;
     do {
@@ -456,10 +456,10 @@ static void assign_register_format_request()
     } while (csdigit(tok.ch()));
     r->alter_format('1', n);
   }
-  else if ((c == 'i')
-          || (c == 'I')
-          || (c == 'a')
-          || (c == 'A'))
+  else if ((c == int('i'))
+          || (c == int('I'))
+          || (c == int('a'))
+          || (c == int('A'))) // TODO: grochar * 4
     r->alter_format(c);
   else if (!has_arg())
     warning(WARN_MISSING, "register interpolation format assignment"

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

Reply via email to