gbranden pushed a commit to branch master
in repository groff.

commit 7fbd43686da3c386e1eada467f8d90d6862c77c6
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Apr 8 18:41:40 2026 -0500

    src/roff/troff/number.cpp: Refactor.
    
    * src/roff/troff/number.cpp: Migrate `valid_scaling_units` global
      constant from type array-of-`char` to a groff `string`.
    
      (is_valid_term): Employ `contains()` function of
      `valid_scaling_units`'s new type instead of the standard C library's
      strchr(3).
    
    Continues the long process of fixing Savannah #67735.
---
 ChangeLog                 | 11 +++++++++++
 src/roff/troff/number.cpp |  7 +++----
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0f96173ba..a4c107d19 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2026-04-08  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/number.cpp: Refactor.  Migrate
+       `valid_scaling_units` global constant from type array-of-`char`
+       to a groff `string`.
+       (is_valid_term): Employ `contains()` function of
+       `valid_scaling_units`'s new type instead of the standard C
+       library's strchr(3).
+
+       Continues the long process of fixing Savannah #67735.
+
 2026-04-08  G. Branden Robinson <[email protected]>
 
        [libgroff]: Add `contains()` member function to `string` class.
diff --git a/src/roff/troff/number.cpp b/src/roff/troff/number.cpp
index 41f991a13..ac91fce64 100644
--- a/src/roff/troff/number.cpp
+++ b/src/roff/troff/number.cpp
@@ -253,7 +253,7 @@ static bool is_valid_expression_start()
 
 enum { OP_LEQ = 'L', OP_GEQ = 'G', OP_MAX = 'X', OP_MIN = 'N' };
 
-static const char valid_scaling_units[] = "icfPmnpuvMsz";
+static const string valid_scaling_units("icfPmnpuvMsz");
 
 static bool is_valid_term(units *u, int scaling_unit,
                          bool is_parenthesized, bool is_mandatory);
@@ -440,7 +440,7 @@ static bool is_valid_term(units *u, int scaling_unit,
       *u = 0;
       return true;
     }
-    else if ((c != 0) && (strchr(valid_scaling_units, char(c)) != 0)) {
+    else if ((c != 0) && valid_scaling_units.contains(c)) {
       tok.next();
       if (tok.ch() == int(';')) { // TODO: grochar
        tok.next();
@@ -540,8 +540,7 @@ static bool is_valid_term(units *u, int scaling_unit,
   }
   unsigned char si = scaling_unit; // TODO: grochar
   bool do_next = false;
-  if (((c = tok.ch()) != 0)
-      && (strchr(valid_scaling_units, c) != 0 /* nullptr */)) {
+  if (((c = tok.ch()) != 0) && valid_scaling_units.contains(c)) {
     switch (scaling_unit) {
     case int(0): // TODO: grochar; null character, not digit zero
       // We know it's a recognized scaling unit because it matched the

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

Reply via email to