This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Add named initializers to argp/argp-parse.c


Hi.

This patch is a test-the-waters patch to see if changes like this would
be considered worthwhile.

2003-02-18  Art Haas  <ahaas@airmail.net>

	* argp/argp-parse.c: Add C99 named initializers.

Index: argp-parse.c
===================================================================
RCS file: /cvs/glibc/libc/argp/argp-parse.c,v
retrieving revision 1.17
diff -u -r1.17 argp-parse.c
--- argp-parse.c	8 Apr 2002 08:38:33 -0000	1.17
+++ argp-parse.c	18 Feb 2003 23:56:57 -0000
@@ -1,5 +1,5 @@
 /* Hierarchial argument parsing, layered over getopt
-   Copyright (C) 1995-2000, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1995-2000, 2002, 2003 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Written by Miles Bader <miles@gnu.ai.mit.edu>.
 
@@ -97,12 +97,32 @@
 
 static const struct argp_option argp_default_options[] =
 {
-  {"help",	  '?',    	0, 0,  N_("Give this help list"), -1},
-  {"usage",	  OPT_USAGE,	0, 0,  N_("Give a short usage message")},
-  {"program-name",OPT_PROGNAME,"NAME", OPTION_HIDDEN, N_("Set the program name")},
-  {"HANG",	  OPT_HANG,    "SECS", OPTION_ARG_OPTIONAL | OPTION_HIDDEN,
-     N_("Hang for SECS seconds (default 3600)")},
-  {0, 0}
+  {
+    .name = "help",
+    .key = '?',
+    .doc = N_("Give this help list"),
+    .group = -1
+  },
+  {
+    .name = "usage",
+    .key = OPT_USAGE,
+    .doc = N_("Give a short usage message")
+  },
+  {
+    .name = "program-name",
+    .key = OPT_PROGNAME,
+    .arg = "NAME",
+    .flags = OPTION_HIDDEN,
+    .doc = N_("Set the program name")
+  },
+  {
+    .name = "HANG",
+    .key = OPT_HANG,
+    .arg = "SECS",
+    .flags = OPTION_ARG_OPTIONAL | OPTION_HIDDEN,
+    .doc = N_("Hang for SECS seconds (default 3600)")
+  },
+  {}
 };
 
 static error_t
@@ -152,14 +172,22 @@
   return 0;
 }
 
-static const struct argp argp_default_argp =
-  {argp_default_options, &argp_default_parser, NULL, NULL, NULL, NULL, "libc"};
+static const struct argp argp_default_argp = {
+  .options = argp_default_options,
+  .parser = &argp_default_parser,
+  .argp_domain = "libc"
+};
 
 
 static const struct argp_option argp_version_options[] =
 {
-  {"version",	  'V',    	0, 0,  N_("Print program version"), -1},
-  {0, 0}
+  {
+    .name = "version",
+    .key = 'V',
+    .doc = N_("Print program version"),
+    .group = -1
+  },
+  {}
 };
 
 static error_t
@@ -184,8 +212,11 @@
   return 0;
 }
 
-static const struct argp argp_version_argp =
-  {argp_version_options, &argp_version_parser, NULL, NULL, NULL, NULL, "libc"};
+static const struct argp argp_version_argp = {
+  .options = argp_version_options,
+  .parser = &argp_version_parser,
+  .argp_domain = "libc"
+};
 
 /* Returns the offset into the getopt long options array LONG_OPTIONS of a
    long option with called NAME, or -1 if none is found.  Passing NULL as
-- 
They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety.
 -- Benjamin Franklin, Historical Review of Pennsylvania, 1759


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]