StringConverter.cpp/GetArgvBeginEnd: Bug or feature?
Posted: 02 Apr 2021, 20:10
while implementing the new command feature with a TaskNumber-prefix
https://espeasy.readthedocs.io/en/lates ... mmand.html ("Command a specific task for multiple instances of a plugin")
I found that multiple optional parameters seem not be supported properly and I wonder if that is bug or feature
The problem: If you have two optional parameters like "command,a,b" you get in the pluginfrom the function "parseString(...)":
The problem is with 3), where the second parameter b is returned as if it was entered as first parameter
and it is not possible to distinguish between 3) and 4) and also not 5).
With this implementation, it is in practice solely possible to have the very last parameter(s) optional, because multiple sequential separators are always treated as one.
The question is, if the current behaviour is a bug or a feature
The problem, I think, is in the following sequence of "bool GetArgvBeginEnd(...)" in "StringConverter.cpp"
The solution is probably in the 5th row, because the separator "," is treated as regular character between 33 and 126.
I had expected there, in the if-clause, a "&& (d != separator)" or similar, which might solve the issue.
https://espeasy.readthedocs.io/en/lates ... mmand.html ("Command a specific task for multiple instances of a plugin")
I found that multiple optional parameters seem not be supported properly and I wonder if that is bug or feature
The problem: If you have two optional parameters like "command,a,b" you get in the pluginfrom the function "parseString(...)":
Code: Select all
par1 = parseString(string, 2); par2 = parseString(string, 3);
command-string par1 par2
--------------------------------------
1) command,a,b a b
2) command,a a
3) command,,b b <=== !!!
4) command,b b
I had instead expected for 3)
!) command,,b b
and also the following delivers the same as 3)
5) command,,,,,b b
6) command, ,b b
and it is not possible to distinguish between 3) and 4) and also not 5).
With this implementation, it is in practice solely possible to have the very last parameter(s) optional, because multiple sequential separators are always treated as one.
The question is, if the current behaviour is a bug or a feature
The problem, I think, is in the following sequence of "bool GetArgvBeginEnd(...)" in "StringConverter.cpp"
Code: Select all
if (!parenthesis && (c == ' ') && (d == ' ')) {}
else if (!parenthesis && (c == ' ') && (d == separator)) {}
else if (!parenthesis && (c == separator) && (d == ' ')) {}
else if (!parenthesis && (c == ' ') && (d >= 33) && (d <= 126)) {}
else if (!parenthesis && (c == separator) && (d >= 33) && (d <= 126)) {}
else
{
I had expected there, in the if-clause, a "&& (d != separator)" or similar, which might solve the issue.