help-gengetopt
[Top][All Lists]
Advanced

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

[help-gengetopt] a small improvement(?) in the config file parser


From: Gyozo, PAPP (VBuster)
Subject: [help-gengetopt] a small improvement(?) in the config file parser
Date: Wed, 29 Sep 2004 18:48:34 +0200

Hi there,

I've run into a problem (with gengetopt 2.13) which I could not resolve 
reassuringly.
The problem involves the new config file parser function (btw I think the old 
one would also be subject of this problem.)

Take the following .ggo resource file
# option.ggo
option "option-with-arg" - "this option must have an argument" type=string no
option "arbitrary"       - "this option is arbitrary, but has great importance 
in this example" no

and the following config file given to the application:
# config.ini
option-with-arg   = # no option is specified, error!
arbitrary

The problem is that the _configfile() parser function currently ignores the 
equal-sign and simply generates "--option-with-arg" for the corresponding argv 
element, and then finally "--arbitrary" is also added to the virtual 
commandline which will be passed to the _internal() perser function. So after 
reading up the preceding config file cmdline_internal() receives the following 
argv array:
        [0] = PACKAGE_VAR_NAME
        [1] = "--option-with-arg"
        [2] = "arbitrary"

At this point, you can easily guess what the real problem is. Yes, the parser 
function thinks that "arbitrary" is the option-argument of "--option-with-arg", 
so the whole configuration will be messed up. I patched the configfile parser 
template which checks now if equal sign is present in the current line, and if 
so, it adds the equal sign to the corresponding argv element. 
        [0] = PACKAGE_VAR_NAME
        [1] = "--option-with-arg="
        [2] = "arbitrary"

This hack may suffice my current needs, but I think the real solution would be 
if options read by _configfile() function was processed immediately without 
translating the options to a virtual command line and then processed by 
_internal(). 

What do you think?

--
Papp, Győző 
VirusBuster Kft




reply via email to

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