When reading a configuration file using configFileLoad(), if the name of a value contains brackets, it will be incorrectly read. For example if the configuration file contains "xxx[aaa] = yyy", pzName will be xxx, and the string value will be "[aaa] = yyy".
My main issue with that is that the simple "name=value" options don't allow for any grouping (i.e., to specify attributes of an object previously defined). One solution for that would be for me to use brackets to distinguish objects. E.g., name[fish]=nemo, name[human]=nikos. However libopts doesn't pass the info in the brackets.
That can be reproduced using the following test program.
int main()
{
tOptionValue const * pov, *val;
pov = configFileLoad("config.test");
if (pov == NULL) exit(1);
val = optionGetValue(pov, NULL);
while(val != NULL) {
fprintf(stderr, "name: %s ", val->pzName);
if (val->valType == OPARG_TYPE_STRING)
fprintf(stderr, ", value: %s\n", val->v.strVal);
val = optionNextValue(pov, val);
}
}
This is actually a feature request, not a bug. But I don't have the time.
The file to fiddle is autoopts/configfile.c
If you or a GSOC student has time, please feel free.
Otherwise, sorry, this does not have a super flexible parser.
I think the bug is on the fact that valid text characters such as '[]' are not allowed as names. I'm currently working around it, but would be nice if it would be fixed. Nevertheless, for a GSOC student to take it (along with other enhancements to autogen) there must be a project proposed there. I'm no longer in GNU/FSF so I couldn't propose it.
Where should a name end? What about:
is that the same as
since these are the same:
I defined names as alphabetics (or underscore) followed by alphanumerics plus _ - ^ and : -- but not ending with ':' (since it is ambiguous). You want to add '[' and ']', but what about '$'? And others? Anyway, I'm certain I don't have time to do it.
option names and config file value names are scanned using the same
syntax: the first character must be of type VAR_FIRST and includes
following characters of class VALUE_NAME.
Changing that disrupts too much stuff. "Won't fix."