This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
[patch] manual/examples/longopt.c: make the options struct a little more like it should be
- To: GNU C Library <libc-alpha at sourceware dot cygnus dot com>
- Subject: [patch] manual/examples/longopt.c: make the options struct a little more like it should be
- From: Ben Collins <bcollins at debian dot org>
- Date: Sat, 23 Dec 2000 13:17:30 -0500
2000-12-23 Ben Collins <bcollins@debian.org>
* manual/examples/longopt.c: Make the "struct option" a little
more like it should be (adding usage of required_argument,
noargument and such, and also setting the options string
right).
--
-----------=======-=-======-=========-----------=====------------=-=------
/ Ben Collins -- ...on that fantastic voyage... -- Debian GNU/Linux \
` bcollins@debian.org -- bcollins@openldap.org -- bcollins@linux.com '
`---=========------=======-------------=-=-----=-===-======-------=--=---'
Index: examples/longopt.c
===================================================================
RCS file: /cvs/glibc/libc/manual/examples/longopt.c,v
retrieving revision 1.4
diff -u -u -r1.4 longopt.c
--- longopt.c 1996/05/15 23:00:17 1.4
+++ longopt.c 2000/12/23 18:17:26
@@ -17,21 +17,21 @@
static struct option long_options[] =
{
/* These options set a flag. */
- {"verbose", 0, &verbose_flag, 1},
- {"brief", 0, &verbose_flag, 0},
+ {"verbose", no_argument, &verbose_flag, 1},
+ {"brief", no_argument, &verbose_flag, 0},
/* These options don't set a flag.
We distinguish them by their indices. */
- {"add", 1, 0, 0},
- {"append", 0, 0, 0},
- {"delete", 1, 0, 0},
- {"create", 0, 0, 0},
- {"file", 1, 0, 0},
+ {"add", required_argument, 0, 'a'},
+ {"append", no_argument, 0, 'b'},
+ {"delete", required_argument, 0, 'd'},
+ {"create", no_argument, 0, 'c'},
+ {"file", required_argument, 0, 'f'},
{0, 0, 0, 0}
};
/* @code{getopt_long} stores the option index here. */
int option_index = 0;
- c = getopt_long (argc, argv, "abc:d:",
+ c = getopt_long (argc, argv, "abc:d:f:",
long_options, &option_index);
/* Detect the end of the options. */