gbranden pushed a commit to branch master
in repository groff.
commit b94556366fd81daec2e878f9131d32daac9315d1
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon May 25 02:31:26 2026 -0500
[tfmtodit]: Fix code style nits. (4/6)
* src/utils/tfmtodit/tfmtodit.cpp (main): Consistently use exit(3) to
return from `main()` instead of `return`. Simplify an
`error()`+`return` combination to a `fatal()` call.
---
ChangeLog | 3 +++
src/utils/tfmtodit/tfmtodit.cpp | 16 +++++++---------
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ab950b580..753a2b892 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,9 @@
compare variables of pointer type to null pointer literal
instead of letting them pun down to Booleans. Arrange equality
comparisons to avoid inadvertent lvalue assignment.
+ (main): Consistently use exit(3) to return from `main()` instead
+ of `return`. Simplify an `error()`+`return` combination to a
+ `fatal()` call.
2026-05-25 G. Branden Robinson <[email protected]>
diff --git a/src/utils/tfmtodit/tfmtodit.cpp b/src/utils/tfmtodit/tfmtodit.cpp
index 2594b3165..d4fbeea19 100644
--- a/src/utils/tfmtodit/tfmtodit.cpp
+++ b/src/utils/tfmtodit/tfmtodit.cpp
@@ -55,7 +55,7 @@ both be zero. */
#include <errno.h>
#include <math.h> // atan2()
#include <stdcountof.h>
-#include <stdlib.h> // exit(), EXIT_SUCCESS, strtol()
+#include <stdlib.h> // exit(), EXIT_FAILURE, EXIT_SUCCESS, strtol()
#include <getopt.h> // getopt_long()
@@ -765,23 +765,21 @@ int main(int argc, char **argv)
gf g;
if (gf_file) {
if (!g.load(gf_file))
- return 1;
+ exit(EXIT_FAILURE);
}
const char *tfm_file = argv[optind];
const char *map_file = argv[optind + 1];
const char *font_file = argv[optind + 2];
tfm t;
if (!t.load(tfm_file))
- return 1;
+ exit(EXIT_FAILURE);
char_list *table[256];
if (!read_map(map_file, table))
- return 1;
+ exit(EXIT_FAILURE);
errno = 0;
- if (!freopen(font_file, "w", stdout)) {
- error("cannot open '%1' for writing: %2", font_file,
+ if (!freopen(font_file, "w", stdout))
+ fatal("cannot open '%1' for writing: %2", font_file,
strerror(errno));
- return 1;
- }
printf("name %s\n", font_file);
if (special_flag)
fputs("special\n", stdout);
@@ -894,7 +892,7 @@ int main(int argc, char **argv)
for (p = p->next; p != 0 /* nullptr */; p = p->next)
printf("%s\t\"\n", p->ch);
}
- return 0;
+ exit(EXIT_SUCCESS);
}
static void usage(FILE *stream)
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit