gbranden pushed a commit to branch master
in repository groff.
commit 202219c790b8ca75c81fefc4161e24c0e034bf15
Author: G. Branden Robinson <[email protected]>
AuthorDate: Tue Nov 4 02:35:10 2025 -0600
[soelim]: Slightly refactor.
* src/preproc/soelim/soelim.cpp (do_file): Mark function as `static`
since it does not require external linkage. Demote return type from
`int` to `bool`; return Boolean rather than integer literals. Reorder
equality comparison to avoid inadvertent lvalue assignment.
---
ChangeLog | 8 ++++++++
src/preproc/soelim/soelim.cpp | 12 ++++++------
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 9d66f44ec..fbddf5251 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2025-11-04 G. Branden Robinson <[email protected]>
+
+ * src/preproc/soelim/soelim.cpp (do_file): Slightly refactor.
+ Mark function as `static` since it does not require external
+ linkage. Demote return type from `int` to `bool`; return
+ Boolean rather than integer literals. Reorder equality
+ comparison to avoid inadvertent lvalue assignment.
+
2025-11-04 G. Branden Robinson <[email protected]>
* src/roff/troff/input.cpp (psbb_locator::psbb_locator): Clarify
diff --git a/src/preproc/soelim/soelim.cpp b/src/preproc/soelim/soelim.cpp
index 311e7c429..5fddd79ee 100644
--- a/src/preproc/soelim/soelim.cpp
+++ b/src/preproc/soelim/soelim.cpp
@@ -45,8 +45,8 @@ bool want_tex_output = false;
extern "C" const char *Version_string;
-int do_file(const char *);
-
+// forward declaration
+static bool do_file(const char *);
void usage(FILE *stream)
{
@@ -186,7 +186,7 @@ void do_so(const char *line)
fputs(line, stdout);
}
-int do_file(const char *filename)
+static bool do_file(const char *filename)
{
char *file_name_in_path = 0;
FILE *fp = include_search_path.open_file_cautiously(filename,
@@ -197,10 +197,10 @@ int do_file(const char *filename)
whole_filename = file_name_in_path;
whole_filename += '\0';
free(file_name_in_path);
- if (fp == 0) {
+ if (0 == fp) {
error("cannot open '%1': %2", whole_filename.contents(),
strerror(err));
- return 0;
+ return false;
}
normalize_file_name_for_lf_request(whole_filename);
current_filename = whole_filename.contents();
@@ -344,7 +344,7 @@ int do_file(const char *filename)
fatal("cannot close '%1': %2", whole_filename.contents(),
strerror(errno));
current_filename = 0 /* nullptr */;
- return 1;
+ return true;
}
// Local Variables:
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit