gbranden pushed a commit to branch master
in repository groff.

commit f1e2cd424f0265c9c10e1a8ff2cd1e140cbe2994
Author: G. Branden Robinson <g.branden.robin...@gmail.com>
AuthorDate: Thu Jul 10 16:31:03 2025 -0500

    [pre-grohtml]: Fix code style nits.
    
    * src/preproc/html/pre-html.cpp (get_line): Boolify: demote return type
      from `int` to `bool`, and return Boolean rather than integer literals.
      Mark as `static` since this function requires no external linkage.
      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                     |  8 ++++++++
 src/preproc/html/pre-html.cpp | 18 +++++++++---------
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6c993709f..4e61f4daf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2025-07-10  G. Branden Robinson <g.branden.robin...@gmail.com>
+
+       * src/preproc/html/pre-html.cpp (get_line): Fix code style nits.
+       Boolify: demote return type from `int` to `bool`, and return
+       Boolean rather than integer literals.  Mark as `static` since
+       this function requires no external linkage.  Reorder equality
+       comparisons to avoid inadvertent lvalue assignment.
+
 2025-07-10  G. Branden Robinson <g.branden.robin...@gmail.com>
 
        [libgroff, eqn, pic, refer, soelim, tbl]: Trivially
diff --git a/src/preproc/html/pre-html.cpp b/src/preproc/html/pre-html.cpp
index cace7ba09..535fb386f 100644
--- a/src/preproc/html/pre-html.cpp
+++ b/src/preproc/html/pre-html.cpp
@@ -262,11 +262,11 @@ void sys_fatal(const char *s)
  *             global line buffer.
  */
 
-int get_line(FILE *f)
+static bool get_line(FILE *f)
 {
-  if (f == 0)
-    return 0;
-  if (linebuf == 0) {
+  if (0 /* nullptr */ == f)
+    return false;
+  if (0 /* nullptr */ == linebuf) {
     linebuf = new char[128];
     linebufsize = 128;
   }
@@ -274,8 +274,8 @@ int get_line(FILE *f)
   // skip leading whitespace
   for (;;) {
     int c = getc(f);
-    if (c == EOF)
-      return 0;
+    if (EOF == c)
+      return false;
     if (c != ' ' && c != '\t') {
       ungetc(c, f);
       break;
@@ -283,7 +283,7 @@ int get_line(FILE *f)
   }
   for (;;) {
     int c = getc(f);
-    if (c == EOF)
+    if (EOF == c)
       break;
     if (i + 1 >= linebufsize) {
       char *old_linebuf = linebuf;
@@ -293,13 +293,13 @@ int get_line(FILE *f)
       linebufsize *= 2;
     }
     linebuf[i++] = c;
-    if (c == '\n') {
+    if ('\n' == c) {
       i--;
       break;
     }
   }
   linebuf[i] = '\0';
-  return 1;
+  return true;
 }
 
 /*

_______________________________________________
groff-commit mailing list
groff-commit@gnu.org
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to