integer base 10 in CFG_INT

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

integer base 10 in CFG_INT

peter (Bugzilla)-15
 Another issue I ran into with libconfuse was that I wanted to parse
08 in base 10, not let  (confuse.c line 615, in cfg_setopt)
val->number = strtol(value, &endptr, 0);
decide that it's octal, and then choke on the 8.

 I just changed the 0 to 10 in my copy of libconfuse, but perhaps
there should be CFGF_BASE10, and CFGF_BASE16, and CFGF_BASE_AUTO flags
to select the base passed to strtol.  I'd suggest making the default
BASE10, since that's what I was expecting without having given it any
thought at all.

int base = 10;
if (is_set(CFGF_BASE_AUTO, opt->flags)) base = 0;
else if (is_set(CFGF_BASE16, opt->flags)) base = 16;
    base = 10;
 // if (is_set(CFGF_BASE10, opt->flags)) base = 10;  // default anyway

#define X(x,y) x##y
Peter Cordes ;  e-mail: X(peter@cor ,

"The gods confound the man who first found out how to distinguish the hours!
 Confound him, too, who in this place set up a sundial, to cut and hack
 my day so wretchedly into small pieces!" -- Plautus, 200 BC

Confuse-devel mailing list
[hidden email]

signature.asc (368 bytes) Download Attachment