diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2007-08-11 08:30:43 +0200 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2007-08-11 08:32:50 +0200 |
commit | ed31c612c12e603ce86073952018bf7f00f9cd59 (patch) | |
tree | 6b4a11c2f0f491d53127516d9e01fb1914fa9f76 /src/pr.c | |
parent | d243c0e840138cc5d8bf67c9d2a785bdbd74a8d9 (diff) | |
download | coreutils-ed31c612c12e603ce86073952018bf7f00f9cd59.tar.xz |
Accommodate more xstrtol changes.
* src/df.c (long_options): Don't bother prepending "--" to long
options that OPT_STR might decode, as that hack is no longer needed.
(main): Invoke xstrtol_fatal rather than STRTOL_FATAL_ERROR.
* src/du.c (long_options, main): Likewise.
* src/ls.c (decode_switches): Likewise.
* src/od.c (long_options, main): Likewise.
* src/pr.c (first_last_page, main): Likewise.
* src/sort.c (long_options, specify_sort_size): Likewise.
* src/pr.c (first_last_page): Accept option index and option char
instead of an assembled option string. All callers changed.
* src/sort.c (specify_sort_size): Likewise.
* src/system.h (OPT_STR, LONG_OPT_STR, short_opt_str, OPT_STR_INIT):
Remove.
Diffstat (limited to 'src/pr.c')
-rw-r--r-- | src/pr.c | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -796,14 +796,14 @@ cols_ready_to_print (void) using option +FIRST_PAGE:LAST_PAGE */ static bool -first_last_page (char const *option, char const *pages) +first_last_page (int oi, char c, char const *pages) { char *p; uintmax_t first; uintmax_t last = UINTMAX_MAX; strtol_error err = xstrtoumax (pages, &p, 10, &first, ""); if (err != LONGINT_OK && err != LONGINT_INVALID_SUFFIX_CHAR) - STRTOL_FATAL_ERROR (option, pages, err); + xstrtol_fatal (err, oi, c, long_options, pages); if (p == pages || !first) return false; @@ -813,7 +813,7 @@ first_last_page (char const *option, char const *pages) char const *p1 = p + 1; err = xstrtoumax (p1, &p, 10, &last, ""); if (err != LONGINT_OK) - STRTOL_FATAL_ERROR (option, pages, err); + xstrtol_fatal (err, oi, c, long_options, pages); if (p1 == p || last < first) return false; } @@ -856,7 +856,6 @@ separator_string (const char *optarg_S) int main (int argc, char **argv) { - int c; int n_files; bool old_options = false; bool old_w = false; @@ -881,9 +880,13 @@ main (int argc, char **argv) ? xmalloc ((argc - 1) * sizeof (char *)) : NULL); - while ((c = getopt_long (argc, argv, short_options, long_options, NULL)) - != -1) + for (;;) { + int oi = -1; + int c = getopt_long (argc, argv, short_options, long_options, &oi); + if (c == -1) + break; + if (ISDIGIT (c)) { /* Accumulate column-count digits specified via old-style options. */ @@ -902,7 +905,7 @@ main (int argc, char **argv) case 1: /* Non-option argument. */ /* long option --page dominates old `+FIRST_PAGE ...'. */ if (! (first_page_number == 0 - && *optarg == '+' && first_last_page ("+", optarg + 1))) + && *optarg == '+' && first_last_page (-2, '+', optarg + 1))) file_names[n_files++] = optarg; break; @@ -911,7 +914,7 @@ main (int argc, char **argv) if (! optarg) error (EXIT_FAILURE, 0, _("`--pages=FIRST_PAGE[:LAST_PAGE]' missing argument")); - else if (! first_last_page ("--pages", optarg)) + else if (! first_last_page (oi, 0, optarg)) error (EXIT_FAILURE, 0, _("Invalid page range %s"), quote (optarg)); break; |