mirror of
https://https.git.savannah.gnu.org/git/coreutils.git
synced 2026-01-27 01:44:21 +00:00
Add support for _POSIX2_VERSION, which lets you pick which POSIX
version you want the utilities to conform to. Remove warnings about failure to conform to a future POSIX version. (ISO_8601_OPTION): Remove; no longer needed. All uses changed to back to the corresponding short options. (short_options): Remove; no longer needed. (COMMON_SHORT_OPTIONS): New macro. (usage): Document only the intersection of the old and new behaviors, to encourage portability. (main): Parse options using POSIX 1003.1-2001 rules if conforming to that standard. Do not warn of obsolete options.
This commit is contained in:
parent
7513e6d4f4
commit
f033fef4ce
33
src/date.c
33
src/date.c
@ -79,20 +79,13 @@ static int iso_8601_format = 0;
|
||||
/* If non-zero, display time in RFC-(2)822 format for mail or news. */
|
||||
static int rfc_format = 0;
|
||||
|
||||
/* For long options that have no equivalent short option, use a
|
||||
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
|
||||
enum
|
||||
{
|
||||
ISO_8601_OPTION = CHAR_MAX + 1
|
||||
};
|
||||
|
||||
static char const short_options[] = "d:f:I" OPTARG_POSIX "r:Rs:u";
|
||||
#define COMMON_SHORT_OPTIONS "Rd:f:r:s:u"
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"date", required_argument, NULL, 'd'},
|
||||
{"file", required_argument, NULL, 'f'},
|
||||
{"iso-8601", optional_argument, NULL, ISO_8601_OPTION},
|
||||
{"iso-8601", optional_argument, NULL, 'I'},
|
||||
{"reference", required_argument, NULL, 'r'},
|
||||
{"rfc-822", no_argument, NULL, 'R'},
|
||||
{"set", required_argument, NULL, 's'},
|
||||
@ -134,20 +127,11 @@ Display the current time in the given FORMAT, or set the system date.\n\
|
||||
\n\
|
||||
-d, --date=STRING display time described by STRING, not `now'\n\
|
||||
-f, --file=DATEFILE like --date once for each line of DATEFILE\n\
|
||||
"), stdout);
|
||||
if (POSIX2_VERSION < 200112)
|
||||
fputs (_("\
|
||||
-ITIMESPEC, --iso-8601[=TIMESPEC] output date/time in ISO 8601 format.\n\
|
||||
-I (obsolete) same as -Idate\n\
|
||||
"), stdout);
|
||||
else
|
||||
fputs (_("\
|
||||
-I TIMESPEC, --iso-8601[=TIMESPEC] output date/time in ISO 8601 format.\n\
|
||||
"), stdout);
|
||||
fputs(_("\
|
||||
TIMESPEC=`date' (or missing) for date only,\n\
|
||||
TIMESPEC=`date' for date only,\n\
|
||||
`hours', `minutes', or `seconds' for date and\n\
|
||||
time to the indicated precision.\n\
|
||||
--iso-8601 without TIMESPEC defaults to `date'.\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-r, --reference=FILE display the last modification time of FILE\n\
|
||||
@ -315,6 +299,9 @@ main (int argc, char **argv)
|
||||
int n_args;
|
||||
int status;
|
||||
int option_specified_date;
|
||||
char const *short_options = (posix2_version () < 200112
|
||||
? COMMON_SHORT_OPTIONS "I::"
|
||||
: COMMON_SHORT_OPTIONS "I:");
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
@ -337,12 +324,6 @@ main (int argc, char **argv)
|
||||
batch_file = optarg;
|
||||
break;
|
||||
case 'I':
|
||||
if (POSIX2_VERSION < 200112 && OBSOLETE_OPTION_WARNINGS
|
||||
&& ! optarg && ! getenv ("POSIXLY_CORRECT"))
|
||||
error (0, 0,
|
||||
_("warning: `-I' option is obsolete; use `--iso-8601'"));
|
||||
/* Fall through. */
|
||||
case ISO_8601_OPTION:
|
||||
iso_8601_format = (optarg
|
||||
? XARGMATCH ("--iso-8601", optarg,
|
||||
time_spec_string, time_spec)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user