gbranden pushed a commit to branch master
in repository groff.

commit 2cb52c596c5bdaf4406d70a20378dd7bb70e7596
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Sep 26 23:48:30 2024 -0500

    [troff]: Fix code style nits.
    
    * src/roff/troff/input.cpp (do_write_request): Fix code style nits.
      Restyle loops to more closely resemble similar logic in this file.
      Reorder equality comparisons to avoid inadvertent lvalue assignment.
    
    Also annotate null pointers with `nullptr` comment to ease any future
    transition to C++11, which defines it as a keyword.
---
 ChangeLog                |  7 +++++++
 src/roff/troff/input.cpp | 14 ++++++++------
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e9c8ea137..ef6caac18 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-09-26  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/input.cpp (do_write_request): Fix code style
+       nits.  Restyle loops to more closely resemble similar logic in
+       this file.  Reorder equality comparisons to avoid inadvertent
+       lvalue assignment.
+
 2024-09-26  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/input.cpp (do_write_request): Check for a
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index d24cfb5a9..f61b3c25f 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -7510,13 +7510,15 @@ void do_write_request(int newline)
     return;
   }
   if (!tok.is_newline() && !tok.is_eof()) {
-    int c;
-    while ((c = get_copy(0)) == ' ')
-      ;
-    if (c == '"')
-      c = get_copy(0);
-    for (; c != '\n' && c != EOF; c = get_copy(0))
+    int c = get_copy(0 /* nullptr */);
+    while (' ' == c)
+      c = get_copy(0 /* nullptr */);
+    if ('"' == c)
+      c = get_copy(0 /* nullptr */);
+    while (c != '\n' && c != EOF) {
       fputs(asciify(c), fp);
+      c = get_copy(0 /* nullptr */);
+    }
   }
   if (newline)
     fputc('\n', fp);

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

Reply via email to