help-gengetopt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[help-gengetopt]patch for gm.c


From: Scott Haug
Subject: [help-gengetopt]patch for gm.c
Date: Mon, 9 Oct 2000 06:26:15 -0700
User-agent: Mutt/1.2.5i

Hi,

First off, thanks for gengetopt.  Great tool!  I'm using it now for my demo
apps in the id3lib project.  This will make for a nice cross-platform solution
that I don't constantly have to tweak.  FYI, I found it at freshmeat when
searching for parsing libraries.  I started using gengetopt because it included
the source for getopt_long, which isn't available on all the platforms I'd like
id3lib to work on.

I've included a patch for gm.c that fixes a couple of issues I was facing.  

First, it changes argv's type from 'char**' to 'char * const *'.  This better
matches the type signature of getopt_long, and it prevents compiler warnings
for those that have defined their main to have a similar signature (like me!).

Second, it #undef's PACKAGE and VERSION before setting them.  id3lib ships with
several example apps as a part of a single tarball.  The toplevel configure.in
defines PACAKGE and VERSION to be for the entire library, and I want different
names (and possibly different version numbers) for the various example apps
that ship with it.  #undef'ing these macros prevents compiler warnings.  It
might be best to choose different macro names for these two (GGO_PACKAGE and
GGO_VERSION?).

Anyway, thanks for the nice tool.

-Scott

diff -ur gengetopt-2.1/src/gm.c gengetopt-2.1.mine/src/gm.c
--- gengetopt-2.1/src/gm.c      Wed Sep 20 14:14:56 2000
+++ gengetopt-2.1.mine/src/gm.c Mon Oct  9 06:09:01 2000
@@ -179,7 +179,7 @@
                   abort ();
                }
                 indent ();
-               printf ("int %s_given ;\t/* Wheter %s was given.  */\n",
+               printf ("int %s_given ;\t/* Whether %s was given.  */\n",
                        opt->var_arg, opt->long_opt);
     } else {
       /* for NO_ARG options we simply create a "given" */
@@ -200,7 +200,7 @@
 
   printf ("} ;\n\n" ) ;
 
-  printf ("int %s (int argc, char **argv, struct %s *%s);\n\n", 
+  printf ("int %s (int argc, char * const *argv, struct %s *%s);\n\n", 
           function_name, ARGS_STRUCT_NAME, ARGS_STRUCT);
 
   printf ("#ifdef __cplusplus\n");
@@ -260,6 +260,9 @@
 
   if (gengetopt_package != NULL)
        printf ("\
+#if defined PACKAGE\n\
+#  undef PACKAGE\n\
+#endif\n\
 #define PACKAGE \"%s\"\n\
 ", gengetopt_package);
   else
@@ -272,6 +275,9 @@
 
   if (gengetopt_version != NULL)
        printf ("\
+#if defined VERSION\n\
+#  undef VERSION\n\
+#endif\n\
 #define VERSION \"%s\"\n\
 ", gengetopt_version);
   else
@@ -436,7 +442,7 @@
 
   printf ("\
 int\n\
-%s (int argc, char **argv, struct %s *%s)\n\
+%s (int argc, char * const *argv, struct %s *%s)\n\
 {\n\
   int c;\t/* Character of the parsed option.  */\n\
   int missing_required_options = 0;\t\n\


 --



reply via email to

[Prev in Thread] Current Thread [Next in Thread]