gbranden pushed a commit to branch master
in repository groff.

commit 9700152b56e59c193078091baa0552867616d149
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Nov 27 02:25:38 2025 -0600

    [troff]: Modestly refactor (3/8).
    
    * src/roff/troff/env.cpp: Retype global `TAB_REPEAT_CHAR` from (`const`)
      `char` to `unsigned char`.
    
      (configure_tab_stops_request): Construct integer from character
    literal.
    
      (adjust): Store return value of `tok.ch()` in temporary local variable
      of `int`, not `char`, type.
---
 ChangeLog              |  4 ++++
 src/roff/troff/env.cpp | 11 ++++++-----
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1f3bcbba2..d5cd1bf85 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,10 +10,14 @@
 
        * src/roff/troff/div.cpp (return_request):
        * src/roff/troff/reg.cpp (assign_register_format_request):
+       * src/roff/troff/env.cpp (configure_tab_stops_request):
        Construct integer from character literal.
+       * src/roff/troff/env.cpp (adjust):
        * src/roff/troff/reg.cpp (assign_register_format_request):
        Store return value of `tok.ch()` in local variable of `int`, not
        `char`, type.
+       * src/roff/troff/env.cpp: Retype global `TAB_REPEAT_CHAR` from
+       {`const`} `char` to `unsigned char`.
 
 2025-11-27  G. Branden Robinson <[email protected]>
 
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index b47543adc..e1fdcc93a 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -2735,7 +2735,8 @@ void adjust()
 {
   curenv->adjust_mode |= 1;
   if (has_arg()) {
-    switch (tok.ch()) {
+    int c = tok.ch(); // safely compares to char literals; TODO: grochar
+    switch (c) {
     case 'l':
       curenv->adjust_mode = ADJUST_LEFT;
       break;
@@ -2806,7 +2807,7 @@ void input_trap_continued()
 /* tabs */
 
 // must not be R or C or L or a legitimate part of a number expression
-const char TAB_REPEAT_CHAR = 'T';
+const unsigned char TAB_REPEAT_CHAR = 'T';
 
 struct tab {
   tab *next;
@@ -3017,15 +3018,15 @@ static void configure_tab_stops_request()
     if (!get_hunits(&pos, 'm', prev_pos))
       break;
     tab_type type = TAB_LEFT;
-    if (tok.ch() == 'C') {
+    if (tok.ch() == int('C')) { // TODO: grochar
       tok.next();
       type = TAB_CENTER;
     }
-    else if (tok.ch() == 'R') {
+    else if (tok.ch() == int('R')) { // TODO: grochar
       tok.next();
       type = TAB_RIGHT;
     }
-    else if (tok.ch() == 'L') {
+    else if (tok.ch() == int('L')) { // TODO: grochar
       tok.next();
     }
     if (pos <= prev_pos && ((!is_first_stop) || is_repeating_stop))

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

Reply via email to