Sunday, 25 January 2009

CommandLine.dll 1.5.9.1: fix the bug of release 1.5.

If you have read the previous blog post and you're a CommandLine.dll user, please download the latest release: 1.5.9.1 at CodePlex.

If you read the {project-root}/doc/ChangeLog, you will have some more details.

Bye! ;-)

4 comments:

  1. Buongiorno signore Scala ;)

    First of all, thanks for publishing this library. I think it has a lot of educative (and practical) value.

    There is a condition where an IndexOutOfRangeException is raised while parsing the argument list in libcmdline 1.5.9.1.

    In ArgumentParser.Create(), the test for long options is like this:
    if ( argument[0] == '-' && argument[1] == '-' ) { /*...*/ }The condition is cleared when
    argument == "-" (which is conventionally used by some programs to indicate STDIN).

    Regards
    RT

    ReplyDelete
  2. Ciao M. Scala,
    it seems I found another bug.
    The case happens when the last parameter is a long option which should take a string parameter.
    e.g.
    * correct behavior:
    prog.exe --option=1
    * incorrect behavior:
    prog.exe --option
    The string member is assigned a nullref instead of the method returning with failure.

    In LongOptionParser.cs, it should be like:
    if (!option.IsBoolean)
    {
    if (parts.Length == 1 && (argumentEnumerator.IsLast || !ArgumentParser.IsInputValue(argumentEnumerator.Next)))
    {
    return ParserState.Failure;
    }

    Another potential failure is when the argument is "":
    In ArgumentParser.cs a check is missing. Here's what it should be like:
    public static bool IsInputValue(string argument)
    {
    if ( argument.Length > 0 )
    {
    return argument[0] != '-';
    }
    return true;
    }
    Otherwise, an out-of-bounds index exception is raised.

    Regards,
    RT

    ReplyDelete
  3. Scratch the last bit. Here's a version that allows "-" as an input parameter, following the logic of my first comment:

    public static bool IsInputValue(string argument)
    {
    if ( argument.Length > 0 )
    {
    return argument.Equals("-", System.StringComparison.InvariantCulture) || argument[0] != '-';
    }
    return true;
    }

    ReplyDelete
  4. Dear Rasqualtwilight,
    please make a summary of your requests/bug reports on CodePlex using
    Issue Tracker feature.
    As soon as possible, I'll try to fix bugs or enhance the DLL, adding requested features/behaviours.
    Also, thanks for complimnents!

    ReplyDelete