gbranden pushed a commit to branch master
in repository groff.

commit abcfb1d0a969f9fa5cfba02259a124b7e92cd431
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Jun 24 21:12:33 2026 -0500

    src/roff/troff/input.cpp: Slightly refactor.
    
    * src/roff/troff/input.cpp (map_special_character_for_device_output):
      Drop confusing local variable `unibufsz` (which differs from a
      libgroff symbol only in lettercase) in favor of `UNIBUFSZ + 1`
      expression and (subsequently) `sizeof character`, which can both be
      computed at compile time.
---
 ChangeLog                |  9 +++++++++
 src/roff/troff/input.cpp | 10 +++++-----
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e3d80c9c5..1d1abd009 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2026-06-24  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/input.cpp
+       (map_special_character_for_device_output): Slightly refactor.
+       Drop confusing local variable `unibufsz` (which differs from a
+       libgroff symbol only in lettercase) in favor of `UNIBUFSZ + 1`
+       expression and (subsequently) `sizeof character`, which can both
+       be computed at compile time.
+
 2026-06-24  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/dictionary.cpp: Preprocessor-include "errarg.h"
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index fe6bb7918..921c3c89a 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -6819,9 +6819,9 @@ static void map_special_character_for_device_output(macro 
*mac,
     else {
       char errbuf[ERRBUFSZ]; // C++03: char errbuf[ERRBUFSZ]()
       (void) memset(errbuf, '\0', ERRBUFSZ);
-      const size_t unibufsz = UNIBUFSZ + 1 /* '\0' */;
-      char character[unibufsz]; // C++03: char errbuf[ERRBUFSZ]()
-      (void) memset(character, '\0', UNIBUFSZ);
+      // C++03: char character[UNIBUFSZ + 1]()
+      char character[UNIBUFSZ + 1];
+      (void) memset(character, '\0', sizeof character);
       // If it looks like something other than an attempt at a Unicode
       // special character escape sequence already, try to convert it
       // into one.  Output drivers don't (and shouldn't) know anything
@@ -6829,7 +6829,7 @@ static void map_special_character_for_device_output(macro 
*mac,
       if ((strlen(sc) < 3) || (sc[0] != 'u')) {
        const char *un = glyph_name_to_unicode(sc);
        if (un != 0 /* nullptr */)
-         strncpy(character, un, unibufsz);
+         strncpy(character, un, sizeof character);
        else {
          warning(WARN_CHAR, "special character '%1' is not encodable"
               " in device-independent output", sc);
@@ -6843,7 +6843,7 @@ static void map_special_character_for_device_output(macro 
*mac,
               " in device-independent output: %2", sc, errbuf);
          return;
        }
-       strncpy(character, un, unibufsz);
+       strncpy(character, un, sizeof character);
       }
       mac->append_str("\\[u");
       mac->append_str(character);

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

Reply via email to