poidasmith/winrun4j — pull request #2 by mpolak (2011-10-12 09:47:46+00:00)
Title: fixed: multiple spaces cause empty values in java String[] args

Hi Peter,

specified command line (5 spaces between first and second parameter and 2 spaces between fourth and fifth):

--first --second --th"ir"d "--fou rth" --fi"ve --six

is given to java String[] args with those values:

0. par: '--first'
1. par: ' '
2. par: ' '
3. par: ' '
4. par: ' '
5. par: '--second'
6. par: '--th"ir"d'
7. par: '--fou rth'
8. par: ' '
9. par: '--fi"ve --six'

But I preffer those values:

0. par: '--first'
1. par: '--second'
2. par: '--th"ir"d'
3. par: '--fou rth'
4. par: '--fi"ve --six'

If you find my patch useful, please merge it.

Thank you.

Actually, I don't know where to put some test code:

void testParseCommandLine(char* lpCmdLine) {

TCHAR *args[50];
int count;
ParseCommandLine(lpCmdLine, args, &count, 1);
printf ("--------------------\nLine: '%s'\n", lpCmdLine);
int i;
for (i = 0; i < count; i++) {

printf ("\t%i.arg :'%s'\n", i, args[i]);
}
}

int main(void) {

testParseCommandLine("--first --second");
testParseCommandLine(" --first --second ");
testParseCommandLine("\"--first\" --sec\"\"ond --th\"i r\"d");
testParseCommandLine(" ");
testParseCommandLine(" --fir\"st --second ");
return EXIT_SUCCESS;
}

Some compare (expected x given) should be implemented too.

Sincerely Mike.