Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Incorrect evaluation of ~ test in ternary conditional



On 30.12.2017 03:40, Bart Schaefer wrote:
> Catching up on some old stuff ...
>
> On Mon, Dec 18, 2017 at 7:07 AM, Felix Uhl <felix.uhl@xxxxxxxxxx> wrote:
>>> -                   if (*ss++ == '/' && *ss)
>>> +                   if (*ss && *ss++ == '/' && *ss)
>>>                           arg--;
>>>
>>> I'm not sure whether (*ss == '/' && *++ss) would be equivalent, i.e.,
>>> I don't know why the original formulation skips over the first
>>> character whether or not it is a '/'.  Possibly to skip a leading '~'?
>> The original implementation doesn't skip the first character, does it?
> It does, because it increments ss regardless of whether or not the
> first character is '/'.  So if ss = "a", (*ss++ == '/' && *ss) is
> false because 'a' != '/', but ss now points at '\0' instead of at 'a'.
>
>> Did you actually test it?
> Yes.

Ah, you're absolutely correct. Thanks for the explanation!

I guess the only thing left then is to find out whether your fix breaks 
anything, correct?


Messages sorted by: Reverse Date, Date, Thread, Author