summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2002-02-16 09:04:30 +0000
committerJim Meyering <jim@meyering.net>2002-02-16 09:04:30 +0000
commitf033fef4ceeab2e25d4e1afa4bf38fdcfba5376e (patch)
treee9afbf996c2576e05a3ead533a4ea5cd57c35f00
parent7513e6d4f40cce1bffd0c03552ba11241383ae39 (diff)
downloadcoreutils-f033fef4ceeab2e25d4e1afa4bf38fdcfba5376e.tar.xz
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.
-rw-r--r--src/date.c33
1 files changed, 7 insertions, 26 deletions
diff --git a/src/date.c b/src/date.c
index 39f8db830..2597c9325 100644
--- a/src/date.c
+++ b/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)