zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh workers <zsh-workers@zsh.org>
Subject: Re: Fishier code in handlefeatures
Date: Mon, 05 Jan 2015 23:45:39 -0800	[thread overview]
Message-ID: <150105234539.ZM10605@torch.brasslantern.com> (raw)
In-Reply-To: <CAHYJk3RZ_1pcJEfJjUqT8P+kxrEOqBudHvdZqWoK6ZsdkP=G4A@mail.gmail.com>
In-Reply-To: <2001361420504569@web17g.yandex.ru>

On Jan 6,  1:20am, Mikael Magnusson wrote:
}
}     if (!enables || *enables)
}       return setfeatureenables(m, f, *enables);
} 
} so if enables is NULL, we immediately do *enables? I'm not sure what's
} intended here but obviously it somehow works.

On Jan 6,  3:36am, ZyX wrote:
} 
} Guess this code means that `enables` is never NULL and first part of
} the condition should be dropped in order not to confuse people.

setfeatureenables() accepts a NULL third argument and is called that way
in a number of places; so I suspect that even though none of the current
module implementations calls handlefeatures() with a NULL third argument,
it was probably intended to permit that case.

None of this is described in zsh-development-guide, though.


diff --git a/Src/module.c b/Src/module.c
index 9e8b3cc..bcc0ba8 100644
--- a/Src/module.c
+++ b/Src/module.c
@@ -3367,7 +3367,7 @@ mod_export int
 handlefeatures(Module m, Features f, int **enables)
 {
     if (!enables || *enables)
-	return setfeatureenables(m, f, *enables);
+	return setfeatureenables(m, f, enables ? *enables : NULL);
     *enables = getfeatureenables(m, f);
     return 0;
 }

-- 
Barton E. Schaefer


      reply	other threads:[~2015-01-06  7:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-06  0:20 Mikael Magnusson
2015-01-06  0:24 ` ZyX
2015-01-06  0:32   ` Mikael Magnusson
2015-01-06  0:36     ` ZyX
2015-01-06  7:45       ` Bart Schaefer [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=150105234539.ZM10605@torch.brasslantern.com \
    --to=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).