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

Re: Fishier code in handlefeatures



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.

>
> --
> Mikael Magnusson



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