Menu

#171 configFileLoad doesn't allow a pzName which contains brackets

autoopts
wont-fix
nobody
None
7
2015-03-03
2015-02-25
No

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.

include <stdio.h></stdio.h>

include <stdlib.h></stdlib.h>

include <autoopts options.h=""></autoopts>

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);
}

}

Discussion

  • Bruce Korb

    Bruce Korb - 2015-02-25
    • Priority: 1 --> 7
     
  • Bruce Korb

    Bruce Korb - 2015-02-25

    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.

     
  • Nikos Mavrogiannopoulos

    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.

     
  • Bruce Korb

    Bruce Korb - 2015-02-25

    Where should a name end? What about:

    foo[ bar ] = baz
    

    is that the same as

    foo[bar] baz
    

    since these are the same:

    foo = baz
    foo   baz
    foo : baz
    

    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.

     
  • Bruce Korb

    Bruce Korb - 2015-03-03
    • status: open --> wont-fix
     
  • Bruce Korb

    Bruce Korb - 2015-03-03

    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."

     

Log in to post a comment.