Compare getopt_long return value against -1, not EOF. Use NULL, not '(int *) 0'...
authorJim Meyering <jim@meyering.net>
Sat, 1 Feb 1997 02:00:04 +0000 (02:00 +0000)
committerJim Meyering <jim@meyering.net>
Sat, 1 Feb 1997 02:00:04 +0000 (02:00 +0000)
21 files changed:
src/cat.c
src/cksum.c
src/comm.c
src/csplit.c
src/cut.c
src/expand.c
src/fmt.c
src/fold.c
src/head.c
src/join.c
src/md5sum.c
src/nl.c
src/od.c
src/paste.c
src/sum.c
src/tac.c
src/tail.c
src/tr.c
src/unexpand.c
src/uniq.c
src/wc.c

index d8594cb..186cc98 100644 (file)
--- a/src/cat.c
+++ b/src/cat.c
@@ -512,8 +512,7 @@ main (int argc, char **argv)
 
   /* Parse command line options.  */
 
-  while ((c = getopt_long (argc, argv, "benstuvAET", long_options, (int *) 0))
-        != EOF)
+  while ((c = getopt_long (argc, argv, "benstuvAET", long_options, NULL)) != -1)
     {
       switch (c)
        {
index 2318d5b..c3f06eb 100644 (file)
@@ -293,7 +293,7 @@ main (int argc, char **argv)
 
   have_read_stdin = 0;
 
-  while ((c = getopt_long (argc, argv, "", long_options, (int *) 0)) != EOF)
+  while ((c = getopt_long (argc, argv, "", long_options, NULL)) != -1)
     {
       switch (c)
        {
index b329e46..c11953e 100644 (file)
@@ -226,7 +226,7 @@ main (int argc, char **argv)
   only_file_2 = 1;
   both = 1;
 
-  while ((c = getopt_long (argc, argv, "123", long_options, (int *) 0)) != EOF)
+  while ((c = getopt_long (argc, argv, "123", long_options, NULL)) != -1)
     switch (c)
       {
       case 0:
index ddd4311..08546f3 100644 (file)
@@ -1476,8 +1476,7 @@ main (int argc, char **argv)
     signal (SIGTERM, interrupt_handler);
 #endif /* not SA_INTERRUPT */
 
-  while ((optc = getopt_long (argc, argv, "f:b:kn:sqz", longopts, (int *) 0))
-        != EOF)
+  while ((optc = getopt_long (argc, argv, "f:b:kn:sqz", longopts, NULL)) != -1)
     switch (optc)
       {
       case 0:
index 59711a0..991baa9 100644 (file)
--- a/src/cut.c
+++ b/src/cut.c
@@ -688,8 +688,7 @@ main (int argc, char **argv)
   delim = '\0';
   have_read_stdin = 0;
 
-  while ((optc = getopt_long (argc, argv, "b:c:d:f:ns", longopts, (int *) 0))
-        != EOF)
+  while ((optc = getopt_long (argc, argv, "b:c:d:f:ns", longopts, NULL)) != -1)
     {
       switch (optc)
        {
index 9beb877..2b52525 100644 (file)
@@ -338,8 +338,7 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
-  while ((c = getopt_long (argc, argv, "it:,0123456789", longopts, (int *) 0))
-        != EOF)
+  while ((c = getopt_long (argc, argv, "it:,0123456789", longopts, NULL)) != -1)
     {
       switch (c)
        {
index b8de757..3830880 100644 (file)
--- a/src/fmt.c
+++ b/src/fmt.c
@@ -353,7 +353,7 @@ main (register int argc, register char **argv)
 
   while ((optchar = getopt_long (argc, argv, "0123456789cstuw:p:",
                                 long_options, NULL))
-        != EOF)
+        != -1)
     switch (optchar)
       {
       default:
index b868102..8d63499 100644 (file)
@@ -276,8 +276,7 @@ main (int argc, char **argv)
        }
     }
 
-  while ((optc = getopt_long (argc, argv, "bsw:", longopts, (int *) 0))
-        != EOF)
+  while ((optc = getopt_long (argc, argv, "bsw:", longopts, NULL)) != -1)
     {
       switch (optc)
        {
index 52aae62..aba3d5c 100644 (file)
@@ -317,8 +317,7 @@ main (int argc, char **argv)
       argc--;
     }
 
-  while ((c = getopt_long (argc, argv, "c:n:qv", long_options, (int *) 0))
-        != EOF)
+  while ((c = getopt_long (argc, argv, "c:n:qv", long_options, NULL)) != -1)
     {
       switch (c)
        {
index d84f62d..b46275e 100644 (file)
@@ -773,7 +773,7 @@ main (int argc, char **argv)
   print_pairables = 1;
 
   while ((optc = getopt_long_only (argc, argv, "-a:e:i1:2:o:t:v:", longopts,
-                                  (int *) 0)) != EOF)
+                                  NULL)) != -1)
     {
       long int val;
 
index 16f3547..0410fea 100644 (file)
@@ -448,7 +448,6 @@ main (int argc, char **argv)
   int opt;
   char **string = NULL;
   size_t n_strings = 0;
-  size_t i;
   size_t err = 0;
   int file_type_specified = 0;
 
@@ -463,8 +462,7 @@ main (int argc, char **argv)
 
   parse_long_options (argc, argv, "md5sum", GNU_PACKAGE, VERSION, usage);
 
-  while ((opt = getopt_long (argc, argv, "bctw", long_options, NULL))
-        != EOF)
+  while ((opt = getopt_long (argc, argv, "bctw", long_options, NULL)) != -1)
     switch (opt)
       {
       case 0:                  /* long option */
@@ -532,6 +530,8 @@ verifying checksums"));
 
   if (n_strings > 0)
     {
+      size_t i;
+
       if (optind < argc)
        {
          error (0, 0, _("no files may be specified when using --string"));
index 62e5e2e..d141081 100644 (file)
--- a/src/nl.c
+++ b/src/nl.c
@@ -473,7 +473,7 @@ main (int argc, char **argv)
   have_read_stdin = 0;
 
   while ((c = getopt_long (argc, argv, "h:b:f:v:i:pl:s:w:n:d:", longopts,
-                          (int *) 0)) != EOF)
+                          NULL)) != -1)
     {
       switch (c)
        {
index c3ad92b..4241ec5 100644 (file)
--- a/src/od.c
+++ b/src/od.c
@@ -1651,8 +1651,7 @@ main (int argc, char **argv)
   flag_dump_strings = 0;
 
   while ((c = getopt_long (argc, argv, "abcdfhilos::xw::A:j:N:t:v",
-                          long_options, (int *) 0))
-        != EOF)
+                          long_options, NULL)) != -1)
     {
       unsigned long int tmp;
       enum strtol_error s_err;
index 4d6edf2..725269b 100644 (file)
@@ -447,8 +447,7 @@ main (int argc, char **argv)
   strcpy (delims, "\t");
   strcpy (zero_delims, "\\0");
 
-  while ((optc = getopt_long (argc, argv, "d:s", longopts, (int *) 0))
-        != EOF)
+  while ((optc = getopt_long (argc, argv, "d:s", longopts, NULL)) != -1)
     {
       switch (optc)
        {
index e4f51e8..9e7d252 100644 (file)
--- a/src/sum.c
+++ b/src/sum.c
@@ -213,7 +213,7 @@ main (int argc, char **argv)
 
   have_read_stdin = 0;
 
-  while ((optc = getopt_long (argc, argv, "rs", longopts, (int *) 0)) != -1)
+  while ((optc = getopt_long (argc, argv, "rs", longopts, NULL)) != -1)
     {
       switch (optc)
        {
index d81ff6c..6b166d7 100644 (file)
--- a/src/tac.c
+++ b/src/tac.c
@@ -597,8 +597,7 @@ main (int argc, char **argv)
   sentinel_length = 1;
   separator_ends_record = 1;
 
-  while ((optc = getopt_long (argc, argv, "brs:", longopts, (int *) 0))
-        != EOF)
+  while ((optc = getopt_long (argc, argv, "brs:", longopts, NULL)) != -1)
     {
       switch (optc)
        {
index cede320..b774606 100644 (file)
@@ -993,8 +993,7 @@ parse_options (int argc, char **argv,
   count_lines = 1;
   forever = forever_multiple = from_start = print_headers = 0;
 
-  while ((c = getopt_long (argc, argv, "c:n:fqv", long_options, (int *) 0))
-        != EOF)
+  while ((c = getopt_long (argc, argv, "c:n:fqv", long_options, NULL)) != -1)
     {
       switch (c)
        {
index dcd40aa..da0f01b 100644 (file)
--- a/src/tr.c
+++ b/src/tr.c
@@ -1837,8 +1837,7 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
-  while ((c = getopt_long (argc, argv, "cdst", long_options,
-                          (int *) 0)) != EOF)
+  while ((c = getopt_long (argc, argv, "cdst", long_options, NULL)) != -1)
     {
       switch (c)
        {
index 0d04ced..9c13c51 100644 (file)
@@ -408,8 +408,7 @@ main (int argc, char **argv)
   tab_list = NULL;
   first_free_tab = 0;
 
-  while ((c = getopt_long (argc, argv, "at:,0123456789", longopts, (int *) 0))
-        != EOF)
+  while ((c = getopt_long (argc, argv, "at:,0123456789", longopts, NULL)) != -1)
     {
       switch (c)
        {
index 237eb11..f716f38 100644 (file)
@@ -305,7 +305,7 @@ main (int argc, char **argv)
   countmode = count_none;
 
   while ((optc = getopt_long (argc, argv, "0123456789cdf:is:uw:", longopts,
-                             (int *) 0)) != EOF)
+                             NULL)) != -1)
     {
       switch (optc)
        {
index e101b90..114b27d 100644 (file)
--- a/src/wc.c
+++ b/src/wc.c
@@ -269,7 +269,7 @@ main (int argc, char **argv)
   print_lines = print_words = print_chars = 0;
   total_lines = total_words = total_chars = 0;
 
-  while ((optc = getopt_long (argc, argv, "clw", longopts, (int *) 0)) != EOF)
+  while ((optc = getopt_long (argc, argv, "clw", longopts, NULL)) != -1)
     switch (optc)
       {
       case 0: