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

Re: Fishier code in handlefeatures



On Tue, Jan 6, 2015 at 1:24 AM, ZyX <kp-pav@xxxxxxxxx> wrote:
> 06.01.2015, 03:21, "Mikael Magnusson" <mikachu@xxxxxxxxx>:
>> mod_export int
>> handlefeatures(Module m, Features f, int **enables)
>> {
>>     if (!enables || *enables)
>>       return setfeatureenables(m, f, *enables);
>>     *enables = getfeatureenables(m, f);
>>     return 0;
>> }
>>
>> so if enables is NULL, we immediately do *enables? I'm not sure what's
>> intended here but obviously it somehow works.
>
> NULL is false, so if enables is NULL !enables is true and *enables is not evaluated due to short-circuiting. Nothing wrong here.

Read the next line too.

-- 
Mikael Magnusson



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