zsh-workers
 help / color / mirror / code / Atom feed
From: Felix Uhl <felix.uhl@outlook.de>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: Incorrect evaluation of ~ test in ternary conditional
Date: Wed, 3 Jan 2018 10:44:42 +0000	[thread overview]
Message-ID: <VI1P194MB0047F41647368F5E265AA1049D1E0@VI1P194MB0047.EURP194.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <CAH+w=7aguzBsj76z6Bt6o8a6i_2UyzFPh07rjUnfAE1LLNW0UQ@mail.gmail.com>

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@outlook.de> 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?

      reply	other threads:[~2018-01-03 10:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-15 13:55 Felix Uhl
2017-12-16 22:01 ` Bart Schaefer
2017-12-18 15:07   ` Felix Uhl
2017-12-30  2:40     ` Bart Schaefer
2018-01-03 10:44       ` Felix Uhl [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=VI1P194MB0047F41647368F5E265AA1049D1E0@VI1P194MB0047.EURP194.PROD.OUTLOOK.COM \
    --to=felix.uhl@outlook.de \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).