summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/logname.c19
-rw-r--r--src/printenv.c19
-rw-r--r--src/sleep.c19
-rw-r--r--src/tsort.c16
-rw-r--r--src/uptime.c19
-rw-r--r--src/users.c20
-rw-r--r--src/whoami.c20
7 files changed, 14 insertions, 118 deletions
diff --git a/src/logname.c b/src/logname.c
index e1201b1fb..005a7a43e 100644
--- a/src/logname.c
+++ b/src/logname.c
@@ -33,11 +33,6 @@
/* The name this program was run with. */
char *program_name;
-static struct option const long_options[] =
-{
- {0, 0, 0, 0}
-};
-
void
usage (int status)
{
@@ -74,18 +69,8 @@ main (int argc, char **argv)
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
usage, AUTHORS, (char const *) NULL);
-
- while ((c = getopt_long (argc, argv, "", long_options, NULL)) != -1)
- {
- switch (c)
- {
- case 0:
- break;
-
- default:
- usage (EXIT_FAILURE);
- }
- }
+ if (getopt (argc, argv, "") != -1)
+ usage (EXIT_FAILURE);
if (optind < argc)
{
diff --git a/src/printenv.c b/src/printenv.c
index 1ad281994..545f1aaee 100644
--- a/src/printenv.c
+++ b/src/printenv.c
@@ -48,11 +48,6 @@ enum { PRINTENV_FAILURE = 2 };
/* The name this program was run with. */
char *program_name;
-static struct option const long_options[] =
-{
- {0, 0, 0, 0}
-};
-
extern char **environ;
void
@@ -97,18 +92,8 @@ main (int argc, char **argv)
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
usage, AUTHORS, (char const *) NULL);
-
- while ((c = getopt_long (argc, argv, "", long_options, NULL)) != -1)
- {
- switch (c)
- {
- case 0:
- break;
-
- default:
- usage (PRINTENV_FAILURE);
- }
- }
+ if (getopt (argc, argv, "+") != -1)
+ usage (PRINTENV_FAILURE);
if (optind >= argc)
{
diff --git a/src/sleep.c b/src/sleep.c
index aa766ee33..d327285c8 100644
--- a/src/sleep.c
+++ b/src/sleep.c
@@ -36,11 +36,6 @@
/* The name by which this program was run. */
char *program_name;
-static struct option const long_options[] =
-{
- {0, 0, 0, 0}
-};
-
void
usage (int status)
{
@@ -119,18 +114,8 @@ main (int argc, char **argv)
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
usage, AUTHORS, (char const *) NULL);
-
- while ((c = getopt_long (argc, argv, "", long_options, NULL)) != -1)
- {
- switch (c)
- {
- case 0:
- break;
-
- default:
- usage (EXIT_FAILURE);
- }
- }
+ if (getopt (argc, argv, "") != -1)
+ usage (EXIT_FAILURE);
if (argc == 1)
{
diff --git a/src/tsort.c b/src/tsort.c
index 5d12a3db1..2dc827008 100644
--- a/src/tsort.c
+++ b/src/tsort.c
@@ -77,11 +77,6 @@ static struct item *loop = NULL;
/* The number of strings to sort. */
static size_t n_strings = 0;
-
-static struct option const long_options[] =
-{
- { NULL, 0, NULL, 0}
-};
void
usage (int status)
@@ -558,15 +553,8 @@ main (int argc, char **argv)
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, VERSION,
usage, AUTHORS, (char const *) NULL);
-
- while ((opt = getopt_long (argc, argv, "", long_options, NULL)) != -1)
- switch (opt)
- {
- case 0: /* long option */
- break;
- default:
- usage (EXIT_FAILURE);
- }
+ if (getopt (argc, argv, "") != -1)
+ usage (EXIT_FAILURE);
have_read_stdin = false;
diff --git a/src/uptime.c b/src/uptime.c
index cf27270ae..1c3b8813f 100644
--- a/src/uptime.c
+++ b/src/uptime.c
@@ -44,11 +44,6 @@ int getloadavg ();
/* The name this program was run with. */
char *program_name;
-static struct option const longopts[] =
-{
- {NULL, 0, NULL, 0}
-};
-
static void
print_uptime (size_t n, const STRUCT_UTMP *this)
{
@@ -225,18 +220,8 @@ main (int argc, char **argv)
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
usage, AUTHORS, (char const *) NULL);
-
- while ((optc = getopt_long (argc, argv, "", longopts, NULL)) != -1)
- {
- switch (optc)
- {
- case 0:
- break;
-
- default:
- usage (EXIT_FAILURE);
- }
- }
+ if (getopt (argc, argv, "") != -1)
+ usage (EXIT_FAILURE);
switch (argc - optind)
{
diff --git a/src/users.c b/src/users.c
index a03b88325..2858019cc 100644
--- a/src/users.c
+++ b/src/users.c
@@ -37,11 +37,6 @@
/* The name this program was run with. */
char *program_name;
-static struct option const longopts[] =
-{
- {NULL, 0, NULL, 0}
-};
-
static int
userid_compare (const void *v_a, const void *v_b)
{
@@ -130,7 +125,6 @@ If FILE is not specified, use %s. %s as FILE is common.\n\
int
main (int argc, char **argv)
{
- int optc;
initialize_main (&argc, &argv);
program_name = argv[0];
setlocale (LC_ALL, "");
@@ -141,18 +135,8 @@ main (int argc, char **argv)
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
usage, AUTHORS, (char const *) NULL);
-
- while ((optc = getopt_long (argc, argv, "", longopts, NULL)) != -1)
- {
- switch (optc)
- {
- case 0:
- break;
-
- default:
- usage (EXIT_FAILURE);
- }
- }
+ if (getopt (argc, argv, "") != -1)
+ usage (EXIT_FAILURE);
switch (argc - optind)
{
diff --git a/src/whoami.c b/src/whoami.c
index 12b2b104d..8614c5b82 100644
--- a/src/whoami.c
+++ b/src/whoami.c
@@ -39,11 +39,6 @@
/* The name this program was run with. */
char *program_name;
-static struct option const long_options[] =
-{
- {0, 0, 0, 0}
-};
-
void
usage (int status)
{
@@ -70,7 +65,6 @@ main (int argc, char **argv)
{
register struct passwd *pw;
register uid_t uid;
- int c;
initialize_main (&argc, &argv);
program_name = argv[0];
@@ -82,18 +76,8 @@ main (int argc, char **argv)
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
usage, AUTHORS, (char const *) NULL);
-
- while ((c = getopt_long (argc, argv, "", long_options, NULL)) != -1)
- {
- switch (c)
- {
- case 0:
- break;
-
- default:
- usage (EXIT_FAILURE);
- }
- }
+ if (getopt (argc, argv, "") != -1)
+ usage (EXIT_FAILURE);
if (optind != argc)
{