libcfg+ - Viewing Bug Advanced Details [ Go Back ]
199 library core major sometimes 2004-03-08 10:37 2004-03-26 14:41
admin  
nepto  
normal  
resolved 0.6.2 (stable)  
fixed  
none  
none  
last line in config file is not parsed
thanks for the ecellent library, by far the best features and best usabilty for option and command line parsing I have seen so far.

There is a little bug in config file parsing, apparently a missing newline on last line screws up:

{NULL, 0, "threading", CFG_ULONG, (void *) &threading, 0},

...
...

con = cfg_get_context(acct_options);
cfg_set_cfgfile_context(con, 0, -1, cfg_file);

ret = cfg_parse(con);
if (ret != CFG_OK) {
printf("error parsing config file %s: ",acct);
cfg_fprint_error(con, stdout);
putchar('\n');
exit(1);
}

Now when "threading=1" is the last line in config file (without newline) it doesn't set "threading" and it doesnt complain either. After adding a newline in the config file it works as expected.
This bug was reported via e-mail by
Richard Zidlicky <rz AT linux-m68k.org>
0000199-threading.tgz.txt (2 KB) 1970-01-01 01:33
0000199-libcfgbug.tar.bz2.txt (1 KB) 1970-01-01 01:33
0000199-big-199-patch.diff.txt (1 KB) 1970-01-01 01:33

Bug Notes
nepto   
2004-03-15 11:33   
The problem is, that bug cannot be reproduced. I created tiny testing program, "threading" variable is still successfully parsed, even if there is no newline at the end of file.

1. Download threading.tgz file.
2. Unpack it in the libcfg+ root directory.
3. It will create threading/ subdirectory for you.
4. Go in and type "make".
5. Than run ./threading binary.
nepto   
2004-03-17 14:53   
Richard's reply:

On Mon, Mar 15, 2004 at 11:40:15AM +0100, Ondrej Jombik wrote:

Hi,

thanks for looking at it.

> Probably you are using some special libcfg+ context flags or some older
> version?

nothing fancy, I use version 0.6.2.

Tested your testprogram and it says "threading = 1". However a closer
look at "threading.cfg" revealed that it *has* a newline at the end of
file.. perhaps some helpfull editor added it.

# od -c threading.cfg
0000000 # \n # B u g # 0 0 0 0 1 9 9
0000020 : l a s t l i n e i n c
0000040 o n f i g f i l e i s n o
0000060 t p a r s e d \n # h t t p :
0000100 / / p l a t o n . s k / p r o j
0000120 e c t s / b u g _ v i e w _ a d
0000140 v a n c e d _ p a g e . p h p ?
0000160 f _ b u g _ i d = 1 9 9 \n # \n \n
0000200 # n o t e n o n e w l i n
0000220 e a t t h e e n d o f
0000240 t h i s f i l e \n \n t h r e a
0000260 d i n g = 1 \n
^^^^^
After deleting that newline I get
# ./threading threading.cfg
configuration file was successfully parsed
threading = 0

Attaching my testcase which is almost identical to yours anyway, wants
libcfg+ installed in standard location and "make" will do everything
including running the tests.

Richard
nepto   
2004-03-26 12:11   
A patch fixing this issue was uploaded.
nepto   
2004-03-26 14:41   
Commited into CVS.