]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Use STREQ rather than strcmp
authorJim Meyering <jim@meyering.net>
Sun, 12 Apr 1998 09:27:45 +0000 (09:27 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 12 Apr 1998 09:27:45 +0000 (09:27 +0000)
18 files changed:
src/cat.c
src/cksum.c
src/comm.c
src/csplit.c
src/cut.c
src/fmt.c
src/fold.c
src/head.c
src/join.c
src/md5sum.c
src/nl.c
src/paste.c
src/pr.c
src/split.c
src/sum.c
src/tac.c
src/uniq.c
src/wc.c

index 7e8e54ad8279397ea8771fdab94c4bef32b899e2..8420d717210d962ad744f48ebc3f3915a30a6f45 100644 (file)
--- a/src/cat.c
+++ b/src/cat.c
@@ -722,7 +722,7 @@ main (int argc, char **argv)
       free (inbuf);
 
     contin:
-      if (strcmp (infile, "-") && close (input_desc) < 0)
+      if (!STREQ (infile, "-") && close (input_desc) < 0)
        {
          error (0, errno, "%s", infile);
          exit_status = 1;
index 77588fd036dc182f009436fa787cc0284f0a867f..e34499f5919c2372444cb41744e926456a654e23 100644 (file)
@@ -1,5 +1,5 @@
 /* cksum -- calculate and print POSIX.2 checksums and sizes of files
-   Copyright (C) 92, 95, 96, 1997 Free Software Foundation, Inc.
+   Copyright (C) 92, 95, 96, 1997, 1998 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -202,7 +202,7 @@ cksum (char *file, int print_name)
   long bytes_read;
   register FILE *fp;
 
-  if (!strcmp (file, "-"))
+  if (STREQ (file, "-"))
     {
       fp = stdin;
       have_read_stdin = 1;
@@ -229,12 +229,12 @@ cksum (char *file, int print_name)
   if (ferror (fp))
     {
       error (0, errno, "%s", file);
-      if (strcmp (file, "-"))
+      if (!STREQ (file, "-"))
        fclose (fp);
       return -1;
     }
 
-  if (strcmp (file, "-") && fclose (fp) == EOF)
+  if (!STREQ (file, "-") && fclose (fp) == EOF)
     {
       error (0, errno, "%s", file);
       return -1;
index 777551e05908e0709c98319199ab0441f4cfbb8d..20e232a26c5f7c68b151401d3524e08098c486c9 100644 (file)
@@ -1,5 +1,5 @@
 /* comm -- compare two sorted files line by line.
-   Copyright (C) 86, 90, 91, 95, 96, 1997 Free Software Foundation, Inc.
+   Copyright (C) 86, 90, 91, 95, 96, 1997, 1998 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -148,8 +148,7 @@ compare_files (char **infiles)
     {
       initbuffer (&lb1[i]);
       thisline[i] = &lb1[i];
-      streams[i] = strcmp (infiles[i], "-")
-       ? fopen (infiles[i], "r") : stdin;
+      streams[i] = (STREQ (infiles[i], "-") ? stdin : fopen (infiles[i], "r"));
       if (!streams[i])
        {
          error (0, errno, "%s", infiles[i]);
index d56ab7481f741a90412e6d93c74f732badd01e42..0e3d1068a2998208cf9b7eda0d174587da77ebe4 100644 (file)
@@ -689,7 +689,7 @@ no_more_lines (void)
 static void
 set_input_file (const char *name)
 {
-  if (!strcmp (name, "-"))
+  if (STREQ (name, "-"))
     input_desc = 0;
   else
     {
index f5a79df59c7e38663acbba4e2214b213a6b9106f..e05c799b2ff9b87a75ac1634cfd48b8ed0c0b522 100644 (file)
--- a/src/cut.c
+++ b/src/cut.c
@@ -1,5 +1,5 @@
 /* cut - remove parts of lines of files
-   Copyright (C) 1984, 1997 by David M. Ihnat
+   Copyright (C) 1984, 1997, 1998 by David M. Ihnat
 
    This program is a total rewrite of the Bell Laboratories Unix(Tm)
    command of the same name, as of System V.  It contains no proprietary
@@ -644,7 +644,7 @@ cut_file (char *file)
 {
   FILE *stream;
 
-  if (!strcmp (file, "-"))
+  if (STREQ (file, "-"))
     {
       have_read_stdin = 1;
       stream = stdin;
@@ -666,7 +666,7 @@ cut_file (char *file)
       error (0, errno, "%s", file);
       return 1;
     }
-  if (!strcmp (file, "-"))
+  if (STREQ (file, "-"))
     clearerr (stream);         /* Also clear EOF. */
   else if (fclose (stream) == EOF)
     {
index 613cf5186b37acf419a9d8cbe5bd800947be9bb4..f3afaef915356e05a139a8d6d382bf557bf8ed17 100644 (file)
--- a/src/fmt.c
+++ b/src/fmt.c
@@ -400,7 +400,7 @@ main (register int argc, register char **argv)
       for (; optind < argc; optind++)
        {
          char *file = argv[optind];
-         if (strcmp (file, "-") == 0)
+         if (STREQ (file, "-"))
            fmt (stdin);
          else
            {
index 7e4cb57aa2f3cf9d8816c26646767770dd4eb667..44233d502318ee3d1a86d873b0d7c384386b4bdd 100644 (file)
@@ -123,7 +123,7 @@ fold_file (char *filename, int width)
   static char *line_out = NULL;
   static int allocated_out = 0;
 
-  if (!strcmp (filename, "-"))
+  if (STREQ (filename, "-"))
     {
       istream = stdin;
       have_read_stdin = 1;
@@ -212,11 +212,11 @@ fold_file (char *filename, int width)
   if (ferror (istream))
     {
       error (0, errno, "%s", filename);
-      if (strcmp (filename, "-"))
+      if (!STREQ (filename, "-"))
        fclose (istream);
       return 1;
     }
-  if (strcmp (filename, "-") && fclose (istream) == EOF)
+  if (!STREQ (filename, "-") && fclose (istream) == EOF)
     {
       error (0, errno, "%s", filename);
       return 1;
index 42f76e423f0ca157890ba21da19f405fd8ea453f..3052df19785452a16b4ff0b73ce4ba127a1fb35c 100644 (file)
@@ -184,7 +184,7 @@ head_file (const char *filename, U_LONG_LONG n_units, int count_lines)
 {
   int fd;
 
-  if (!strcmp (filename, "-"))
+  if (STREQ (filename, "-"))
     {
       have_read_stdin = 1;
       filename = _("standard input");
index 0c1207ddfedb7dc5efc0fb9baa96271c5b1503db..7e0e1205a0800033ba64dffac947265727f272a2 100644 (file)
@@ -843,10 +843,10 @@ main (int argc, char **argv)
       usage (1);
     }
 
-  fp1 = strcmp (names[0], "-") ? fopen (names[0], "r") : stdin;
+  fp1 = STREQ (names[0], "-") ? stdin : fopen (names[0], "r");
   if (!fp1)
     error (EXIT_FAILURE, errno, "%s", names[0]);
-  fp2 = strcmp (names[1], "-") ? fopen (names[1], "r") : stdin;
+  fp2 = STREQ (names[1], "-") ? stdin : fopen (names[1], "r");
   if (!fp2)
     error (EXIT_FAILURE, errno, "%s", names[1]);
   if (fp1 == fp2)
index 11cd0c1faf0052d2a282542f2e8758b3f9939e96..1700563fd59e39ab3df478cd4cecb815a8b021a7 100644 (file)
@@ -1,6 +1,6 @@
 /* Compute MD5 checksum of files or strings according to the definition
    of MD5 in RFC 1321 from April 1992.
-   Copyright (C) 95, 96, 1997 Free Software Foundation, Inc.
+   Copyright (C) 95, 96, 1997, 1998 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -240,7 +240,7 @@ md5_file (const char *filename, int binary, unsigned char *md5_result)
   FILE *fp;
   int err;
 
-  if (strcmp (filename, "-") == 0)
+  if (STREQ (filename, "-"))
     {
       have_read_stdin = 1;
       fp = stdin;
@@ -289,7 +289,7 @@ md5_check (const char *checkfile_name)
   char *line;
   size_t line_chars_allocated;
 
-  if (strcmp (checkfile_name, "-") == 0)
+  if (STREQ (checkfile_name, "-"))
     {
       have_read_stdin = 1;
       checkfile_name = _("standard input");
index f8edb8fe2a89745fce9965243a693fcc65476d71..6a7fab2599d7a1679e5d6f2240591ccf1e8063b7 100644 (file)
--- a/src/nl.c
+++ b/src/nl.c
@@ -414,7 +414,7 @@ nl_file (const char *file)
 {
   FILE *stream;
 
-  if (!strcmp (file, "-"))
+  if (STREQ (file, "-"))
     {
       have_read_stdin = 1;
       stream = stdin;
@@ -436,7 +436,7 @@ nl_file (const char *file)
       error (0, errno, "%s", file);
       return 1;
     }
-  if (!strcmp (file, "-"))
+  if (STREQ (file, "-"))
     clearerr (stream);         /* Also clear EOF. */
   else if (fclose (stream) == EOF)
     {
index a623966d14aab4acc2136d69646fb46a20cee5dc..9f9850972b0ecdec2f923c9259fa0d0b58c2ff23 100644 (file)
@@ -1,5 +1,5 @@
 /* paste - merge lines of files
-   Copyright (C) 1984, 1997 by David M. Ihnat
+   Copyright (C) 1984, 1997, 1998 by David M. Ihnat
 
    This program is a total rewrite of the Bell Laboratories Unix(Tm)
    command of the same name, as of System V.  It contains no proprietary
@@ -194,7 +194,7 @@ paste_parallel (int nfiles, char **fnamptr)
          fileptr = (FILE **) xrealloc ((char *) fileptr, (file_list_size + 1)
                                        * sizeof (FILE *));
        }
-      if (!strcmp (fnamptr[files_open], "-"))
+      if (STREQ (fnamptr[files_open], "-"))
        {
          have_read_stdin = 1;
          fileptr[files_open] = stdin;
@@ -332,7 +332,7 @@ paste_serial (int nfiles, char **fnamptr)
 
   for (; nfiles; nfiles--, fnamptr++)
     {
-      if (!strcmp (*fnamptr, "-"))
+      if (STREQ (*fnamptr, "-"))
        {
          have_read_stdin = 1;
          fileptr = stdin;
index a7e69e92a0547fb9ea01b4c8c53f4c7fe1421742..c03684cce5791c3155dd268901cad6f4f3184141 100644 (file)
--- a/src/pr.c
+++ b/src/pr.c
@@ -1192,7 +1192,7 @@ init_funcs (void)
 static int
 open_file (char *name, COLUMN *p)
 {
-  if (!strcmp (name, "-"))
+  if (STREQ (name, "-"))
     {
       p->name = _("standard input");
       p->fp = stdin;
@@ -1376,7 +1376,7 @@ init_header (char *filename, int desc)
       char t_buf[T_BUF_SIZE];
 
       /* If parallel files or standard input, use current time. */
-      if (desc < 0 || !strcmp (filename, "-") || fstat (desc, &st))
+      if (desc < 0 || STREQ (filename, "-") || fstat (desc, &st))
        st.st_mtime = time (NULL);
 
       tmptr = localtime (&st.st_mtime);
index bce8b8d3c634f085841c5bf062fe2bda67068a59..a6624d9433d499a3bdb19743310be9268946fe09 100644 (file)
@@ -486,7 +486,7 @@ main (int argc, char **argv)
     }
 
   /* Open the input file.  */
-  if (!strcmp (infile, "-"))
+  if (STREQ (infile, "-"))
     input_desc = 0;
   else
     {
index 0e0fdebcd6678d69cd1092f4bac1b63033aaa687..de3dfe15ad65d24cfea05b44ba273db73149fdeb 100644 (file)
--- a/src/sum.c
+++ b/src/sum.c
@@ -92,7 +92,7 @@ bsd_sum_file (const char *file, int print_name)
   register long total_bytes = 0; /* The number of bytes. */
   register int ch;             /* Each character read. */
 
-  if (!strcmp (file, "-"))
+  if (STREQ (file, "-"))
     {
       fp = stdin;
       have_read_stdin = 1;
@@ -118,12 +118,12 @@ bsd_sum_file (const char *file, int print_name)
   if (ferror (fp))
     {
       error (0, errno, "%s", file);
-      if (strcmp (file, "-"))
+      if (!STREQ (file, "-"))
        fclose (fp);
       return -1;
     }
 
-  if (strcmp (file, "-") && fclose (fp) == EOF)
+  if (!STREQ (file, "-") && fclose (fp) == EOF)
     {
       error (0, errno, "%s", file);
       return -1;
@@ -151,7 +151,7 @@ sysv_sum_file (const char *file, int print_name)
   register unsigned long checksum = 0;
   long total_bytes = 0;
 
-  if (!strcmp (file, "-"))
+  if (STREQ (file, "-"))
     {
       fd = 0;
       have_read_stdin = 1;
@@ -178,12 +178,12 @@ sysv_sum_file (const char *file, int print_name)
   if (bytes_read < 0)
     {
       error (0, errno, "%s", file);
-      if (strcmp (file, "-"))
+      if (!STREQ (file, "-"))
        close (fd);
       return -1;
     }
 
-  if (strcmp (file, "-") && close (fd) == -1)
+  if (!STREQ (file, "-") && close (fd) == -1)
     {
       error (0, errno, "%s", file);
       return -1;
index f281c45f338ecca024b649eedeca32bfce2ad964..416ab64aee26156462d42dc3510ac4bfdf0cc9c9 100644 (file)
--- a/src/tac.c
+++ b/src/tac.c
@@ -638,7 +638,7 @@ main (int argc, char **argv)
   else
     for (; optind < argc; ++optind)
       {
-       if (strcmp (argv[optind], "-") == 0)
+       if (STREQ (argv[optind], "-"))
          {
            have_read_stdin = 1;
            errors |= tac_stdin_to_mem ();
index 176c865717b60708862a305ef8151b059db7aff7..27395afd34e7add56af766abc298ea6b42d1fa84 100644 (file)
@@ -216,14 +216,14 @@ check_file (const char *infile, const char *outfile)
   int prevlen, thislen;
   int match_count = 0;
 
-  if (!strcmp (infile, "-"))
+  if (STREQ (infile, "-"))
     istream = stdin;
   else
     istream = fopen (infile, "r");
   if (istream == NULL)
     error (EXIT_FAILURE, errno, "%s", infile);
 
-  if (!strcmp (outfile, "-"))
+  if (STREQ (outfile, "-"))
     ostream = stdout;
   else
     ostream = fopen (outfile, "w");
@@ -379,7 +379,7 @@ main (int argc, char **argv)
   if (show_help)
     usage (0);
 
-  if (optind >= 2 && strcmp (argv[optind - 1], "--") != 0)
+  if (optind >= 2 && !STREQ (argv[optind - 1], "--"))
     {
       /* Interpret non-option arguments with leading `+' only
         if we haven't seen `--'.  */
index 94079684d8c4ef61f94196585827ee26b010c85c..15a38917a306364d05ff4e1361ca6db985ca4dbe 100644 (file)
--- a/src/wc.c
+++ b/src/wc.c
@@ -267,7 +267,7 @@ wc (int fd, const char *file)
 static void
 wc_file (const char *file)
 {
-  if (!strcmp (file, "-"))
+  if (STREQ (file, "-"))
     {
       have_read_stdin = 1;
       wc (0, file);