From 984dcc37f2e821e20f747d387f1e9d6a2a31f448 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 28 Jun 2025 15:04:30 -0700 Subject: [PATCH] od: check sign bit more often * src/od.c (read_char, dump_strings, main): Instead of testing for an exact negative number, just look at the sign bit. This is a very minor tweak. --- src/od.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/od.c b/src/od.c index 847eb6d743..6d9c5d0697 100644 --- a/src/od.c +++ b/src/od.c @@ -1314,15 +1314,9 @@ read_char (int *c) *c = EOF; - while (in_stream != nullptr) /* EOF. */ + while (in_stream && (*c = fgetc (in_stream)) < 0) { - *c = fgetc (in_stream); - - if (*c != EOF) - break; - ok &= check_and_close (errno); - ok &= open_next_file (); } @@ -1568,7 +1562,7 @@ dump_strings (void) } } - if (c == -1 || i - !c < string_min) + if (c < 0 || i - !c < string_min) continue; buf[i] = 0; @@ -2009,7 +2003,7 @@ main (int argc, char **argv) cleanup: - if (have_read_stdin && fclose (stdin) == EOF) + if (have_read_stdin && fclose (stdin) < 0) error (EXIT_FAILURE, errno, _("standard input")); return ok ? EXIT_SUCCESS : EXIT_FAILURE; -- 2.47.2