[BACK]Return to wc.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / wc

Diff for /src/usr.bin/wc/wc.c between version 1.27 and 1.28

version 1.27, 2021/10/24 21:24:18 version 1.28, 2021/11/16 23:34:24
Line 48 
Line 48 
 int     rval;  int     rval;
 extern char *__progname;  extern char *__progname;
   
 static void print_counts(int64_t, int64_t, int64_t, char *);  static void print_counts(int64_t, int64_t, int64_t, const char *);
 static void format_and_print(int64_t);  static void format_and_print(int64_t);
 static void cnt(char *);  static void cnt(const char *);
   
 int  int
 main(int argc, char *argv[])  main(int argc, char *argv[])
Line 115 
Line 115 
 }  }
   
 static void  static void
 cnt(char *file)  cnt(const char *path)
 {  {
         static char *buf;          static char *buf;
         static size_t bufsz;          static size_t bufsz;
   
         FILE *stream;          FILE *stream;
           const char *file;
         char *C;          char *C;
         wchar_t wc;          wchar_t wc;
         short gotsp;          short gotsp;
Line 131 
Line 132 
   
         linect = wordct = charct = 0;          linect = wordct = charct = 0;
         stream = NULL;          stream = NULL;
         if (file) {          if (path != NULL) {
                   file = path;
                 if ((fd = open(file, O_RDONLY)) == -1) {                  if ((fd = open(file, O_RDONLY)) == -1) {
                         warn("%s", file);                          warn("%s", file);
                         rval = 1;                          rval = 1;
                         return;                          return;
                 }                  }
         } else  {          } else  {
                   file = "(stdin)";
                 fd = STDIN_FILENO;                  fd = STDIN_FILENO;
         }          }
   
Line 191 
Line 194 
                         }                          }
                 }                  }
         } else {          } else {
                 if (file == NULL)                  if (path == NULL)
                         stream = stdin;                          stream = stdin;
                 else if ((stream = fdopen(fd, "r")) == NULL) {                  else if ((stream = fdopen(fd, "r")) == NULL) {
                         warn("%s", file);                          warn("%s", file);
Line 249 
Line 252 
                 }                  }
         }          }
   
         print_counts(linect, wordct, charct, file);          print_counts(linect, wordct, charct, path);
   
         /*          /*
          * Don't bother checking doline, doword, or dochar -- speeds           * Don't bother checking doline, doword, or dochar -- speeds
Line 279 
Line 282 
 }  }
   
 static void  static void
 print_counts(int64_t lines, int64_t words, int64_t chars, char *name)  print_counts(int64_t lines, int64_t words, int64_t chars, const char *name)
 {  {
         if (doline)          if (doline)
                 format_and_print(lines);                  format_and_print(lines);

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.28