Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Fishier code in handlefeatures
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author