gbranden pushed a commit to branch master
in repository groff.
commit d99412de634f69288bfd3a89757336c141d8baec
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon Nov 17 21:36:23 2025 -0600
[hpftodit,troff]: Fix code style nit.
* src/roff/troff/input.cpp (charinfo::dump):
* src/roff/troff/node.cpp (glyph_node::asciify):
* src/utils/hpftodit/hpftodit.cpp (unicode_to_ucode_name): Make the
compiler do the work of computing sufficiently large static buffer
sizes (for C strings), and so doing express the maximal expected
output to that buffer.
---
ChangeLog | 11 +++++++++++
src/roff/troff/input.cpp | 2 +-
src/roff/troff/node.cpp | 2 +-
src/utils/hpftodit/hpftodit.cpp | 2 +-
4 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 646489347..9088ff3ce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2025-11-17 G. Branden Robinson <[email protected]>
+
+ [hpftodit,troff]: Fix code style nit.
+
+ * src/roff/troff/input.cpp (charinfo::dump):
+ * src/roff/troff/node.cpp (glyph_node::asciify):
+ * src/utils/hpftodit/hpftodit.cpp (unicode_to_ucode_name): Make
+ the compiler do the work of computing sufficiently large static
+ buffer sizes (for C strings), and so doing express the maximal
+ expected output to that buffer.
+
2025-11-14 G. Branden Robinson <[email protected]>
* Makefile.am: Include "contrib/install-font/install-font.am".
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 8e6ef1285..342260bdf 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -10769,7 +10769,7 @@ void charinfo::dump()
// Also see node.cpp::glyph_node::asciify().
int mapping = get_unicode_mapping();
if (mapping >= 0) {
- const size_t buflen = 6; // enough for five hex digits + '\0'
+ const size_t buflen = sizeof "10FFFF";
char hexbuf[buflen];
(void) memset(hexbuf, '\0', buflen);
(void) snprintf(hexbuf, buflen, "%.4X", mapping);
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index fa053a7e4..a46da10d2 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -3935,7 +3935,7 @@ void glyph_node::asciify(macro *m)
break;
default:
m->append_str("\\[u");
- const size_t buflen = 6; // five hex digits + '\0'
+ const size_t buflen = sizeof "10FFFF";
char hexbuf[buflen];
(void) memset(hexbuf, '\0', buflen);
(void) snprintf(hexbuf, buflen, "%.4X", unicode_mapping);
diff --git a/src/utils/hpftodit/hpftodit.cpp b/src/utils/hpftodit/hpftodit.cpp
index b29a04dc3..35986ee92 100644
--- a/src/utils/hpftodit/hpftodit.cpp
+++ b/src/utils/hpftodit/hpftodit.cpp
@@ -1322,7 +1322,7 @@ unicode_to_ucode_name(int ucode)
// A 64-bit signed int produces up to 16 hexadecimal digits.
assert(sizeof(int) <= 8);
const char *ustr;
- char codestr[17]; // 16 hex digits + \0
+ char codestr[sizeof "AAAABBBBCCCCDDDD"];
// don't allow PUA code points as Unicode names
if (ucode >= 0xE000 && ucode <= 0xF8FF)
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit