[PATCH] argp: rename "struct group" to "struct argp_group"

2014-02-17 Thread Eric Wong
This avoid conflicts with FreeBSD headers when using the
"freebsd-glue" package on Debian GNU/kFreeBSD

Reproducible with:
  ./configure LIBS=-lfreebsd-glue CFLAGS=-I/usr/include/freebsd

* lib/argp-parse.c (struct argp_group): rename from struct group
---
  Now I'm stuck on another failure, another email coming

 lib/argp-parse.c | 31 ---
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/lib/argp-parse.c b/lib/argp-parse.c
index 9ade452..3f6af2a 100644
--- a/lib/argp-parse.c
+++ b/lib/argp-parse.c
@@ -191,7 +191,7 @@ find_long_option (struct option *long_options, const char 
*name)
 /* The state of a "group" during parsing.  Each group corresponds to a
particular argp structure from the tree of such descending from the top
level argp passed to argp_parse.  */
-struct group
+struct argp_group
 {
   /* This group's parsing function.  */
   argp_parser_t parser;
@@ -208,7 +208,7 @@ struct group
   unsigned args_processed;
 
   /* This group's parser's parent's group.  */
-  struct group *parent;
+  struct argp_group *parent;
   unsigned parent_index;/* And the our position in the parent.   */
 
   /* These fields are swapped into and out of the state structure when
@@ -221,7 +221,8 @@ struct group
from STATE before calling, and back into state afterwards.  If GROUP has
no parser, EBADKEY is returned.  */
 static error_t
-group_parse (struct group *group, struct argp_state *state, int key, char *arg)
+group_parse (struct argp_group *group, struct argp_state *state,
+ int key, char *arg)
 {
   if (group->parser)
 {
@@ -252,9 +253,9 @@ struct parser
   struct _getopt_data opt_data;
 
   /* States of the various parsing groups.  */
-  struct group *groups;
+  struct argp_group *groups;
   /* The end of the GROUPS array.  */
-  struct group *egroup;
+  struct argp_group *egroup;
   /* A vector containing storage for the CHILD_INPUTS field in all groups.  */
   void **child_inputs;
 
@@ -285,10 +286,10 @@ struct parser_convert_state
into getopt options stored in SHORT_OPTS and LONG_OPTS; SHORT_END and
CVT->LONG_END are the points at which new options are added.  Returns the
next unused group entry.  CVT holds state used during the conversion.  */
-static struct group *
+static struct argp_group *
 convert_options (const struct argp *argp,
- struct group *parent, unsigned parent_index,
- struct group *group, struct parser_convert_state *cvt)
+ struct argp_group *parent, unsigned parent_index,
+ struct argp_group *group, struct parser_convert_state *cvt)
 {
   /* REAL is the most recent non-alias value of OPT.  */
   const struct argp_option *real = argp->options;
@@ -459,7 +460,7 @@ parser_init (struct parser *parser, const struct argp *argp,
  int argc, char **argv, int flags, void *input)
 {
   error_t err = 0;
-  struct group *group;
+  struct argp_group *group;
   struct parser_sizes szs;
   struct _getopt_data opt_data = _GETOPT_DATA_INITIALIZER;
   char *storage;
@@ -477,13 +478,13 @@ parser_init (struct parser *parser, const struct argp 
*argp,
 calc_sizes (argp, &szs);
 
   /* Lengths of the various bits of storage used by PARSER.  */
-  glen = (szs.num_groups + 1) * sizeof (struct group);
+  glen = (szs.num_groups + 1) * sizeof (struct argp_group);
   clen = szs.num_child_inputs * sizeof (void *);
   llen = (szs.long_len + 1) * sizeof (struct option);
   slen = szs.short_len + 1;
 
   /* Sums of previous lengths, properly aligned.  There's no need to
- align gsum, since struct group is aligned at least as strictly as
+ align gsum, since struct argp_group is aligned at least as strictly as
  void * (since it contains a void * member).  And there's no need
  to align lsum, since struct option is aligned at least as
  strictly as char.  */
@@ -570,7 +571,7 @@ static error_t
 parser_finalize (struct parser *parser,
  error_t err, int arg_ebadkey, int *end_index)
 {
-  struct group *group;
+  struct argp_group *group;
 
   if (err == EBADKEY && arg_ebadkey)
 /* Suppress errors generated by unparsed arguments.  */
@@ -669,7 +670,7 @@ parser_parse_arg (struct parser *parser, char *val)
  we're parsing is again the front of the arg vector.  */
   int index = --parser->state.next;
   error_t err = EBADKEY;
-  struct group *group;
+  struct argp_group *group;
   int key = 0;  /* Which of ARGP_KEY_ARG[S] we used.  */
 
   /* Try to parse the argument in each parser.  */
@@ -726,7 +727,7 @@ parser_parse_opt (struct parser *parser, int opt, char *val)
various starting positions in each group's SHORT_END field, we can
determine which group OPT came from.  */
 {
-  struct group *group;
+  struct argp_group *group;
   char *short_index = strchr (parser->short_opts, opt);
 
   if (short_index)
@@ -938,7 +939,7 @@ __argp_input (const struct argp *argp, const

Debian argp kFreeBSD failure with freebsd-glue

2014-02-17 Thread Eric Wong
Note: things work fine without freebsd-glue, but I wanted to
transparently enable FreeBSD sendfile on cmogstored.

I got another failure after fixing the argp "struct group" conflict.

Also using:
  ./configure LIBS=-lfreebsd-glue CFLAGS=-I/usr/include/freebsd

(Note: this is not that important for me, take your time)

Full log here: http://yhbt.net/argp-debiankfbsd.gz

Partial below:

gcc -DHAVE_CONFIG_H -I. -I..  -DGNULIB_STRICT_CHECKING=1   
-I/usr/include/freebsd -MT printf-args.o -MD -MP -MF .deps/printf-args.Tpo -c 
-o printf-args.o printf-args.c
mv -f .deps/progname.Tpo .deps/progname.Po
mv -f .deps/asnprintf.Tpo .deps/asnprintf.Po
mv -f .deps/unistd.Tpo .deps/unistd.Po
gcc -DHAVE_CONFIG_H -I. -I..  -DGNULIB_STRICT_CHECKING=1   
-I/usr/include/freebsd -MT printf-parse.o -MD -MP -MF .deps/printf-parse.Tpo -c 
-o printf-parse.o printf-parse.c
gcc -DHAVE_CONFIG_H -I. -I..  -DGNULIB_STRICT_CHECKING=1   
-I/usr/include/freebsd -MT strerror.o -MD -MP -MF .deps/strerror.Tpo -c -o 
strerror.o strerror.c
gcc -DHAVE_CONFIG_H -I. -I..  -DGNULIB_STRICT_CHECKING=1   
-I/usr/include/freebsd -MT strerror-override.o -MD -MP -MF 
.deps/strerror-override.Tpo -c -o strerror-override.o strerror-override.c
In file included from /usr/include/libio.h:32:0,
 from /usr/include/stdio.h:74,
 from /usr/include/freebsd/stdio.h:1,
 from ./stdio.h:43,
 from /usr/include/bsd/stdio.h:30,
 from /usr/include/freebsd/stdio.h:6,
 from ./stdio.h:33,
 from /usr/include/wchar.h:36,
 from ./wchar.h:79,
 from printf-args.h:41,
 from printf-args.c:29:
/usr/include/_G_config.h:24:3: error: unknown type name ‘__mbstate_t’
   __mbstate_t __state;
   ^
/usr/include/_G_config.h:29:3: error: unknown type name ‘__mbstate_t’
   __mbstate_t __state;
   ^
mv -f .deps/xsize.Tpo .deps/xsize.Po
In file included from /usr/include/libio.h:32:0,
 from /usr/include/stdio.h:74,
 from /usr/include/freebsd/stdio.h:1,
 from ./stdio.h:43,
 from /usr/include/bsd/stdio.h:30,
 from /usr/include/freebsd/stdio.h:6,
 from ./stdio.h:33,
 from /usr/include/wchar.h:36,
 from ./wchar.h:79,
 from printf-args.h:41,
 from printf-parse.h:29,
 from printf-parse.c:36:
/usr/include/_G_config.h:24:3: error: unknown type name ‘__mbstate_t’
   __mbstate_t __state;
   ^
/usr/include/_G_config.h:29:3: error: unknown type name ‘__mbstate_t’
   __mbstate_t __state;
   ^
gcc -DHAVE_CONFIG_H -I. -I..  -DGNULIB_STRICT_CHECKING=1   
-I/usr/include/freebsd -MT vasnprintf.o -MD -MP -MF .deps/vasnprintf.Tpo -c -o 
vasnprintf.o vasnprintf.c
make[4]: *** [printf-args.o] Error 1
make[4]: *** Waiting for unfinished jobs
mv -f .deps/getopt1.Tpo .deps/getopt1.Po
mv -f .deps/dup2.Tpo .deps/dup2.Po
make[4]: *** [printf-parse.o] Error 1
mv -f .deps/strerror-override.Tpo .deps/strerror-override.Po
mv -f .deps/getopt.Tpo .deps/getopt.Po
mv -f .deps/strerror.Tpo .deps/strerror.Po
mv -f .deps/vasnprintf.Tpo .deps/vasnprintf.Po
make[4]: Leaving directory `/tmp/argp/gllib'

Thanks for taking a look!