groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 04/27: src/preproc/html/pre-html.cpp: Refactor (3/11).


From: G. Branden Robinson
Subject: [groff] 04/27: src/preproc/html/pre-html.cpp: Refactor (3/11).
Date: Sat, 2 Jul 2022 00:43:11 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit cb2c60fd9122c8d8def421dadd70cc5035ee08b5
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Mon Jun 27 15:53:49 2022 -0500

    src/preproc/html/pre-html.cpp: Refactor (3/11).
    
    * src/preproc/html/pre-html.cpp (makeTempFiles): Demote return type from
      `int` to `void`.  Stop returning after calling functions that don't
      return.
    
      (makeTempFiles): Boolify.  Use idiomatic C++98 null pointer constant.
      Annotate it as null pointer to ease any future migration to ISO C++11.
      Reorder null pointer equality comparisons to avoid inadvertent lvalue
      assignment.
---
 ChangeLog                     | 19 ++++++++++-------
 src/preproc/html/pre-html.cpp | 48 +++++++++++++++----------------------------
 2 files changed, 28 insertions(+), 39 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 55680f77..1858a5b7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,13 +2,18 @@
 
        * src/preproc/html/pre-html.cpp: Refactor.  Drop unnecessary
        prototype for static function.
-       (char_buffer::read_file): Demote return type from `int` to
-       `void`.  Stop returning after calling functions that don't
-       return.  Call `sys_fatal()` if `fread()` returns an error,
-       similarly to other calls into the standard C library that this
-       file makes.  Improve check for error from `fread()` by not
-       regarding a return value of zero when the end-of-file indicator
-       is set as an error condition.
+       (char_buffer::read_file, makeTempFiles): Demote return type from
+       `int` to `void`.  Stop returning after calling functions that
+       don't return.
+       (char_buffer::read_file): Call `sys_fatal()` if `fread()`
+       returns an error, similarly to other calls into the standard C
+       library that this file makes.  Improve check for error from
+       `fread()` by not regarding a return value of zero when the
+       end-of-file indicator is set as an error condition.
+       (makeTempFiles): Boolify.  Use idiomatic C++98 null pointer
+       constant.  Annotate it as null pointer to ease any future
+       migration to ISO C++11.  Reorder null pointer equality
+       comparisons to avoid inadvertent lvalue assignment.
        (do_file): Drop conditional with empty consequent.
 
 2022-06-27  G. Branden Robinson <g.branden.robinson@gmail.com>
diff --git a/src/preproc/html/pre-html.cpp b/src/preproc/html/pre-html.cpp
index 51713b64..e6a83ce7 100644
--- a/src/preproc/html/pre-html.cpp
+++ b/src/preproc/html/pre-html.cpp
@@ -1747,7 +1747,7 @@ static int scanArguments(int argc, char **argv)
  *  makeTempFiles - Name the temporary files.
  */
 
-static int makeTempFiles(void)
+static void makeTempFiles(void)
 {
 #if defined(DEBUGGING)
   psFileName = DEBUG_FILE("prehtml-ps");
@@ -1759,48 +1759,33 @@ static int makeTempFiles(void)
 #else /* not DEBUGGING */
   FILE *f;
 
-  /* psPageName contains a single page of postscript */
-  f = xtmpfile(&psPageName,
-              PS_TEMPLATE_LONG, PS_TEMPLATE_SHORT,
-              TRUE);
-  if (f == NULL) {
+  // psPageName contains a single page of PostScript.
+  f = xtmpfile(&psPageName, PS_TEMPLATE_LONG, PS_TEMPLATE_SHORT, true);
+  if (0 /* nullptr */ == f)
     sys_fatal("xtmpfile");
-    return -1;
-  }
   fclose(f);
 
-  /* imagePageName contains a bitmap image of the single postscript page */
-  f = xtmpfile(&imagePageName,
-              PAGE_TEMPLATE_LONG, PAGE_TEMPLATE_SHORT,
-              TRUE);
-  if (f == NULL) {
+  // imagePageName contains a bitmap image of a single PostScript page.
+  f = xtmpfile(&imagePageName, PAGE_TEMPLATE_LONG, PAGE_TEMPLATE_SHORT,
+              true);
+  if (0 /* nullptr */ == f)
     sys_fatal("xtmpfile");
-    return -1;
-  }
   fclose(f);
 
-  /* psFileName contains a postscript file of the complete document */
-  f = xtmpfile(&psFileName,
-              PS_TEMPLATE_LONG, PS_TEMPLATE_SHORT,
-              TRUE);
-  if (f == NULL) {
+  // psFileName contains a PostScript file of the complete document.
+  f = xtmpfile(&psFileName, PS_TEMPLATE_LONG, PS_TEMPLATE_SHORT, true);
+  if (0 /* nullptr */ == f)
     sys_fatal("xtmpfile");
-    return -1;
-  }
   fclose(f);
 
-  /* regionFileName contains a list of the images and their boxed coordinates 
*/
+  // regionFileName contains a list of the images and their boxed
+  // coordinates.
   f = xtmpfile(&regionFileName,
-              REGION_TEMPLATE_LONG, REGION_TEMPLATE_SHORT,
-              TRUE);
-  if (f == NULL) {
+              REGION_TEMPLATE_LONG, REGION_TEMPLATE_SHORT, true);
+  if (0 /* nullptr */ == f)
     sys_fatal("xtmpfile");
-    return -1;
-  }
   fclose(f);
-
 #endif /* not DEBUGGING */
-  return 0;
 }
 
 static int do_file(const char *filename)
@@ -1869,8 +1854,7 @@ int main(int argc, char **argv)
 
   if (!found)
     do_file("-");
-  if (makeTempFiles())
-    return 1;
+  makeTempFiles();
   int wstatus = inputFile.do_image(argc, argv);
   if (wstatus == 0) {
     generateImages(regionFileName);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]