summaryrefslogtreecommitdiff
path: root/src/od.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2007-08-04 13:36:59 +0200
committerJim Meyering <jim@meyering.net>2007-08-04 13:36:59 +0200
commit8188c3b48ded8b53d88440f0736690d2e30508ed (patch)
treeb36bbe8ed28eaa4dc37c9876cc5f71a520bb9fdd /src/od.c
parent33f95a9ab62968a6b13eb1a6a71f180f61721f71 (diff)
downloadcoreutils-8188c3b48ded8b53d88440f0736690d2e30508ed.tar.xz
Adapt to new human and xstrtol API.
* src/df.c (long_options): Prepend "--" to long options that OPT_STR might decode. * src/du.c (long_options): Likewise. * src/od.c (long_options): Likewise. * src/sort.c (long_options): Likewise. * src/df.c (main): Adjust to new human and xstrtol API. * src/du.c (main): Likewise. * src/ls.c (decode_switches): Likewise. * src/od.c (main): Likewise. * src/pr.c (first_last_page): Likewise. New argument OPTION. All callers changed. * src/sort.c (specify_sort_size): New arg OPTION. All callers changed. Adjust to new xstrtol API. * src/system.h (opt_str_storage): New static var. (OPT_STR, LONG_OPT_STR, OPT_STR_INIT): New macros.
Diffstat (limited to 'src/od.c')
-rw-r--r--src/od.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/od.c b/src/od.c
index 3f2159ee8..472c513e3 100644
--- a/src/od.c
+++ b/src/od.c
@@ -1,5 +1,5 @@
/* od -- dump files in octal and other formats
- Copyright (C) 92, 1995-2006 Free Software Foundation, Inc.
+ Copyright (C) 92, 1995-2007 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -281,14 +281,14 @@ enum
static struct option const long_options[] =
{
- {"skip-bytes", required_argument, NULL, 'j'},
+ {OPT_STR_INIT ("skip-bytes"), required_argument, NULL, 'j'},
{"address-radix", required_argument, NULL, 'A'},
- {"read-bytes", required_argument, NULL, 'N'},
+ {OPT_STR_INIT ("read-bytes"), required_argument, NULL, 'N'},
{"format", required_argument, NULL, 't'},
{"output-duplicates", no_argument, NULL, 'v'},
- {"strings", optional_argument, NULL, 'S'},
+ {OPT_STR_INIT ("strings"), optional_argument, NULL, 'S'},
{"traditional", no_argument, NULL, TRADITIONAL_OPTION},
- {"width", optional_argument, NULL, 'w'},
+ {OPT_STR_INIT ("width"), optional_argument, NULL, 'w'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
@@ -1555,7 +1555,6 @@ dump_strings (void)
int
main (int argc, char **argv)
{
- int c;
int n_files;
size_t i;
int l_c_m;
@@ -1609,11 +1608,14 @@ main (int argc, char **argv)
address_pad_len = 7;
flag_dump_strings = false;
- while ((c = getopt_long (argc, argv, short_options, long_options, NULL))
- != -1)
+ for (;;)
{
uintmax_t tmp;
enum strtol_error s_err;
+ int oi = -1;
+ int c = getopt_long (argc, argv, short_options, long_options, &oi);
+ if (c == -1)
+ break;
switch (c)
{
@@ -1653,7 +1655,7 @@ it must be one character from [doxn]"),
modern = true;
s_err = xstrtoumax (optarg, NULL, 0, &n_bytes_to_skip, multipliers);
if (s_err != LONGINT_OK)
- STRTOL_FATAL_ERROR (optarg, _("skip argument"), s_err);
+ STRTOL_FATAL_ERROR (OPT_STR (oi, c, long_options), optarg, s_err);
break;
case 'N':
@@ -1663,7 +1665,7 @@ it must be one character from [doxn]"),
s_err = xstrtoumax (optarg, NULL, 0, &max_bytes_to_format,
multipliers);
if (s_err != LONGINT_OK)
- STRTOL_FATAL_ERROR (optarg, _("limit argument"), s_err);
+ STRTOL_FATAL_ERROR (OPT_STR (oi, c, long_options), optarg, s_err);
break;
case 'S':
@@ -1674,7 +1676,8 @@ it must be one character from [doxn]"),
{
s_err = xstrtoumax (optarg, NULL, 0, &tmp, multipliers);
if (s_err != LONGINT_OK)
- STRTOL_FATAL_ERROR (optarg, _("minimum string length"), s_err);
+ STRTOL_FATAL_ERROR (OPT_STR (oi, c, long_options), optarg,
+ s_err);
/* The minimum string length may be no larger than SIZE_MAX,
since we may allocate a buffer of this size. */
@@ -1746,7 +1749,8 @@ it must be one character from [doxn]"),
uintmax_t w_tmp;
s_err = xstrtoumax (optarg, NULL, 10, &w_tmp, "");
if (s_err != LONGINT_OK)
- STRTOL_FATAL_ERROR (optarg, _("width specification"), s_err);
+ STRTOL_FATAL_ERROR (OPT_STR (oi, c, long_options), optarg,
+ s_err);
if (SIZE_MAX < w_tmp)
error (EXIT_FAILURE, 0, _("%s is too large"), optarg);
desired_width = w_tmp;