From ee367bd38daca8e36e4088d11301e52b782597ad Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 17 Sep 2025 09:12:23 -0700 Subject: [PATCH] =?utf8?q?maint:=20STREQ=20=E2=86=92=20streq?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Use new Gnulib streq function instead of rolling our own macro. * bootstrap.conf (gnulib_modules): Add stringeq. * src/rm.c (main): Don’t assume streq is a macro that expands to (...), as it is now a function. * src/system.h: * tests/df/no-mtab-status.sh, tests/df/skip-duplicates.sh: (STREQ): Remove. All uses replaced by streq. --- bootstrap.conf | 1 + gl/lib/root-dev-ino.h | 2 +- src/basenc.c | 4 +- src/cat.c | 2 +- src/chcon.c | 2 +- src/chroot.c | 2 +- src/comm.c | 4 +- src/copy.c | 6 +-- src/coreutils.c | 6 +-- src/cp.c | 4 +- src/csplit.c | 2 +- src/cut.c | 4 +- src/date.c | 2 +- src/df.c | 26 +++++------ src/digest.c | 8 ++-- src/dircolors.c | 4 +- src/du.c | 6 +-- src/echo.c | 6 +-- src/env.c | 2 +- src/expand-common.c | 4 +- src/expr.c | 4 +- src/fmt.c | 2 +- src/fold.c | 4 +- src/head.c | 2 +- src/install.c | 2 +- src/join.c | 10 ++--- src/nl.c | 10 ++--- src/numfmt.c | 2 +- src/od.c | 4 +- src/paste.c | 4 +- src/pinky.c | 2 +- src/pr.c | 4 +- src/printf.c | 6 +-- src/ptx.c | 6 +-- src/rm.c | 4 +- src/seq.c | 2 +- src/set-fields.c | 2 +- src/shred.c | 6 +-- src/shuf.c | 6 +-- src/sort.c | 20 ++++----- src/split.c | 4 +- src/stat.c | 8 ++-- src/stdbuf.c | 2 +- src/stty.c | 90 ++++++++++++++++++------------------- src/system.h | 5 +-- src/tac.c | 2 +- src/tail.c | 16 +++---- src/test.c | 60 ++++++++++++------------- src/touch.c | 2 +- src/true.c | 4 +- src/tsort.c | 4 +- src/uniq.c | 4 +- src/wc.c | 8 ++-- tests/df/no-mtab-status.sh | 4 +- tests/df/skip-duplicates.sh | 10 ++--- 55 files changed, 208 insertions(+), 214 deletions(-) diff --git a/bootstrap.conf b/bootstrap.conf index 50e76652df..1a2d961a1d 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -260,6 +260,7 @@ gnulib_modules=" stpcpy str_endswith strdup-posix + stringeq strnlen strnumcmp strsignal diff --git a/gl/lib/root-dev-ino.h b/gl/lib/root-dev-ino.h index 1250d34395..a4d909f825 100644 --- a/gl/lib/root-dev-ino.h +++ b/gl/lib/root-dev-ino.h @@ -33,7 +33,7 @@ get_root_dev_ino (struct dev_ino *root_d_i) _GL_ATTRIBUTE_NONNULL (); # define ROOT_DEV_INO_WARN(Dirname) \ do \ { \ - if (STREQ (Dirname, "/")) \ + if (streq (Dirname, "/")) \ error (0, 0, _("it is dangerous to operate recursively on %s"), \ quoteaf (Dirname)); \ else \ diff --git a/src/basenc.c b/src/basenc.c index 35168f49b2..1fb7a16f58 100644 --- a/src/basenc.c +++ b/src/basenc.c @@ -1452,7 +1452,7 @@ finish_and_exit (FILE *in, char const *infile) { if (fclose (in) != 0) { - if (STREQ (infile, "-")) + if (streq (infile, "-")) error (EXIT_FAILURE, errno, _("closing standard input")); else error (EXIT_FAILURE, errno, "%s", quotef (infile)); @@ -1790,7 +1790,7 @@ main (int argc, char **argv) else infile = "-"; - if (STREQ (infile, "-")) + if (streq (infile, "-")) { xset_binary_mode (STDIN_FILENO, O_BINARY); input_fh = stdin; diff --git a/src/cat.c b/src/cat.c index 9b94ee1247..2a3c1d18a0 100644 --- a/src/cat.c +++ b/src/cat.c @@ -679,7 +679,7 @@ main (int argc, char **argv) if (argind < argc) infile = argv[argind]; - bool reading_stdin = STREQ (infile, "-"); + bool reading_stdin = streq (infile, "-"); if (reading_stdin) { have_read_stdin = true; diff --git a/src/chcon.c b/src/chcon.c index 3c8edab31f..a54133a5cd 100644 --- a/src/chcon.c +++ b/src/chcon.c @@ -177,7 +177,7 @@ change_file_context (int fd, char const *file) context_string = specified_context; } - if (file_context == nullptr || ! STREQ (context_string, file_context)) + if (file_context == nullptr || ! streq (context_string, file_context)) { int fail = (affect_symlink_referent ? setfileconat (fd, file, context_string) diff --git a/src/chroot.c b/src/chroot.c index ca0677b016..27cb15e72d 100644 --- a/src/chroot.c +++ b/src/chroot.c @@ -171,7 +171,7 @@ static bool is_root (char const *dir) { char *resolved = canonicalize_file_name (dir); - bool is_res_root = resolved && STREQ ("/", resolved); + bool is_res_root = resolved && streq ("/", resolved); free (resolved); return is_res_root; } diff --git a/src/comm.c b/src/comm.c index 6ebf66f380..355f72b691 100644 --- a/src/comm.c +++ b/src/comm.c @@ -285,7 +285,7 @@ compare_files (char **infiles) alt[i][0] = 0; alt[i][1] = 0; alt[i][2] = 0; - streams[i] = (STREQ (infiles[i], "-") ? stdin : fopen (infiles[i], "r")); + streams[i] = (streq (infiles[i], "-") ? stdin : fopen (infiles[i], "r")); if (!streams[i]) error (EXIT_FAILURE, errno, "%s", quotef (infiles[i])); @@ -464,7 +464,7 @@ main (int argc, char **argv) break; case OUTPUT_DELIMITER_OPTION: - if (col_sep_len && !STREQ (col_sep, optarg)) + if (col_sep_len && !streq (col_sep, optarg)) error (EXIT_FAILURE, 0, _("multiple output delimiters specified")); col_sep = optarg; col_sep_len = *optarg ? strlen (optarg) : 1; diff --git a/src/copy.c b/src/copy.c index c1df848c8a..11c82e1a81 100644 --- a/src/copy.c +++ b/src/copy.c @@ -1598,7 +1598,7 @@ source_is_dst_backup (char const *srcbase, struct stat const *src_st, size_t suffixlen = strlen (simple_backup_suffix); if (! (srcbaselen == dstbaselen + suffixlen && memcmp (srcbase, dstbase, dstbaselen) == 0 - && STREQ (srcbase + dstbaselen, simple_backup_suffix))) + && streq (srcbase + dstbaselen, simple_backup_suffix))) return false; char *dst_back = subst_suffix (dst_relname, dst_relname + strlen (dst_relname), @@ -2435,7 +2435,7 @@ skip: dst_parent = dir_name (dst_relname); - in_current_dir = ((dst_dirfd == AT_FDCWD && STREQ (".", dst_parent)) + in_current_dir = ((dst_dirfd == AT_FDCWD && streq (".", dst_parent)) /* If either stat call fails, it's ok not to report the failure and say dst_name is in the current directory. Other things will fail later. */ @@ -2555,7 +2555,7 @@ skip: areadlinkat_with_size (dst_dirfd, dst_relname, dst_sb.st_size); if (dest_link_val) { - if (STREQ (dest_link_val, src_link_val)) + if (streq (dest_link_val, src_link_val)) symlink_err = 0; free (dest_link_val); } diff --git a/src/coreutils.c b/src/coreutils.c index fc79bea2f4..5f357cd687 100644 --- a/src/coreutils.c +++ b/src/coreutils.c @@ -103,7 +103,7 @@ launch_program (char const *prog_name, int prog_argc, char **prog_argv) if (false); /* Look up the right main program. */ # define SINGLE_BINARY_PROGRAM(prog_name_str, main_name) \ - else if (STREQ (prog_name_str, prog_name)) \ + else if (streq (prog_name_str, prog_name)) \ prog_main = single_binary_main_##main_name; # include "coreutils.h" # undef SINGLE_BINARY_PROGRAM @@ -134,7 +134,7 @@ main (int argc, char **argv) /* Map external name to internal name. */ char ginstall[] = "ginstall"; - if (STREQ (prog_name, "install")) + if (streq (prog_name, "install")) prog_name = ginstall; /* If this program is called directly as "coreutils" or if the value of @@ -198,7 +198,7 @@ main (int argc, char **argv) /* Only print the error message when no options have been passed to coreutils. */ - if (optind == 1 && prog_name && !STREQ (prog_name, "coreutils")) + if (optind == 1 && prog_name && !streq (prog_name, "coreutils")) error (0, 0, _("unknown program %s"), quote (prog_name)); diff --git a/src/cp.c b/src/cp.c index 57450dbd45..317d667ce0 100644 --- a/src/cp.c +++ b/src/cp.c @@ -742,7 +742,7 @@ do_copy (int n_files, char **file, char const *target_directory, ASSIGN_STRDUPA (arg_base, last_component (arg)); strip_trailing_slashes (arg_base); /* For 'cp -R source/.. dest', don't copy into 'dest/..'. */ - arg_base += STREQ (arg_base, ".."); + arg_base += streq (arg_base, ".."); dst_name = file_name_concat (target_directory, arg_base, &arg_in_concat); } @@ -802,7 +802,7 @@ do_copy (int n_files, char **file, char const *target_directory, if (x->unlink_dest_after_failed_open && x->backup_type != no_backups - && STREQ (source, dest) + && streq (source, dest) && !new_dst && (sb.st_mode != 0 || stat (dest, &sb) == 0) && S_ISREG (sb.st_mode)) { diff --git a/src/csplit.c b/src/csplit.c index 506f9248f9..de499f166a 100644 --- a/src/csplit.c +++ b/src/csplit.c @@ -608,7 +608,7 @@ no_more_lines (void) static void set_input_file (char const *name) { - if (! STREQ (name, "-") && fd_reopen (STDIN_FILENO, name, O_RDONLY, 0) < 0) + if (! streq (name, "-") && fd_reopen (STDIN_FILENO, name, O_RDONLY, 0) < 0) error (EXIT_FAILURE, errno, _("cannot open %s for reading"), quoteaf (name)); } diff --git a/src/cut.c b/src/cut.c index b424997035..f0effb9eb5 100644 --- a/src/cut.c +++ b/src/cut.c @@ -441,7 +441,7 @@ cut_file (char const *file, void (*cut_stream) (FILE *)) { FILE *stream; - if (STREQ (file, "-")) + if (streq (file, "-")) { have_read_stdin = true; stream = stdin; @@ -464,7 +464,7 @@ cut_file (char const *file, void (*cut_stream) (FILE *)) int err = errno; if (!ferror (stream)) err = 0; - if (STREQ (file, "-")) + if (streq (file, "-")) clearerr (stream); /* Also clear EOF. */ else if (fclose (stream) == EOF) err = errno; diff --git a/src/date.c b/src/date.c index f3a8241cf8..db16f3225a 100644 --- a/src/date.c +++ b/src/date.c @@ -410,7 +410,7 @@ batch_convert (char const *input_filename, size_t buflen; struct timespec when; - if (STREQ (input_filename, "-")) + if (streq (input_filename, "-")) { input_filename = _("standard input"); in_stream = stdin; diff --git a/src/df.c b/src/df.c index 5e369830fc..857f76cf4a 100644 --- a/src/df.c +++ b/src/df.c @@ -443,7 +443,7 @@ decode_output_arg (char const *arg) display_field_t field = INVALID_FIELD; for (idx_t i = 0; i < ARRAY_CARDINALITY (field_data); i++) { - if (STREQ (field_data[i].arg, s)) + if (streq (field_data[i].arg, s)) { field = i; break; @@ -643,7 +643,7 @@ selected_fstype (char const *fstype) if (fs_select_list == nullptr || fstype == nullptr) return true; for (fsp = fs_select_list; fsp; fsp = fsp->fs_next) - if (STREQ (fstype, fsp->fs_name)) + if (streq (fstype, fsp->fs_name)) return true; return false; } @@ -659,7 +659,7 @@ excluded_fstype (char const *fstype) if (fs_exclude_list == nullptr || fstype == nullptr) return false; for (fsp = fs_exclude_list; fsp; fsp = fsp->fs_next) - if (STREQ (fstype, fsp->fs_name)) + if (streq (fstype, fsp->fs_name)) return true; return false; } @@ -754,7 +754,7 @@ filter_mount_list (bool devices_only) < strlen (me->me_mntroot)); if (! print_grand_total && me->me_remote && seen_dev->me->me_remote - && ! STREQ (seen_dev->me->me_devname, me->me_devname)) + && ! streq (seen_dev->me->me_devname, me->me_devname)) { /* Don't discard remote entries with different locations, as these are more likely to be explicitly mounted. @@ -767,12 +767,12 @@ filter_mount_list (bool devices_only) /* let points towards the root of the device win. */ || (target_nearer_root && ! source_below_root) /* let an entry overmounted on a new device win... */ - || (! STREQ (seen_dev->me->me_devname, me->me_devname) + || (! streq (seen_dev->me->me_devname, me->me_devname) /* ... but only when matching an existing mnt point, to avoid problematic replacement when given inaccurate mount lists, seen with some chroot environments for example. */ - && STREQ (me->me_mountdir, + && streq (me->me_mountdir, seen_dev->me->me_mountdir))) { /* Discard mount entry for existing device. */ @@ -1057,7 +1057,7 @@ get_dev (char const *device, char const *mount_point, char const *file, if (stat (stat_file, &sb) == 0) { struct mount_entry const * dev_me = me_for_dev (sb.st_dev); - if (dev_me && ! STREQ (dev_me->me_devname, device) + if (dev_me && ! streq (dev_me->me_devname, device) && (! dev_me->me_remote || ! me_remote)) { fstype = "-"; @@ -1244,7 +1244,7 @@ last_device_for_mount (char const *mount) for (me = mount_list; me; me = me->me_next) { - if (STREQ (me->me_mountdir, mount)) + if (streq (me->me_mountdir, mount)) le = me; } @@ -1285,10 +1285,10 @@ get_device (char const *device) if (canon_dev && IS_ABSOLUTE_FILE_NAME (canon_dev)) devname = canon_dev; - if (STREQ (device, devname)) + if (streq (device, devname)) { char *last_device = last_device_for_mount (me->me_mountdir); - eclipsed_device = last_device && ! STREQ (last_device, devname); + eclipsed_device = last_device && ! streq (last_device, devname); size_t len = strlen (me->me_mountdir); if (! eclipsed_device @@ -1362,7 +1362,7 @@ get_point (char const *point, const struct stat *statp) for (me = mount_list; me; me = me->me_next) { - if (!STREQ (me->me_type, "lofs") + if (!streq (me->me_type, "lofs") && (!best_match || best_match->me_dummy || !me->me_dummy)) { size_t len = strlen (me->me_mountdir); @@ -1407,7 +1407,7 @@ get_point (char const *point, const struct stat *statp) } if (statp->st_dev == me->me_dev - && !STREQ (me->me_type, "lofs") + && !streq (me->me_type, "lofs") && (!best_match || best_match->me_dummy || !me->me_dummy)) { /* Skip bogus mtab entries. */ @@ -1734,7 +1734,7 @@ main (int argc, char **argv) struct fs_type_list *fs_excl; for (fs_excl = fs_exclude_list; fs_excl; fs_excl = fs_excl->fs_next) { - if (STREQ (fs_incl->fs_name, fs_excl->fs_name)) + if (streq (fs_incl->fs_name, fs_excl->fs_name)) { error (0, 0, _("file system type %s both selected and excluded"), diff --git a/src/digest.c b/src/digest.c index c9f6106b95..03b3190d6b 100644 --- a/src/digest.c +++ b/src/digest.c @@ -868,7 +868,7 @@ split_3 (char *s, size_t s_len, bool length_specified = s[i] == '-'; bool openssl_format = s[i] == '('; /* and no length_specified */ s[i++] = '\0'; - if (!STREQ (algo_name, DIGEST_TYPE_STRING)) + if (!streq (algo_name, DIGEST_TYPE_STRING)) return false; if (openssl_format) s[--i] = '('; @@ -1049,7 +1049,7 @@ digest_file (char const *filename, int *binary, unsigned char *bin_result, { FILE *fp; int err; - bool is_stdin = STREQ (filename, "-"); + bool is_stdin = streq (filename, "-"); *missing = false; @@ -1235,7 +1235,7 @@ digest_check (char const *checkfile_name) uintmax_t line_number; char *line; size_t line_chars_allocated; - bool is_stdin = STREQ (checkfile_name, "-"); + bool is_stdin = streq (checkfile_name, "-"); if (is_stdin) { @@ -1289,7 +1289,7 @@ digest_check (char const *checkfile_name) size_t d_len; if (! (split_3 (line, line_length, &digest, &d_len, &binary, &filename) - && ! (is_stdin && STREQ (filename, "-")))) + && ! (is_stdin && streq (filename, "-")))) { ++n_misformatted_lines; diff --git a/src/dircolors.c b/src/dircolors.c index 3893f2fb33..cb6714dbfd 100644 --- a/src/dircolors.c +++ b/src/dircolors.c @@ -137,7 +137,7 @@ guess_shell_syntax (void) shell = last_component (shell); - if (STREQ (shell, "csh") || STREQ (shell, "tcsh")) + if (streq (shell, "csh") || streq (shell, "tcsh")) return SHELL_SYNTAX_C; return SHELL_SYNTAX_BOURNE; @@ -396,7 +396,7 @@ dc_parse_file (char const *filename) { bool ok; - if (! STREQ (filename, "-") && freopen (filename, "r", stdin) == nullptr) + if (! streq (filename, "-") && freopen (filename, "r", stdin) == nullptr) { error (0, errno, "%s", quotef (filename)); return false; diff --git a/src/du.c b/src/du.c index e8ad3e93c0..f4dbd8c053 100644 --- a/src/du.c +++ b/src/du.c @@ -950,7 +950,7 @@ main (int argc, char **argv) time_style = getenv ("TIME_STYLE"); /* Ignore TIMESTYLE="locale", for compatibility with ls. */ - if (! time_style || STREQ (time_style, "locale")) + if (! time_style || streq (time_style, "locale")) time_style = "long-iso"; else if (*time_style == '+') { @@ -1007,7 +1007,7 @@ main (int argc, char **argv) usage (EXIT_FAILURE); } - if (! (STREQ (files_from, "-") || freopen (files_from, "r", stdin))) + if (! (streq (files_from, "-") || freopen (files_from, "r", stdin))) error (EXIT_FAILURE, errno, _("cannot open %s for reading"), quoteaf (files_from)); @@ -1066,7 +1066,7 @@ main (int argc, char **argv) affirm (!"unexpected error code from argv_iter"); } } - if (files_from && STREQ (files_from, "-") && STREQ (file_name, "-")) + if (files_from && streq (files_from, "-") && streq (file_name, "-")) { /* Give a better diagnostic in an unusual case: printf - | du --files0-from=- */ diff --git a/src/echo.c b/src/echo.c index 991a574253..c688037b37 100644 --- a/src/echo.c +++ b/src/echo.c @@ -116,7 +116,7 @@ main (int argc, char **argv) bool posixly_correct = !!getenv ("POSIXLY_CORRECT"); bool allow_options = (! posixly_correct - || (! DEFAULT_ECHO_TO_XPG && 1 < argc && STREQ (argv[1], "-n"))); + || (! DEFAULT_ECHO_TO_XPG && 1 < argc && streq (argv[1], "-n"))); /* System V machines already have a /bin/sh with a v9 behavior. Use the identical behavior for these machines so that the @@ -135,10 +135,10 @@ main (int argc, char **argv) order to avoid accepting abbreviations. */ if (allow_options && argc == 2) { - if (STREQ (argv[1], "--help")) + if (streq (argv[1], "--help")) usage (EXIT_SUCCESS); - if (STREQ (argv[1], "--version")) + if (streq (argv[1], "--version")) { version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS, (char *) nullptr); diff --git a/src/env.c b/src/env.c index baa1e1372d..e06ca55681 100644 --- a/src/env.c +++ b/src/env.c @@ -831,7 +831,7 @@ main (int argc, char **argv) } } - if (optind < argc && STREQ (argv[optind], "-")) + if (optind < argc && streq (argv[optind], "-")) { ignore_environment = true; ++optind; diff --git a/src/expand-common.c b/src/expand-common.c index 366c589cf6..ca2ad4d67b 100644 --- a/src/expand-common.c +++ b/src/expand-common.c @@ -348,7 +348,7 @@ next_file (FILE *fp) int err = errno; if (!ferror (fp)) err = 0; - if (STREQ (prev_file, "-")) + if (streq (prev_file, "-")) clearerr (fp); /* Also clear EOF. */ else if (fclose (fp) != 0) err = errno; @@ -361,7 +361,7 @@ next_file (FILE *fp) while ((file = *file_list++) != nullptr) { - if (STREQ (file, "-")) + if (streq (file, "-")) { have_read_stdin = true; fp = stdin; diff --git a/src/expr.c b/src/expr.c index cd87763df7..17a1ddd299 100644 --- a/src/expr.c +++ b/src/expr.c @@ -322,7 +322,7 @@ main (int argc, char **argv) /* The above handles --help and --version. Since there is no other invocation of getopt, handle '--' here. */ - if (1 < argc && STREQ (argv[1], "--")) + if (1 < argc && streq (argv[1], "--")) { --argc; ++argv; @@ -522,7 +522,7 @@ nextarg (char const *str) return false; else { - bool r = STREQ (*args, str); + bool r = streq (*args, str); args += r; return r; } diff --git a/src/fmt.c b/src/fmt.c index 408fe45a1a..b44bbde5c7 100644 --- a/src/fmt.c +++ b/src/fmt.c @@ -424,7 +424,7 @@ main (int argc, char **argv) for (; optind < argc; optind++) { char *file = argv[optind]; - if (STREQ (file, "-")) + if (streq (file, "-")) { ok &= fmt (stdin, file); have_read_stdin = true; diff --git a/src/fold.c b/src/fold.c index 6969a81e80..e908371432 100644 --- a/src/fold.c +++ b/src/fold.c @@ -157,7 +157,7 @@ fold_file (char const *filename, size_t width) static size_t length_in = 0; int saved_errno; - if (STREQ (filename, "-")) + if (streq (filename, "-")) { istream = stdin; have_read_stdin = true; @@ -291,7 +291,7 @@ fold_file (char const *filename, size_t width) if (offset_out) write_out (line_out, offset_out, /*newline=*/ false); - if (STREQ (filename, "-")) + if (streq (filename, "-")) clearerr (istream); else if (fclose (istream) != 0 && !saved_errno) saved_errno = errno; diff --git a/src/head.c b/src/head.c index 20c2ee0313..127099dfc5 100644 --- a/src/head.c +++ b/src/head.c @@ -860,7 +860,7 @@ head_file (char const *filename, uintmax_t n_units, bool count_lines, { int fd; bool ok; - bool is_stdin = STREQ (filename, "-"); + bool is_stdin = streq (filename, "-"); if (is_stdin) { diff --git a/src/install.c b/src/install.c index b3b26abdb4..53f6a2ff57 100644 --- a/src/install.c +++ b/src/install.c @@ -227,7 +227,7 @@ need_copy (char const *src_name, char const *dest_name, return true; } - scontext_match = STREQ (file_scontext_raw, to_scontext_raw); + scontext_match = streq (file_scontext_raw, to_scontext_raw); freecon (file_scontext_raw); freecon (to_scontext_raw); diff --git a/src/join.c b/src/join.c index faf402eeab..28d9dd3ee3 100644 --- a/src/join.c +++ b/src/join.c @@ -1054,7 +1054,7 @@ main (int argc, char **argv) break; case 'e': - if (empty_filler && ! STREQ (empty_filler, optarg)) + if (empty_filler && ! streq (empty_filler, optarg)) error (EXIT_FAILURE, 0, _("conflicting empty-field replacement strings")); empty_filler = optarg; @@ -1089,7 +1089,7 @@ main (int argc, char **argv) break; case 'o': - if (STREQ (optarg, "auto")) + if (streq (optarg, "auto")) autoformat = true; else { @@ -1107,7 +1107,7 @@ main (int argc, char **argv) newtab = mcel_ch ('\n', 1); /* output_separator does not matter. */ } - else if (STREQ (optarg, "\\0")) + else if (streq (optarg, "\\0")) { newtab = mcel_ch ('\0', 1); output_separator = ""; @@ -1188,10 +1188,10 @@ main (int argc, char **argv) if (join_field_2 < 0) join_field_2 = 0; - fp1 = STREQ (g_names[0], "-") ? stdin : fopen (g_names[0], "r"); + fp1 = streq (g_names[0], "-") ? stdin : fopen (g_names[0], "r"); if (!fp1) error (EXIT_FAILURE, errno, "%s", quotef (g_names[0])); - fp2 = STREQ (g_names[1], "-") ? stdin : fopen (g_names[1], "r"); + fp2 = streq (g_names[1], "-") ? stdin : fopen (g_names[1], "r"); if (!fp2) error (EXIT_FAILURE, errno, "%s", quotef (g_names[1])); if (fp1 == fp2) diff --git a/src/nl.c b/src/nl.c index 71421c4bab..2812b383b7 100644 --- a/src/nl.c +++ b/src/nl.c @@ -436,7 +436,7 @@ nl_file (char const *file) { FILE *stream; - if (STREQ (file, "-")) + if (streq (file, "-")) { have_read_stdin = true; stream = stdin; @@ -459,7 +459,7 @@ nl_file (char const *file) int err = errno; if (!ferror (stream)) err = 0; - if (STREQ (file, "-")) + if (streq (file, "-")) clearerr (stream); /* Also clear EOF. */ else if (fclose (stream) != 0 && !err) err = errno; @@ -544,11 +544,11 @@ main (int argc, char **argv) 0, XTOINT_MIN_RANGE); break; case 'n': - if (STREQ (optarg, "ln")) + if (streq (optarg, "ln")) lineno_format = FORMAT_LEFT; - else if (STREQ (optarg, "rn")) + else if (streq (optarg, "rn")) lineno_format = FORMAT_RIGHT_NOLZ; - else if (STREQ (optarg, "rz")) + else if (streq (optarg, "rz")) lineno_format = FORMAT_RIGHT_LZ; else { diff --git a/src/numfmt.c b/src/numfmt.c index 3fc027c7ea..4f72facb94 100644 --- a/src/numfmt.c +++ b/src/numfmt.c @@ -1279,7 +1279,7 @@ process_suffixed_number (char *text, long double *result, { char *possible_suffix = text + strlen (text) - strlen (suffix); - if (STREQ (suffix, possible_suffix)) + if (streq (suffix, possible_suffix)) { /* trim suffix, ONLY if it's at the end of the text. */ *possible_suffix = '\0'; diff --git a/src/od.c b/src/od.c index d38a4c3803..45d9f32e6f 100644 --- a/src/od.c +++ b/src/od.c @@ -987,7 +987,7 @@ open_next_file (void) return ok; ++file_list; - if (STREQ (input_filename, "-")) + if (streq (input_filename, "-")) { input_filename = _("standard input"); in_stream = stdin; @@ -1028,7 +1028,7 @@ check_and_close (int in_errno) { if (!ferror (in_stream)) in_errno = 0; - if (STREQ (file_list[-1], "-")) + if (streq (file_list[-1], "-")) clearerr (in_stream); else if (fclose (in_stream) != 0 && !in_errno) in_errno = errno; diff --git a/src/paste.c b/src/paste.c index 10d1424366..d2c5c2d425 100644 --- a/src/paste.c +++ b/src/paste.c @@ -191,7 +191,7 @@ paste_parallel (size_t nfiles, char **fnamptr) for (files_open = 0; files_open < nfiles; ++files_open) { - if (STREQ (fnamptr[files_open], "-")) + if (streq (fnamptr[files_open], "-")) { have_read_stdin = true; fileptr[files_open] = stdin; @@ -343,7 +343,7 @@ paste_serial (size_t nfiles, char **fnamptr) for (; nfiles; nfiles--, fnamptr++) { int saved_errno; - bool is_stdin = STREQ (*fnamptr, "-"); + bool is_stdin = streq (*fnamptr, "-"); if (is_stdin) { have_read_stdin = true; diff --git a/src/pinky.c b/src/pinky.c index 287b3a3f2b..b49096b357 100644 --- a/src/pinky.c +++ b/src/pinky.c @@ -452,7 +452,7 @@ scan_entries (idx_t n, STRUCT_UTMP const *utmp_buf, if (argc_names) { for (int i = 0; i < argc_names; i++) - if (STREQ (utmp_buf->ut_user, argv_names[i])) + if (streq (utmp_buf->ut_user, argv_names[i])) { print_entry (utmp_buf); break; diff --git a/src/pr.c b/src/pr.c index e7081a059a..87974d058b 100644 --- a/src/pr.c +++ b/src/pr.c @@ -1483,7 +1483,7 @@ init_funcs (void) static bool open_file (char *name, COLUMN *p) { - if (STREQ (name, "-")) + if (streq (name, "-")) { p->name = _("standard input"); p->fp = stdin; @@ -1654,7 +1654,7 @@ init_header (char const *filename, int desc) struct tm tm; /* If parallel files or standard input, use current date. */ - if (STREQ (filename, "-")) + if (streq (filename, "-")) desc = -1; if (0 <= desc && fstat (desc, &st) == 0) t = get_stat_mtime (&st); diff --git a/src/printf.c b/src/printf.c index 2a73bb7fed..5ac9e13eea 100644 --- a/src/printf.c +++ b/src/printf.c @@ -708,10 +708,10 @@ main (int argc, char **argv) order to avoid accepting abbreviations. */ if (argc == 2) { - if (STREQ (argv[1], "--help")) + if (streq (argv[1], "--help")) usage (EXIT_SUCCESS); - if (STREQ (argv[1], "--version")) + if (streq (argv[1], "--version")) { version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS, (char *) nullptr); @@ -721,7 +721,7 @@ main (int argc, char **argv) /* The above handles --help and --version. Since there is no other invocation of getopt, handle '--' here. */ - if (1 < argc && STREQ (argv[1], "--")) + if (1 < argc && streq (argv[1], "--")) { --argc; ++argv; diff --git a/src/ptx.c b/src/ptx.c index 006eb66afe..1f7fc6731c 100644 --- a/src/ptx.c +++ b/src/ptx.c @@ -505,7 +505,7 @@ swallow_file_in_memory (char const *file_name, BLOCK *block) /* As special cases, a file name which is null or "-" indicates standard input, which is already opened. In all other cases, open the file from its name. */ - bool using_stdin = !file_name || !*file_name || STREQ (file_name, "-"); + bool using_stdin = !file_name || !*file_name || streq (file_name, "-"); if (using_stdin) block->start = fread_file (stdin, 0, &used_length); else @@ -1915,7 +1915,7 @@ main (int argc, char **argv) for (file_index = 0; file_index < number_input_files; file_index++) { - if (!*argv[optind] || STREQ (argv[optind], "-")) + if (!*argv[optind] || streq (argv[optind], "-")) input_file_name[file_index] = nullptr; else input_file_name[file_index] = argv[optind]; @@ -1931,7 +1931,7 @@ main (int argc, char **argv) input_file_name = xmalloc (sizeof *input_file_name); file_line_count = xmalloc (sizeof *file_line_count); text_buffers = xmalloc (sizeof *text_buffers); - if (!*argv[optind] || STREQ (argv[optind], "-")) + if (!*argv[optind] || streq (argv[optind], "-")) input_file_name[0] = nullptr; else input_file_name[0] = argv[optind]; diff --git a/src/rm.c b/src/rm.c index 46a3d4d135..2d08e71d9f 100644 --- a/src/rm.c +++ b/src/rm.c @@ -295,7 +295,7 @@ main (int argc, char **argv) break; case NO_PRESERVE_ROOT: - if (! STREQ (argv[optind - 1], "--no-preserve-root")) + if (! streq (argv[optind - 1], "--no-preserve-root")) error (EXIT_FAILURE, 0, _("you may not abbreviate the --no-preserve-root option")); preserve_root = false; @@ -304,7 +304,7 @@ main (int argc, char **argv) case PRESERVE_ROOT: if (optarg) { - if STREQ (optarg, "all") + if (streq (optarg, "all")) x.preserve_all_root = true; else error (EXIT_FAILURE, 0, diff --git a/src/seq.c b/src/seq.c index 59de497984..2bff0d40cc 100644 --- a/src/seq.c +++ b/src/seq.c @@ -347,7 +347,7 @@ print_numbers (char const *fmt, struct layout layout, if (x0_strlen < 0) xalloc_die (); x0_str[x0_strlen - layout.suffix_len] = '\0'; - print_extra_number = !STREQ (x0_str, x_str); + print_extra_number = !streq (x0_str, x_str); free (x0_str); } diff --git a/src/set-fields.c b/src/set-fields.c index 31547e4e9a..14f7e4d650 100644 --- a/src/set-fields.c +++ b/src/set-fields.c @@ -147,7 +147,7 @@ set_fields (char const *fieldstr, unsigned int options) /* Collect and store in RP the range end points. */ /* Special case: '--field=-' means all fields, emulate '--field=1-' . */ - if ((options & SETFLD_ALLOW_DASH) && STREQ (fieldstr,"-")) + if ((options & SETFLD_ALLOW_DASH) && streq (fieldstr,"-")) { value = 1; lhs_specified = true; diff --git a/src/shred.c b/src/shred.c index 6458228949..cf782f16eb 100644 --- a/src/shred.c +++ b/src/shred.c @@ -552,7 +552,7 @@ dopass (int fd, struct stat const *st, char const *qname, off_t *sizep, = human_readable (offset, offset_buf, human_floor | human_progress_opts, 1, 1); - if (done || !STREQ (previous_human_offset, human_offset)) + if (done || !streq (previous_human_offset, human_offset)) { if (! known (size)) error (0, 0, _("%s: pass %lu/%lu (%s)...%s"), @@ -1195,7 +1195,7 @@ main (int argc, char **argv) break; case RANDOM_SOURCE_OPTION: - if (random_source && !STREQ (random_source, optarg)) + if (random_source && !streq (random_source, optarg)) error (EXIT_FAILURE, 0, _("multiple random sources specified")); random_source = optarg; break; @@ -1252,7 +1252,7 @@ main (int argc, char **argv) for (i = 0; i < n_files; i++) { char *qname = xstrdup (quotef (file[i])); - if (STREQ (file[i], "-")) + if (streq (file[i], "-")) { ok &= wipefd (STDOUT_FILENO, qname, randint_source, &flags); } diff --git a/src/shuf.c b/src/shuf.c index 3c50aa23dd..d43606620f 100644 --- a/src/shuf.c +++ b/src/shuf.c @@ -450,13 +450,13 @@ main (int argc, char **argv) break; case 'o': - if (outfile && !STREQ (outfile, optarg)) + if (outfile && !streq (outfile, optarg)) error (EXIT_FAILURE, 0, _("multiple output files specified")); outfile = optarg; break; case RANDOM_SOURCE_OPTION: - if (random_source && !STREQ (random_source, optarg)) + if (random_source && !streq (random_source, optarg)) error (EXIT_FAILURE, 0, _("multiple random sources specified")); random_source = optarg; break; @@ -511,7 +511,7 @@ main (int argc, char **argv) { /* If an input file is specified, re-open it as stdin. */ if (n_operands == 1 - && ! (STREQ (operand[0], "-") + && ! (streq (operand[0], "-") || freopen (operand[0], "r", stdin))) error (EXIT_FAILURE, errno, "%s", quotef (operand[0])); diff --git a/src/sort.c b/src/sort.c index a4d81bc1c8..5a6a963f35 100644 --- a/src/sort.c +++ b/src/sort.c @@ -954,7 +954,7 @@ stream_open (char const *file, char const *how) if (*how == 'r') { - if (STREQ (file, "-")) + if (streq (file, "-")) { have_read_stdin = true; fp = stdin; @@ -1534,7 +1534,7 @@ sort_buffer_size (FILE *const *fps, size_t nfps, size_t worst_case; if ((i < nfps ? fstat (fileno (fps[i]), &st) - : STREQ (files[i], "-") ? fstat (STDIN_FILENO, &st) + : streq (files[i], "-") ? fstat (STDIN_FILENO, &st) : stat (files[i], &st)) != 0) sort_die (_("stat failed"), files[i]); @@ -3859,11 +3859,11 @@ avoid_trashing_input (struct sortfile *files, size_t ntemps, for (size_t i = ntemps; i < nfiles; i++) { - bool is_stdin = STREQ (files[i].name, "-"); + bool is_stdin = streq (files[i].name, "-"); bool same; struct stat instat; - if (outfile && STREQ (outfile, files[i].name) && !is_stdin) + if (outfile && streq (outfile, files[i].name) && !is_stdin) same = true; else { @@ -3907,7 +3907,7 @@ check_inputs (char *const *files, size_t nfiles) { for (size_t i = 0; i < nfiles; i++) { - if (STREQ (files[i], "-")) + if (streq (files[i], "-")) continue; if (euidaccess (files[i], R_OK) != 0) @@ -4567,7 +4567,7 @@ main (int argc, char **argv) break; case COMPRESS_PROGRAM_OPTION: - if (compress_program && !STREQ (compress_program, optarg)) + if (compress_program && !streq (compress_program, optarg)) error (SORT_FAILURE, 0, _("multiple compress programs specified")); compress_program = optarg; break; @@ -4640,13 +4640,13 @@ main (int argc, char **argv) break; case 'o': - if (outfile && !STREQ (outfile, optarg)) + if (outfile && !streq (outfile, optarg)) error (SORT_FAILURE, 0, _("multiple output files specified")); outfile = optarg; break; case RANDOM_SOURCE_OPTION: - if (random_source && !STREQ (random_source, optarg)) + if (random_source && !streq (random_source, optarg)) error (SORT_FAILURE, 0, _("multiple random sources specified")); random_source = optarg; break; @@ -4666,7 +4666,7 @@ main (int argc, char **argv) error (SORT_FAILURE, 0, _("empty tab")); if (optarg[1]) { - if (STREQ (optarg, "\\0")) + if (streq (optarg, "\\0")) newtab = '\0'; else { @@ -4757,7 +4757,7 @@ main (int argc, char **argv) nfiles = tok.n_tok; for (size_t i = 0; i < nfiles; i++) { - if (STREQ (files[i], "-")) + if (streq (files[i], "-")) error (SORT_FAILURE, 0, _("when reading file names from " "standard input, " "no file name of %s allowed"), diff --git a/src/split.c b/src/split.c index e5f6947f81..e58e0db54e 100644 --- a/src/split.c +++ b/src/split.c @@ -1452,7 +1452,7 @@ main (int argc, char **argv) error (EXIT_FAILURE, 0, _("empty record separator")); if (optarg[1]) { - if (STREQ (optarg, "\\0")) + if (streq (optarg, "\\0")) neweol = '\0'; else { @@ -1605,7 +1605,7 @@ main (int argc, char **argv) } /* Open the input file. */ - if (! STREQ (infile, "-") + if (! streq (infile, "-") && fd_reopen (STDIN_FILENO, infile, O_RDONLY, 0) < 0) error (EXIT_FAILURE, errno, _("cannot open %s for reading"), quoteaf (infile)); diff --git a/src/stat.c b/src/stat.c index df9e3d4408..348e33793d 100644 --- a/src/stat.c +++ b/src/stat.c @@ -967,7 +967,7 @@ find_bind_mount (char const * name) for (me = mount_list; me; me = me->me_next) { if (me->me_dummy && me->me_devname[0] == '/' - && STREQ (me->me_mountdir, name)) + && streq (me->me_mountdir, name)) { struct stat dev_stats; @@ -1260,7 +1260,7 @@ do_statfs (char const *filename, char const *format) { STRUCT_STATVFS statfsbuf; - if (STREQ (filename, "-")) + if (streq (filename, "-")) { error (0, 0, _("using %s to denote standard input does not work" " in file system mode"), quoteaf (filename)); @@ -1367,7 +1367,7 @@ NODISCARD static bool do_stat (char const *filename, char const *format, char const *format2) { - int fd = STREQ (filename, "-") ? 0 : AT_FDCWD; + int fd = streq (filename, "-") ? 0 : AT_FDCWD; int flags = 0; struct stat st; struct statx stx = {0}; @@ -1456,7 +1456,7 @@ static bool do_stat (char const *filename, char const *format, char const *format2) { - int fd = STREQ (filename, "-") ? 0 : -1; + int fd = streq (filename, "-") ? 0 : -1; struct stat statbuf; struct print_args pa; pa.st = &statbuf; diff --git a/src/stdbuf.c b/src/stdbuf.c index b61ddf6a46..11b9a12f27 100644 --- a/src/stdbuf.c +++ b/src/stdbuf.c @@ -347,7 +347,7 @@ main (int argc, char **argv) usage (EXIT_CANCELED); } - if (!STREQ (optarg, "L") + if (!streq (optarg, "L") && parse_size (optarg, &stdbuf[opt_fileno].size) == -1) error (EXIT_CANCELED, errno, _("invalid mode %s"), quote (optarg)); diff --git a/src/stty.c b/src/stty.c index 3b2469a9b2..8032304bb4 100644 --- a/src/stty.c +++ b/src/stty.c @@ -1128,14 +1128,14 @@ apply_settings (bool checking, char const *device_name, ++arg; reversed = true; } - if (STREQ (arg, "drain")) + if (streq (arg, "drain")) { tcsetattr_options = reversed ? TCSANOW : TCSADRAIN; continue; } for (i = 0; mode_info[i].name != nullptr; ++i) { - if (STREQ (arg, mode_info[i].name)) + if (streq (arg, mode_info[i].name)) { if ((mode_info[i].flags & NO_SETATTR) == 0) { @@ -1156,7 +1156,7 @@ apply_settings (bool checking, char const *device_name, { for (i = 0; control_info[i].name != nullptr; ++i) { - if (STREQ (arg, control_info[i].name)) + if (streq (arg, control_info[i].name)) { check_argument (arg); match_found = true; @@ -1169,7 +1169,7 @@ apply_settings (bool checking, char const *device_name, } if (!match_found || not_set_attr) { - if (STREQ (arg, "ispeed")) + if (streq (arg, "ispeed")) { check_argument (arg); ++k; @@ -1183,7 +1183,7 @@ apply_settings (bool checking, char const *device_name, continue; *require_set_attr = true; } - else if (STREQ (arg, "ospeed")) + else if (streq (arg, "ospeed")) { check_argument (arg); ++k; @@ -1200,7 +1200,7 @@ apply_settings (bool checking, char const *device_name, #ifdef TIOCEXT /* This is the BSD interface to "extproc". Even though it's an lflag, an ioctl is used to set it. */ - else if (STREQ (arg, "extproc")) + else if (streq (arg, "extproc")) { int val = ! reversed; @@ -1213,7 +1213,7 @@ apply_settings (bool checking, char const *device_name, } #endif #ifdef TIOCGWINSZ - else if (STREQ (arg, "rows")) + else if (streq (arg, "rows")) { check_argument (arg); ++k; @@ -1222,8 +1222,8 @@ apply_settings (bool checking, char const *device_name, set_window_size (integer_arg (settings[k], INT_MAX), -1, device_name); } - else if (STREQ (arg, "cols") - || STREQ (arg, "columns")) + else if (streq (arg, "cols") + || streq (arg, "columns")) { check_argument (arg); ++k; @@ -1232,7 +1232,7 @@ apply_settings (bool checking, char const *device_name, set_window_size (-1, integer_arg (settings[k], INT_MAX), device_name); } - else if (STREQ (arg, "size")) + else if (streq (arg, "size")) { if (checking) continue; @@ -1242,7 +1242,7 @@ apply_settings (bool checking, char const *device_name, } #endif #ifdef HAVE_C_LINE - else if (STREQ (arg, "line")) + else if (streq (arg, "line")) { check_argument (arg); ++k; @@ -1253,7 +1253,7 @@ apply_settings (bool checking, char const *device_name, *require_set_attr = true; } #endif - else if (STREQ (arg, "speed")) + else if (streq (arg, "speed")) { if (checking) continue; @@ -1356,8 +1356,8 @@ main (int argc, char **argv) default: /* Consider "drain" as an option rather than a setting, to support: alias stty='stty -drain' etc. */ - if (! STREQ (argv[argi + opti], "-drain") - && ! STREQ (argv[argi + opti], "drain")) + if (! streq (argv[argi + opti], "-drain") + && ! streq (argv[argi + opti], "drain")) noargs = false; /* Skip the argument containing this unrecognized option; @@ -1497,21 +1497,21 @@ set_mode (struct mode_info const *info, bool reversed, struct termios *mode) if (bitsp == nullptr) { /* Combination mode. */ - if (STREQ (info->name, "evenp") || STREQ (info->name, "parity")) + if (streq (info->name, "evenp") || streq (info->name, "parity")) { if (reversed) mode->c_cflag = (mode->c_cflag & ~PARENB & ~CSIZE) | CS8; else mode->c_cflag = (mode->c_cflag & ~PARODD & ~CSIZE) | PARENB | CS7; } - else if (STREQ (info->name, "oddp")) + else if (streq (info->name, "oddp")) { if (reversed) mode->c_cflag = (mode->c_cflag & ~PARENB & ~CSIZE) | CS8; else mode->c_cflag = (mode->c_cflag & ~CSIZE) | CS7 | PARODD | PARENB; } - else if (STREQ (info->name, "nl")) + else if (streq (info->name, "nl")) { if (reversed) { @@ -1537,21 +1537,21 @@ set_mode (struct mode_info const *info, bool reversed, struct termios *mode) #endif } } - else if (STREQ (info->name, "ek")) + else if (streq (info->name, "ek")) { mode->c_cc[VERASE] = CERASE; mode->c_cc[VKILL] = CKILL; } - else if (STREQ (info->name, "sane")) + else if (streq (info->name, "sane")) sane_mode (mode); - else if (STREQ (info->name, "cbreak")) + else if (streq (info->name, "cbreak")) { if (reversed) mode->c_lflag |= ICANON; else mode->c_lflag &= ~ICANON; } - else if (STREQ (info->name, "pass8")) + else if (streq (info->name, "pass8")) { if (reversed) { @@ -1564,7 +1564,7 @@ set_mode (struct mode_info const *info, bool reversed, struct termios *mode) mode->c_iflag &= ~ISTRIP; } } - else if (STREQ (info->name, "litout")) + else if (streq (info->name, "litout")) { if (reversed) { @@ -1579,7 +1579,7 @@ set_mode (struct mode_info const *info, bool reversed, struct termios *mode) mode->c_oflag &= ~OPOST; } } - else if (STREQ (info->name, "raw") || STREQ (info->name, "cooked")) + else if (streq (info->name, "raw") || streq (info->name, "cooked")) { if ((info->name[0] == 'r' && reversed) || (info->name[0] == 'c' && !reversed)) @@ -1610,7 +1610,7 @@ set_mode (struct mode_info const *info, bool reversed, struct termios *mode) } } #ifdef IXANY - else if (STREQ (info->name, "decctlq")) + else if (streq (info->name, "decctlq")) { if (reversed) mode->c_iflag |= IXANY; @@ -1619,7 +1619,7 @@ set_mode (struct mode_info const *info, bool reversed, struct termios *mode) } #endif #ifdef TABDLY - else if (STREQ (info->name, "tabs")) + else if (streq (info->name, "tabs")) { if (reversed) mode->c_oflag = (mode->c_oflag & ~TABDLY) | TAB3; @@ -1628,7 +1628,7 @@ set_mode (struct mode_info const *info, bool reversed, struct termios *mode) } #else # ifdef OXTABS - else if (STREQ (info->name, "tabs")) + else if (streq (info->name, "tabs")) { if (reversed) mode->c_oflag = mode->c_oflag | OXTABS; @@ -1638,8 +1638,8 @@ set_mode (struct mode_info const *info, bool reversed, struct termios *mode) # endif #endif #if defined XCASE && defined IUCLC && defined OLCUC - else if (STREQ (info->name, "lcase") - || STREQ (info->name, "LCASE")) + else if (streq (info->name, "lcase") + || streq (info->name, "LCASE")) { if (reversed) { @@ -1655,7 +1655,7 @@ set_mode (struct mode_info const *info, bool reversed, struct termios *mode) } } #endif - else if (STREQ (info->name, "crt")) + else if (streq (info->name, "crt")) mode->c_lflag |= ECHOE #ifdef ECHOCTL | ECHOCTL @@ -1664,7 +1664,7 @@ set_mode (struct mode_info const *info, bool reversed, struct termios *mode) | ECHOKE #endif ; - else if (STREQ (info->name, "dec")) + else if (streq (info->name, "dec")) { mode->c_cc[VINTR] = 3; /* ^C */ mode->c_cc[VERASE] = 127; /* DEL */ @@ -1696,11 +1696,11 @@ set_control_char (struct control_info const *info, char const *arg, { unsigned long int value; - if (STREQ (info->name, "min") || STREQ (info->name, "time")) + if (streq (info->name, "min") || streq (info->name, "time")) value = integer_arg (arg, TYPE_MAXIMUM (cc_t)); else if (arg[0] == '\0' || arg[1] == '\0') value = to_uchar (arg[0]); - else if (STREQ (arg, "^-") || STREQ (arg, "undef")) + else if (streq (arg, "^-") || streq (arg, "undef")) value = _POSIX_VDISABLE; else if (arg[0] == '^' && arg[1] != '\0') /* Ignore any trailing junk. */ { @@ -1924,26 +1924,26 @@ display_changed (struct termios *mode) current_col = 0; empty_line = true; - for (i = 0; !STREQ (control_info[i].name, "min"); ++i) + for (i = 0; !streq (control_info[i].name, "min"); ++i) { if (mode->c_cc[control_info[i].offset] == control_info[i].saneval) continue; #ifdef VFLUSHO /* 'flush' is the deprecated equivalent of 'discard'. */ - if (STREQ (control_info[i].name, "flush")) + if (streq (control_info[i].name, "flush")) continue; #endif /* If swtch is the same as susp, don't print both. */ #if VSWTCH == VSUSP - if (STREQ (control_info[i].name, "swtch")) + if (streq (control_info[i].name, "swtch")) continue; #endif /* If eof uses the same slot as min, only print whichever applies. */ #if VEOF == VMIN if ((mode->c_lflag & ICANON) == 0 - && (STREQ (control_info[i].name, "eof") - || STREQ (control_info[i].name, "eol"))) + && (streq (control_info[i].name, "eof") + || streq (control_info[i].name, "eol"))) continue; #endif @@ -2016,23 +2016,23 @@ display_all (struct termios *mode, char const *device_name) putchar ('\n'); current_col = 0; - for (i = 0; ! STREQ (control_info[i].name, "min"); ++i) + for (i = 0; ! streq (control_info[i].name, "min"); ++i) { #ifdef VFLUSHO /* 'flush' is the deprecated equivalent of 'discard'. */ - if (STREQ (control_info[i].name, "flush")) + if (streq (control_info[i].name, "flush")) continue; #endif /* If swtch is the same as susp, don't print both. */ #if VSWTCH == VSUSP - if (STREQ (control_info[i].name, "swtch")) + if (streq (control_info[i].name, "swtch")) continue; #endif /* If eof uses the same slot as min, only print whichever applies. */ #if VEOF == VMIN if ((mode->c_lflag & ICANON) == 0 - && (STREQ (control_info[i].name, "eof") - || STREQ (control_info[i].name, "eol"))) + && (streq (control_info[i].name, "eof") + || streq (control_info[i].name, "eol"))) continue; #endif wrapf ("%s = %s;", control_info[i].name, @@ -2223,9 +2223,9 @@ string_to_baud (char const *arg) else if (c) { /* Not a valid number; check for legacy aliases "exta" and "extb" */ - if (STREQ (arg, "exta")) + if (streq (arg, "exta")) return B19200; - else if (STREQ (arg, "extb")) + else if (streq (arg, "extb")) return B38400; else return (speed_t) -1; @@ -2243,7 +2243,7 @@ sane_mode (struct termios *mode) for (i = 0; control_info[i].name; ++i) { #if VMIN == VEOF - if (STREQ (control_info[i].name, "min")) + if (streq (control_info[i].name, "min")) break; #endif mode->c_cc[control_info[i].offset] = control_info[i].saneval; diff --git a/src/system.h b/src/system.h index 2296c8bbb9..f37d4b811a 100644 --- a/src/system.h +++ b/src/system.h @@ -183,7 +183,6 @@ select_plural (uintmax_t n) return (n <= ULONG_MAX ? n : n % PLURAL_REDUCER + PLURAL_REDUCER); } -#define STREQ(a, b) (strcmp (a, b) == 0) #define STREQ_LEN(a, b, n) (strncmp (a, b, n) == 0) /* n==-1 means unbounded */ #define STRPREFIX(a, b) (strncmp (a, b, strlen (b)) == 0) @@ -652,7 +651,7 @@ emit_ancillary_info (char const *program) char const *node = program; struct infomap const *map_prog = infomap; - while (map_prog->program && ! STREQ (program, map_prog->program)) + while (map_prog->program && ! streq (program, map_prog->program)) map_prog++; if (map_prog->node) @@ -675,7 +674,7 @@ emit_ancillary_info (char const *program) /* .htaccess on the coreutils web site maps programs to the appropriate page, however we explicitly handle "[" -> "test" here as the "[" is not recognized as part of a URL by default in terminals. */ - char const *url_program = STREQ (program, "[") ? "test" : program; + char const *url_program = streq (program, "[") ? "test" : program; printf (_("Full documentation <%s%s>\n"), PACKAGE_URL, url_program); printf (_("or available locally via: info '(coreutils) %s%s'\n"), diff --git a/src/tac.c b/src/tac.c index 2779c2d2cd..e049331592 100644 --- a/src/tac.c +++ b/src/tac.c @@ -442,7 +442,7 @@ tac_file (char const *filename) bool ok; off_t file_size; int fd; - bool is_stdin = STREQ (filename, "-"); + bool is_stdin = streq (filename, "-"); if (is_stdin) { diff --git a/src/tail.c b/src/tail.c index 7539639377..b8bef1d91c 100644 --- a/src/tail.c +++ b/src/tail.c @@ -967,7 +967,7 @@ recheck (struct File_spec *f, bool blocking) { struct stat new_stats; bool ok = false; - bool is_stdin = (STREQ (f->name, "-")); + bool is_stdin = (streq (f->name, "-")); int prev_errnum = f->errnum; bool new_file; int fd = (is_stdin @@ -1377,7 +1377,7 @@ static bool tailable_stdin (const struct File_spec *f, int n_files) { for (int i = 0; i < n_files; i++) - if (!f[i].ignore && STREQ (f[i].name, "-")) + if (!f[i].ignore && streq (f[i].name, "-")) return true; return false; } @@ -1705,7 +1705,7 @@ tail_forever_inotify (int wd, struct File_spec *f, int n_files, /* With N=hundreds of frequently-changing files, this O(N^2) process might be a problem. FIXME: use a hash table? */ if (f[j].parent_wd == ev->wd - && STREQ (ev->name, f[j].name + f[j].basename_start)) + && streq (ev->name, f[j].name + f[j].basename_start)) break; } @@ -1966,7 +1966,7 @@ tail_file (struct File_spec *f, count_t n_files, count_t n_units) /* Avoid blocking if we may need to process asynchronously. */ bool nonblocking = forever && (nbpids || n_files > 1); - bool is_stdin = (STREQ (f->name, "-")); + bool is_stdin = (streq (f->name, "-")); if (is_stdin) { @@ -2073,7 +2073,7 @@ parse_obsolete_option (int argc, char * const *argv, count_t *n_units) one file argument. Watch out for "-" and "--", though. */ if (! (argc == 2 || (argc == 3 && ! (argv[2][0] == '-' && argv[2][1])) - || (3 <= argc && argc <= 4 && STREQ (argv[2], "--")))) + || (3 <= argc && argc <= 4 && streq (argv[2], "--")))) return false; int posix_ver = posix2_version (); @@ -2287,7 +2287,7 @@ ignore_fifo_and_pipe (struct File_spec *f, int n_files) for (int i = 0; i < n_files; i++) { bool is_a_fifo_or_pipe = - (STREQ (f[i].name, "-") + (streq (f[i].name, "-") && !f[i].ignore && 0 <= f[i].fd && (S_ISFIFO (f[i].mode) @@ -2369,7 +2369,7 @@ main (int argc, char **argv) bool found_hyphen = false; for (int i = 0; i < n_files; i++) - if (STREQ (file[i], "-")) + if (streq (file[i], "-")) found_hyphen = true; /* When following by name, there must be a name. */ @@ -2404,7 +2404,7 @@ main (int argc, char **argv) for (int i = 0; i < n_files; i++) { F[i].name = file[i]; - F[i].prettyname = STREQ (file[i], "-") ? _("standard input") : file[i]; + F[i].prettyname = streq (file[i], "-") ? _("standard input") : file[i]; } if (header_mode == always diff --git a/src/test.c b/src/test.c index 61bf8b7412..c11542922f 100644 --- a/src/test.c +++ b/src/test.c @@ -186,20 +186,20 @@ get_mtime (char const *filename) static int binop (char const *s) { - return ( STREQ (s, "=" ) ? EQ_STRING_BINOP - : STREQ (s, "==" ) ? EQ_STRING_BINOP /* an alias for = */ - : STREQ (s, "!=" ) ? NE_STRING_BINOP - : STREQ (s, ">" ) ? GT_STRING_BINOP - : STREQ (s, "<" ) ? LT_STRING_BINOP - : STREQ (s, "-eq") ? EQ_BINOP - : STREQ (s, "-ne") ? NE_BINOP - : STREQ (s, "-lt") ? LT_BINOP - : STREQ (s, "-le") ? LE_BINOP - : STREQ (s, "-gt") ? GT_BINOP - : STREQ (s, "-ge") ? GE_BINOP - : STREQ (s, "-ot") ? OT_BINOP - : STREQ (s, "-nt") ? NT_BINOP - : STREQ (s, "-ef") ? EF_BINOP + return ( streq (s, "=" ) ? EQ_STRING_BINOP + : streq (s, "==" ) ? EQ_STRING_BINOP /* an alias for = */ + : streq (s, "!=" ) ? NE_STRING_BINOP + : streq (s, ">" ) ? GT_STRING_BINOP + : streq (s, "<" ) ? LT_STRING_BINOP + : streq (s, "-eq") ? EQ_BINOP + : streq (s, "-ne") ? NE_BINOP + : streq (s, "-lt") ? LT_BINOP + : streq (s, "-le") ? LE_BINOP + : streq (s, "-gt") ? GT_BINOP + : streq (s, "-ge") ? GE_BINOP + : streq (s, "-ot") ? OT_BINOP + : streq (s, "-nt") ? NT_BINOP + : streq (s, "-ef") ? EF_BINOP : -1); } @@ -246,7 +246,7 @@ term (void) advance (true); for (nargs = 1; - pos + nargs < argc && ! STREQ (argv[pos + nargs], ")"); + pos + nargs < argc && ! streq (argv[pos + nargs], ")"); nargs++) if (nargs == 4) { @@ -265,7 +265,7 @@ term (void) } /* Are there enough arguments left that this could be dyadic? */ - else if (4 <= argc - pos && STREQ (argv[pos], "-l") + else if (4 <= argc - pos && streq (argv[pos], "-l") && 0 <= (bop = binop (argv[pos + 2]))) value = binary_operator (true, bop); else if (3 <= argc - pos @@ -294,7 +294,7 @@ binary_operator (bool l_is_l, enum binop bop) op = pos + 1; /* Is the right integer expression of the form '-l string'? */ - bool r_is_l = op < argc - 2 && STREQ (argv[op + 1], "-l"); + bool r_is_l = op < argc - 2 && streq (argv[op + 1], "-l"); if (r_is_l) advance (false); @@ -349,7 +349,7 @@ binary_operator (bool l_is_l, enum binop bop) case EQ_STRING_BINOP: case NE_STRING_BINOP: - return STREQ (argv[op - 1], argv[op + 1]) == (bop == EQ_STRING_BINOP); + return streq (argv[op - 1], argv[op + 1]) == (bop == EQ_STRING_BINOP); case GT_STRING_BINOP: case LT_STRING_BINOP: @@ -519,7 +519,7 @@ and (void) while (true) { value &= term (); - if (! (pos < argc && STREQ (argv[pos], "-a"))) + if (! (pos < argc && streq (argv[pos], "-a"))) return value; advance (false); } @@ -538,7 +538,7 @@ or (void) while (true) { value |= and (); - if (! (pos < argc && STREQ (argv[pos], "-o"))) + if (! (pos < argc && streq (argv[pos], "-o"))) return value; advance (false); } @@ -568,7 +568,7 @@ two_arguments (void) { bool value; - if (STREQ (argv[pos], "!")) + if (streq (argv[pos], "!")) { advance (false); value = ! one_argument (); @@ -592,19 +592,19 @@ three_arguments (void) if (0 <= bop) value = binary_operator (false, bop); - else if (STREQ (argv[pos], "!")) + else if (streq (argv[pos], "!")) { advance (true); value = !two_arguments (); } - else if (STREQ (argv[pos], "(") && STREQ (argv[pos + 2], ")")) + else if (streq (argv[pos], "(") && streq (argv[pos + 2], ")")) { advance (false); value = one_argument (); advance (false); } - else if (STREQ (argv[pos + 1], "-a") || STREQ (argv[pos + 1], "-o") - || STREQ (argv[pos + 1], ">") || STREQ (argv[pos + 1], "<")) + else if (streq (argv[pos + 1], "-a") || streq (argv[pos + 1], "-o") + || streq (argv[pos + 1], ">") || streq (argv[pos + 1], "<")) value = expr (); else test_syntax_error (_("%s: binary operator expected"), @@ -633,13 +633,13 @@ posixtest (int nargs) break; case 4: - if (STREQ (argv[pos], "!")) + if (streq (argv[pos], "!")) { advance (true); value = !three_arguments (); break; } - if (STREQ (argv[pos], "(") && STREQ (argv[pos + 3], ")")) + if (streq (argv[pos], "(") && streq (argv[pos + 3], ")")) { advance (false); value = two_arguments (); @@ -815,17 +815,17 @@ main (int margc, char **margv) and "test --version" to exit silently with status 0. */ if (margc == 2) { - if (STREQ (margv[1], "--help")) + if (streq (margv[1], "--help")) usage (EXIT_SUCCESS); - if (STREQ (margv[1], "--version")) + if (streq (margv[1], "--version")) { version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS, (char *) nullptr); test_main_return (EXIT_SUCCESS); } } - if (margc < 2 || !STREQ (margv[margc - 1], "]")) + if (margc < 2 || !streq (margv[margc - 1], "]")) test_syntax_error (_("missing %s"), quote ("]")); --margc; diff --git a/src/touch.c b/src/touch.c index 2b54808b7c..bc6b23840e 100644 --- a/src/touch.c +++ b/src/touch.c @@ -124,7 +124,7 @@ touch (char const *file) int open_errno = 0; struct timespec const *t = newtime; - if (STREQ (file, "-")) + if (streq (file, "-")) fd = STDOUT_FILENO; else if (! (no_create || no_dereference)) { diff --git a/src/true.c b/src/true.c index 3ce0005fa4..34406b66d1 100644 --- a/src/true.c +++ b/src/true.c @@ -68,10 +68,10 @@ main (int argc, char **argv) edge case where writes fail with GNU specific options. */ atexit (close_stdout); - if (STREQ (argv[1], "--help")) + if (streq (argv[1], "--help")) usage (EXIT_STATUS); - if (STREQ (argv[1], "--version")) + if (streq (argv[1], "--version")) version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS, (char *) nullptr); } diff --git a/src/tsort.c b/src/tsort.c index dcbfdc24fd..7aff3e29aa 100644 --- a/src/tsort.c +++ b/src/tsort.c @@ -265,7 +265,7 @@ record_relation (struct item *j, struct item *k) { struct successor *p; - if (!STREQ (j->str, k->str)) + if (!streq (j->str, k->str)) { k->count++; p = xmalloc (sizeof *p); @@ -432,7 +432,7 @@ tsort (char const *file) struct item *j = nullptr; struct item *k = nullptr; token_buffer tokenbuffer; - bool is_stdin = STREQ (file, "-"); + bool is_stdin = streq (file, "-"); /* Initialize the head of the tree holding the strings we're sorting. */ struct item *root = new_item (nullptr); diff --git a/src/uniq.c b/src/uniq.c index 9aa780574b..bce1949f31 100644 --- a/src/uniq.c +++ b/src/uniq.c @@ -322,9 +322,9 @@ check_file (char const *infile, char const *outfile, char delimiter) struct linebuffer lb1, lb2; struct linebuffer *thisline, *prevline; - if (! (STREQ (infile, "-") || freopen (infile, "r", stdin))) + if (! (streq (infile, "-") || freopen (infile, "r", stdin))) error (EXIT_FAILURE, errno, "%s", quotef (infile)); - if (! (STREQ (outfile, "-") || freopen (outfile, "w", stdout))) + if (! (streq (outfile, "-") || freopen (outfile, "w", stdout))) error (EXIT_FAILURE, errno, "%s", quotef (outfile)); fadvise (stdin, FADVISE_SEQUENTIAL); diff --git a/src/wc.c b/src/wc.c index 5f974e1c0f..777277f23d 100644 --- a/src/wc.c +++ b/src/wc.c @@ -623,7 +623,7 @@ wc (int fd, char const *file_x, struct fstatus *fstatus) static bool wc_file (char const *file, struct fstatus *fstatus) { - if (! file || STREQ (file, "-")) + if (! file || streq (file, "-")) { have_read_stdin = true; xset_binary_mode (STDIN_FILENO, O_BINARY); @@ -670,7 +670,7 @@ get_input_fstatus (idx_t nfiles, char *const *file) else { for (idx_t i = 0; i < nfiles; i++) - fstatus[i].failed = (! file[i] || STREQ (file[i], "-") + fstatus[i].failed = (! file[i] || streq (file[i], "-") ? fstat (STDIN_FILENO, &fstatus[i].st) : stat (file[i], &fstatus[i].st)); } @@ -815,7 +815,7 @@ main (int argc, char **argv) usage (EXIT_FAILURE); } - if (STREQ (files_from, "-")) + if (streq (files_from, "-")) stream = stdin; else { @@ -871,7 +871,7 @@ main (int argc, char **argv) for (int i = 0; (file_name = argv_iter (ai, &ai_err)); i++) { bool skip_file = false; - if (files_from && STREQ (files_from, "-") && STREQ (file_name, "-")) + if (files_from && streq (files_from, "-") && streq (file_name, "-")) { /* Give a better diagnostic in an unusual case: printf - | wc --files0-from=- */ diff --git a/tests/df/no-mtab-status.sh b/tests/df/no-mtab-status.sh index 47105a13ae..0c2e8982d5 100755 --- a/tests/df/no-mtab-status.sh +++ b/tests/df/no-mtab-status.sh @@ -39,8 +39,6 @@ cat > k.c < #include -#define STREQ(a, b) (strcmp (a, b) == 0) - int open(const char *path, int flags, ...) { static int (*open_func)(const char *, int, ...); @@ -67,7 +65,7 @@ int open(const char *path, int flags, ...) /* Returning ENOENT here will get read_file_system_list() to fall back to using getmntent() below. */ - if (STREQ (path, "/proc/self/mountinfo")) + if (streq (path, "/proc/self/mountinfo")) { errno = ENOENT; return -1; diff --git a/tests/df/skip-duplicates.sh b/tests/df/skip-duplicates.sh index 644f2e027e..f97f794f54 100755 --- a/tests/df/skip-duplicates.sh +++ b/tests/df/skip-duplicates.sh @@ -49,8 +49,6 @@ cat > k.c < #include -#define STREQ(a, b) (strcmp (a, b) == 0) - int open(const char *path, int flags, ...) { static int (*open_func)(const char *, int, ...); @@ -77,7 +75,7 @@ int open(const char *path, int flags, ...) /* Returning ENOENT here will get read_file_system_list() to fall back to using getmntent() below. */ - if (STREQ (path, "/proc/self/mountinfo")) + if (streq (path, "/proc/self/mountinfo")) { errno = ENOENT; return -1; @@ -86,8 +84,6 @@ int open(const char *path, int flags, ...) return open_func(path, flags, mode); } -#define STREQ(a, b) (strcmp (a, b) == 0) - struct mntent *getmntent (FILE *fp) { static char *nonroot_fs; @@ -132,9 +128,9 @@ struct mntent *getmntent (FILE *fp) mntents[done-2].mnt_type = "-"; if (!mntents[done-2].mnt_opts) mntents[done-2].mnt_opts = "-"; - if (STREQ (mntents[done-2].mnt_dir, "/NONROOT")) + if (streq (mntents[done-2].mnt_dir, "/NONROOT")) mntents[done-2].mnt_dir = nonroot_fs; - if (STREQ (mntents[done-2].mnt_dir, "/REMOTE")) + if (streq (mntents[done-2].mnt_dir, "/REMOTE")) { if (!remote_fs || !*remote_fs) continue; -- 2.47.3