gbranden pushed a commit to branch master
in repository groff.

commit 3e4526d6f89abd759e4a65529ec1a9d7b5303c03
Author: G. Branden Robinson <[email protected]>
AuthorDate: Tue Jun 23 18:50:37 2026 -0500

    src/preproc/eqn/lex.cpp: Fix code style nits.
    
    * src/preproc/eqn/lex.cpp (interpolate_macro_with_args): Parenthesize
      formally complex expressions.  Arrange equality comparisons to avoid
      inadvertent assignment to lvalue.
---
 ChangeLog               |  7 +++++++
 src/preproc/eqn/lex.cpp | 14 +++++++-------
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6b4336c28..79defba90 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2026-06-23  G. Branden Robinson <[email protected]>
+
+       * src/preproc/eqn/lex.cpp (interpolate_macro_with_args): Fix
+       code style nits.  Parenthesize formally complex expressions.
+       Arrange equality comparisons to avoid inadvertent assignment to
+       lvalue.
+
 2026-06-23  G. Branden Robinson <[email protected]>
 
        * src/preproc/eqn/lex.cpp (interpolate_macro_with_args): Declare
diff --git a/src/preproc/eqn/lex.cpp b/src/preproc/eqn/lex.cpp
index 91f76e4fa..f6a1f23ac 100644
--- a/src/preproc/eqn/lex.cpp
+++ b/src/preproc/eqn/lex.cpp
@@ -758,7 +758,7 @@ static void interpolate_macro_with_args(const char *body)
   int argc = 0;
   int i;
   for (i = 0; i < 9; i++)
-    argv[i] = 0;
+    argv[i] = 0 /* nullptr */;
   int level = 0;
   int c;
   bool is_ignoring_arguments = false;
@@ -766,11 +766,11 @@ static void interpolate_macro_with_args(const char *body)
     token_buffer.clear();
     for (;;) {
       c = get_char();
-      if (c == EOF) {
+      if (EOF == c) {
        lex_error("end of input while scanning macro arguments");
        break;
       }
-      if (level == 0 && (c == ',' || c == ')')) {
+      if ((0 == level) && ((',' == c) || (')' == c))) {
        if (argc >= 9) {
          if (!is_ignoring_arguments) { // if we didn't already warn
            lex_warning("excess macro argument(s); ignoring");
@@ -783,17 +783,17 @@ static void interpolate_macro_with_args(const char *body)
          argv[argc] = strsave(token_buffer.contents());
        }
        // for 'foo()', argc = 0
-       if (argc > 0 || c != ')' || i > 0)
+       if ((argc > 0) || (c != ')') || (i > 0))
          argc++;
        break;
       }
       token_buffer += char(c);
-      if (c == '(')
+      if ('(' == c)
        level++;
-      else if (c == ')')
+      else if (')' == c)
        level--;
     }
-  } while (c != ')' && c != EOF);
+  } while ((c != ')') && (c != EOF));
   current_input = new argument_macro_input(body, argc, argv,
                                           current_input);
 }

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

Reply via email to