From: Jim Meyering Date: Sat, 1 Feb 1997 02:00:04 +0000 (+0000) Subject: Compare getopt_long return value against -1, not EOF. Use NULL, not '(int *) 0'... X-Git-Tag: SH-UTILS-1_16a~319 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c2d2dec516bd776d6acba7637d2e9ee721394604;p=platform%2Fupstream%2Fcoreutils.git Compare getopt_long return value against -1, not EOF. Use NULL, not '(int *) 0' as last parameter in getopt_long call. --- diff --git a/src/cat.c b/src/cat.c index d8594cb..186cc98 100644 --- 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) { diff --git a/src/cksum.c b/src/cksum.c index 2318d5b..c3f06eb 100644 --- a/src/cksum.c +++ b/src/cksum.c @@ -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) { diff --git a/src/comm.c b/src/comm.c index b329e46..c11953e 100644 --- a/src/comm.c +++ b/src/comm.c @@ -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: diff --git a/src/csplit.c b/src/csplit.c index ddd4311..08546f3 100644 --- a/src/csplit.c +++ b/src/csplit.c @@ -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: diff --git a/src/cut.c b/src/cut.c index 59711a0..991baa9 100644 --- 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) { diff --git a/src/expand.c b/src/expand.c index 9beb877..2b52525 100644 --- a/src/expand.c +++ b/src/expand.c @@ -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) { diff --git a/src/fmt.c b/src/fmt.c index b8de757..3830880 100644 --- 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: diff --git a/src/fold.c b/src/fold.c index b868102..8d63499 100644 --- a/src/fold.c +++ b/src/fold.c @@ -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) { diff --git a/src/head.c b/src/head.c index 52aae62..aba3d5c 100644 --- a/src/head.c +++ b/src/head.c @@ -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) { diff --git a/src/join.c b/src/join.c index d84f62d..b46275e 100644 --- a/src/join.c +++ b/src/join.c @@ -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; diff --git a/src/md5sum.c b/src/md5sum.c index 16f3547..0410fea 100644 --- a/src/md5sum.c +++ b/src/md5sum.c @@ -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")); diff --git a/src/nl.c b/src/nl.c index 62e5e2e..d141081 100644 --- 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) { diff --git a/src/od.c b/src/od.c index c3ad92b..4241ec5 100644 --- 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; diff --git a/src/paste.c b/src/paste.c index 4d6edf2..725269b 100644 --- a/src/paste.c +++ b/src/paste.c @@ -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) { diff --git a/src/sum.c b/src/sum.c index e4f51e8..9e7d252 100644 --- 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) { diff --git a/src/tac.c b/src/tac.c index d81ff6c..6b166d7 100644 --- 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) { diff --git a/src/tail.c b/src/tail.c index cede320..b774606 100644 --- a/src/tail.c +++ b/src/tail.c @@ -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) { diff --git a/src/tr.c b/src/tr.c index dcd40aa..da0f01b 100644 --- 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) { diff --git a/src/unexpand.c b/src/unexpand.c index 0d04ced..9c13c51 100644 --- a/src/unexpand.c +++ b/src/unexpand.c @@ -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) { diff --git a/src/uniq.c b/src/uniq.c index 237eb11..f716f38 100644 --- a/src/uniq.c +++ b/src/uniq.c @@ -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) { diff --git a/src/wc.c b/src/wc.c index e101b90..114b27d 100644 --- 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: