Re: [PATCH] PR cli/21688: Fix multi-line/inline command differentiation

Simon Marchi
2017-06-30T07:01:01Z

On 2017-06-30 00:21, Sergio Durigan Junior wrote:
> On Thursday, June 29 2017, Simon Marchi wrote:
>
>> On 2017-06-29 21:48, Sergio Durigan Junior wrote:
>>> On Thursday, June 29 2017, Simon Marchi wrote:
>>>> Another (maybe simpler) way would be to check
>>>>
>>>> else if (command_name_equals (cmd, "python") && *cmd_name == '\0')
>>>>
>>>> It's not clear when expressed like this though because cmd_name is
>>>> not
>>>> well named at this point (it points just after the command name).
>>>
>>> Hm, right. Would you prefer this way instead? I don't have a strong
>>> opinion on this.
>>
>> My opinion is the solution with the least code is probably best, if
>> they are equivalent otherwise, but I don't really mind. It's just a
>> suggestion.
>
> Right. I did some more tests here, and unfortunately your solution
> doesn't work for all cases. For example, if the user puts trailing
> whitespace on the command name (like "python "), *cmd_name will point
> to
> a whitespace after the call to lookup_cmd_1.

Ah, I got confused because there's some code that strips trailing
whitespaces, but it only set p_end, it doesn't modify the string.

> So here's second version of the patch, with the fixes you requested
> except the one above. WDYT?

That LGTM.

Simon