(usage): Document only the intersection of the old and new behaviors,
to encourage portability.
(short_options): Remove; no longer needed.
(COMMON_SHORT_OPTIONS): New macro.
(STRINGS_OPTION, WIDTH_OPTION): Remove; no longer needed.
All uses changed to back to the corresponding short options.
(main): Parse options using POSIX 1003.1-2001 rules if
conforming to that standard. Do not warn of obsolete options.
#include "system.h"
#include "closeout.h"
#include "error.h"
#include "system.h"
#include "closeout.h"
#include "error.h"
#include "xstrtol.h"
/* The official name of this program (e.g., no `g' prefix). */
#include "xstrtol.h"
/* The official name of this program (e.g., no `g' prefix). */
#define MAX_FP_TYPE_SIZE sizeof(LONG_DOUBLE)
static enum size_spec fp_type_size[MAX_FP_TYPE_SIZE + 1];
#define MAX_FP_TYPE_SIZE sizeof(LONG_DOUBLE)
static enum size_spec fp_type_size[MAX_FP_TYPE_SIZE + 1];
-static char const short_options[] =
-"abcdfhilos" OPTARG_POSIX "xw" OPTARG_POSIX "A:j:N:t:v";
+#define COMMON_SHORT_OPTIONS "A:N:abcdfhij:lot:vx"
/* For long options that have no equivalent short option, use a
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
enum
{
/* For long options that have no equivalent short option, use a
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
enum
{
- STRINGS_OPTION = CHAR_MAX + 1,
- TRADITIONAL_OPTION,
- WIDTH_OPTION
+ TRADITIONAL_OPTION = CHAR_MAX + 1
};
static struct option const long_options[] =
};
static struct option const long_options[] =
{"read-bytes", required_argument, NULL, 'N'},
{"format", required_argument, NULL, 't'},
{"output-duplicates", no_argument, NULL, 'v'},
{"read-bytes", required_argument, NULL, 'N'},
{"format", required_argument, NULL, 't'},
{"output-duplicates", no_argument, NULL, 'v'},
-
- {"strings", optional_argument, NULL, STRINGS_OPTION},
+ {"strings", optional_argument, NULL, 's'},
{"traditional", no_argument, NULL, TRADITIONAL_OPTION},
{"traditional", no_argument, NULL, TRADITIONAL_OPTION},
- {"width", optional_argument, NULL, WIDTH_OPTION},
+ {"width", optional_argument, NULL, 'w'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
With no FILE, or when FILE is -, read standard input.\n\
\n\
"), stdout);
With no FILE, or when FILE is -, read standard input.\n\
\n\
"), stdout);
- if (POSIX2_VERSION < 200112)
- fputs (_("\
-Mandatory arguments to long options are mandatory for short options too.\n\
-"), stdout);
- else
- fputs (_("\
All arguments to long options are mandatory for short options.\n\
"), stdout);
fputs (_("\
All arguments to long options are mandatory for short options.\n\
"), stdout);
fputs (_("\
int width_specified = 0;
int n_failed_decodes = 0;
int err;
int width_specified = 0;
int n_failed_decodes = 0;
int err;
- bool posix_pedantic = (getenv ("POSIXLY_CORRECT") != NULL);
+ char const *short_options = (posix2_version () < 200112
+ ? COMMON_SHORT_OPTIONS "s::w::"
+ : COMMON_SHORT_OPTIONS "s:w:");
/* The old-style `pseudo starting address' to be printed in parentheses
after any true address. */
/* The old-style `pseudo starting address' to be printed in parentheses
after any true address. */
- if (POSIX2_VERSION < 200112 && OBSOLETE_OPTION_WARNINGS
- && ! optarg && ! posix_pedantic)
- error (0, 0,
- _("warning: `od -s' is obsolete; use `od --strings'"));
- /* Fall through. */
- case STRINGS_OPTION:
if (optarg == NULL)
string_min = 3;
else
if (optarg == NULL)
string_min = 3;
else
#undef CASE_OLD_ARG
case 'w':
#undef CASE_OLD_ARG
case 'w':
- if (POSIX2_VERSION < 200112 && OBSOLETE_OPTION_WARNINGS
- && ! optarg && ! posix_pedantic)
- error (0, 0, _("warning: `od -w' is obsolete; use `od --width'"));
- /* Fall through. */
- case WIDTH_OPTION:
width_specified = 1;
if (optarg == NULL)
{
width_specified = 1;
if (optarg == NULL)
{