diff options
author | Jim Meyering <jim@meyering.net> | 1996-04-19 03:17:23 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1996-04-19 03:17:23 +0000 |
commit | cccb23f01b94849440363e5a1629e8c729bef298 (patch) | |
tree | 2fcddb50f35f57e60a13bff8d63d41dac7c8bad9 | |
parent | 199923e3ccfe52e49ccc9b27f5f38053b861d739 (diff) | |
download | coreutils-cccb23f01b94849440363e5a1629e8c729bef298.tar.xz |
(main): Make code clearer: use new variable `n_files' in
place of `argc - optind'. Use `file' instead of `argv + optind'.
-rw-r--r-- | src/tail.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/tail.c b/src/tail.c index 7246c5b79..b158584b5 100644 --- a/src/tail.c +++ b/src/tail.c @@ -847,7 +847,9 @@ main (int argc, char **argv) off_t n_units = -1; long int tmp_long; int c; /* Option character. */ - int fileind; /* Index in ARGV of first file name. */ + int i; + int n_files; + char **file; program_name = argv[0]; setlocale (LC_ALL, ""); @@ -988,28 +990,29 @@ main (int argc, char **argv) --n_units; } - fileind = optind; + n_files = argc - optind; + file = argv + optind; - if (optind < argc - 1 && forever) + if (n_files > 1 && forever) { forever_multiple = 1; forever = 0; - file_descs = (int *) xmalloc ((argc - optind) * sizeof (int)); - file_sizes = (off_t *) xmalloc ((argc - optind) * sizeof (off_t)); + file_descs = (int *) xmalloc (n_files * sizeof (int)); + file_sizes = (off_t *) xmalloc (n_files * sizeof (off_t)); } if (header_mode == always - || (header_mode == multiple_files && optind < argc - 1)) + || (header_mode == multiple_files && n_files > 1)) print_headers = 1; - if (optind == argc) + if (n_files == 0) exit_status |= tail_file ("-", n_units, 0); - for (; optind < argc; ++optind) - exit_status |= tail_file (argv[optind], n_units, optind - fileind); + for (i = 0; i < n_files; i++) + exit_status |= tail_file (file[i], n_units, i); if (forever_multiple) - tail_forever (argv + fileind, argc - fileind); + tail_forever (file, n_files); if (have_read_stdin && close (0) < 0) error (EXIT_FAILURE, errno, "-"); |