[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 05/27: src/preproc/html/pre-html.cpp: Refactor (4/11).
From: |
G. Branden Robinson |
Subject: |
[groff] 05/27: src/preproc/html/pre-html.cpp: Refactor (4/11). |
Date: |
Sat, 2 Jul 2022 00:43:11 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 777ca172e4bbec002707d849a75039ad1d3474c8
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Mon Jun 27 18:44:30 2022 -0500
src/preproc/html/pre-html.cpp: Refactor (4/11).
* src/preproc/html/pre-html.cpp (do_file): Boolify. Demote return type
from `int` to `bool`. Return Boolean literals. 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 | 9 +++++----
src/preproc/html/pre-html.cpp | 12 ++++++------
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 1858a5b7..54610ec9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,11 +10,12 @@
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
+ (makeTempFiles, do_file): 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.
+ (do_file): Demote return type from `int` to `bool`. Return
+ Boolean literals. 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 e6a83ce7..3e3f13b6 100644
--- a/src/preproc/html/pre-html.cpp
+++ b/src/preproc/html/pre-html.cpp
@@ -1788,7 +1788,7 @@ static void makeTempFiles(void)
#endif /* not DEBUGGING */
}
-static int do_file(const char *filename)
+static bool do_file(const char *filename)
{
FILE *fp;
@@ -1797,16 +1797,16 @@ static int do_file(const char *filename)
fp = stdin;
else {
fp = fopen(filename, "r");
- if (fp == 0) {
- error("can't open '%1': %2", filename, strerror(errno));
- return 0;
+ if (0 /* nullptr*/ == fp) {
+ error("unable to open '%1': %2", filename, strerror(errno));
+ return false;
}
}
inputFile.read_file(fp);
if (fp != stdin)
fclose(fp);
- current_filename = NULL;
- return 1;
+ current_filename = 0 /* nullptr */;
+ return true;
}
int main(int argc, char **argv)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 05/27: src/preproc/html/pre-html.cpp: Refactor (4/11).,
G. Branden Robinson <=