gbranden pushed a commit to branch master
in repository groff.

commit fcf3505a097e9e22fe2d31216a4886b0b9d0d4e5
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Nov 19 19:46:57 2025 -0600

    [troff]: Slightly refactor.
    
    * src/roff/troff/input.cpp (token::description): Use different technique
      (with `static` `const` character literals) to construct computed
      string describing a special character or character class token.  See
      `assign_escape_character()` for a similar pattern.
---
 ChangeLog                |  8 ++++++++
 src/roff/troff/input.cpp | 13 +++++++------
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3f755c2e6..d92dc26bf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2025-11-19  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/input.cpp (token::description): Slightly
+       refactor.  Use different technique (with `static` `const`
+       character literals) to construct computed string describing a
+       special character or character class token.  See
+       `assign_escape_character()` for a similar pattern.
+
 2025-11-19  G. Branden Robinson <[email protected]>
 
        [troff]: Trivially refactor.  Rename `get_char()` member
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index de1944cb7..ff4e471f9 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -2922,12 +2922,13 @@ const char *token::description()
       // character or character class names.  Do something about that.
       // (The truncation is visually indicated by the absence of a
       // closing quotation mark.)
-      if (tok.get_charinfo()->is_class())
-       (void) snprintf(buf, maxstr, "character class %c%s%c", qc, sc,
-                       qc);
-      else
-       (void) snprintf(buf, maxstr, "special character %c%s%c", qc, sc,
-                       qc);
+      static const char special_character[] = "special character";
+      static const char character_class[] = "character class";
+      const char *ctype = special_character;
+      charinfo *ci = get_charinfo();
+      if ((ci != 0 /* nullptr */) && ci->is_class())
+       ctype = character_class;
+      (void) snprintf(buf, maxstr, "%s %c%s%c", ctype, qc, sc, qc);
       return buf;
     }
   case TOKEN_SPREAD:

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

Reply via email to