[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[help-gengetopt] controlling output extenstions
From: |
Brooks Davis |
Subject: |
[help-gengetopt] controlling output extenstions |
Date: |
Tue, 24 Feb 2004 20:51:22 -0000 |
User-agent: |
Mutt/1.5.4i |
I'm working on a project that uses gengetopt. Some of the options
currently have defaults which should be set by configure. To enable
that, but avoid adding a build dependency of gengetopt, I would like to
be able to create .c.in and .h.in files that autoconf can do
substitations on. The following patch allows the users to set the
extensions of the c and header files produced by gengetopt so I can do
this.
-- Brooks
--
Any statement of the form "X is the one, true Y" is FALSE.
PGP fingerprint 655D 519C 26A7 82E7 2529 9BF0 5D8E 8BE9 F238 1AD4
diff -ru --exclude=cmdline.c --exclude=cmdline.h
gengetopt-2.11/doc/gengetopt.1.in gengetopt-2.11+suffix/doc/gengetopt.1.in
--- gengetopt-2.11/doc/gengetopt.1.in Tue Jul 22 08:09:44 2003
+++ gengetopt-2.11+suffix/doc/gengetopt.1.in Tue Feb 24 09:35:34 2004
@@ -30,17 +30,19 @@
\fBgengetopt\fP accepts some options.
.sp
.nf
- -h --help Print help and exit
- -V --version Print version and exit
- -iSTRING --input=STRING input file (default std input)
- -fSTRING --func-name=STRING name of generated function
(default='cmdline_parser')
- -FSTRING --file-name=STRING name of generated file (default='cmdline')
- -l --long-help long usage line in help
- -u --unamed-opts accept filenames
- --no-handle-help do not handle --help|-h automatically
- --no-handle-version do not handle --version|-V automatically
- --no-handle-error do not exit on errors
- --conf-parser generate a config file parser
+ -h --help Print help and exit
+ -V --version Print version and exit
+ -iSTRING --input=STRING input file (default std input)
+ -fSTRING --func-name=STRING name of generated function
(default='cmdline_parser')
+ -FSTRING --file-name=STRING name of generated file (default='cmdline')
+ --c-extension=STRING extension of c file (default='c')
+ --header-extension=ext extension of header file (default='h')
+ -l --long-help long usage line in help
+ -u --unamed-opts accept filenames
+ --no-handle-help do not handle --help|-h automatically
+ --no-handle-version do not handle --version|-V automatically
+ --no-handle-error do not exit on errors
+ --conf-parser generate a config file parser
.fi
.SH INPUT
The description file consists of lines with the following format, commands in
() are optionals:
diff -ru --exclude=cmdline.c --exclude=cmdline.h gengetopt-2.11/src/cmdline.ggo
gengetopt-2.11+suffix/src/cmdline.ggo
--- gengetopt-2.11/src/cmdline.ggo Sun Jul 6 14:11:19 2003
+++ gengetopt-2.11+suffix/src/cmdline.ggo Tue Feb 24 09:36:54 2004
@@ -61,6 +61,8 @@
option "input" i "input file (default std input)" string
typestr="filename" no
option "func-name" f "name of generated function" string typestr="name"
default="cmdline_parser" no
option "file-name" F "name of generated file" string typestr="name"
default="cmdline" no
+option "c-extension" - "extension of c file" string typestr="ext"
default="c" no
+option "header-extension" - "extension of header file" string typestr="ext"
default="h" no
option "long-help" l "long usage line in help" no
option "unamed-opts" u "accept filenames" no
option "no-handle-help" - "do not handle --help|-h automatically" no
diff -ru --exclude=cmdline.c --exclude=cmdline.h
gengetopt-2.11/src/gengetopt.cc gengetopt-2.11+suffix/src/gengetopt.cc
--- gengetopt-2.11/src/gengetopt.cc Tue Jul 22 08:50:00 2003
+++ gengetopt-2.11+suffix/src/gengetopt.cc Tue Feb 24 09:28:53 2004
@@ -52,9 +52,6 @@
extern "C" char *strdup (const char *s) ;
#endif
-#define DEFAULT_HEADER_EXT "h"
-#define DEFAULT_C_EXT "c"
-
struct gengetopt_option * gengetopt_options = NULL;
char * gengetopt_package = NULL;
char * gengetopt_version = NULL;
@@ -79,6 +76,8 @@
struct gengetopt_args_info args_info ;
char *cmdline_parser_name ; /* name of the generated function */
char *cmdline_filename ; /* name of generated file */
+ char *c_ext ; /* extenstion of c file */
+ char *header_ext ; /* extenstion of header file */
int i;
FILE *input_file ;
@@ -107,6 +106,8 @@
cmdline_parser_name = args_info.func_name_arg ;
cmdline_filename = args_info.file_name_arg ;
+ c_ext = args_info.c_extension_arg;
+ header_ext = args_info.header_extension_arg;
switch (gengetopt_add_option (HELP_LONG_OPT, HELP_SHORT_OPT,
HELP_OPT_DESCR, ARG_NO, 0, 0, 0, 0, 0, 0))
@@ -163,8 +164,8 @@
(cmdline_parser_name,
args_info.unamed_opts_given,
cmdline_filename,
- DEFAULT_HEADER_EXT,
- DEFAULT_C_EXT,
+ header_ext,
+ c_ext,
args_info.long_help_given,
args_info.no_handle_help_given,
args_info.no_handle_version_given,
pgpk2jCsfcIxR.pgp
Description: PGP signature
- [help-gengetopt] controlling output extenstions,
Brooks Davis <=