gbranden pushed a commit to branch master
in repository groff.

commit 23bc178f87da2a09a331abbaa6aecff679a282a7
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Dec 25 22:38:19 2025 -0600

    src/roff/troff/input.cpp: Slightly refactor.
    
    * src/roff/troff/input.cpp (read_input_until_terminator): Introduce
      `const`-qualified local variable to defeat inadvertent lvalue
      assignment.
    
    Also tidy up some comments.
---
 ChangeLog                |  6 ++++++
 src/roff/troff/input.cpp | 10 +++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4ad0501db..3c01a908f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2025-12-25  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/input.cpp (read_input_until_terminator):
+       Slightly refactor.  Introduce `const`-qualified local variable
+       to defeat inadvertent lvalue assignment.
+
 2025-12-25  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/input.cpp (read_input_until_terminator):
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 1a119c273..fc12f7796 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -3212,11 +3212,11 @@ static symbol read_input_until_terminator(bool required,
   }
   (void) memset(buf, 0, (buf_size * sizeof(unsigned char)));
   int i = 0;
+  const unsigned char terminator = end_char; // TODO: grochar
   for (;;) {
-    // If `end_char` != U0 we normally have to append a null byte.
+    // If `terminator` != 0U we normally have to append a null byte.
     if ((i + 2) > buf_size) {
-      // TODO: grochar
-      unsigned char *old_buf = buf;
+      unsigned char *old_buf = buf; // TODO: grochar
       int new_buf_size = buf_size * 2;
       // C++03: new char[new_buf_size]();
       try {
@@ -3231,7 +3231,7 @@ static symbol read_input_until_terminator(bool required,
       delete[] old_buf;
     }
     buf[i] = tok.ch();
-    if ((0U == buf[i]) || (end_char == buf[i]))
+    if ((0U == buf[i]) || (terminator == buf[i]))
       break;
     i++;
     tok.next();
@@ -3241,7 +3241,7 @@ static symbol read_input_until_terminator(bool required,
     delete[] buf;
     return NULL_SYMBOL;
   }
-  if ((end_char != 0U) && (end_char == buf[i]))
+  if ((terminator != 0U) && (terminator == buf[i]))
     buf[i + 1] = '\0';
   else
     diagnose_invalid_identifier();

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

Reply via email to