[Toybox] [PATCH] id: various fixes.
Rob Landley
rob at landley.net
Tue Nov 5 17:17:40 PST 2019
On 11/4/19 10:56 PM, enh wrote:
> On Mon, Nov 4, 2019 at 8:12 PM Rob Landley <rob at landley.net> wrote:
>>
>>
>>
>> On 11/4/19 12:43 PM, enh via Toybox wrote:
>>> Handle unknown groups (fixes #117).
>>>
>>> Fix -G to show *all* groups, not just all supplementary groups.
>>>
>>> Fix -Z output to not include "context=".
>>
>> Sigh:
>>
>> - if (!FLAG(Z)) {
>> + if (!(toys.optflags&(FLAG_g|FLAG_Z))) {
>>
>> I need some kind of FLAGS(Z,g) syntax, but have no idea how to get the
>> preprocessor to do that. Hmmm...
>
> funnily enough, in this specific case we can rearrange the code a bit
> and remove these completely. i'll send you a patch.
Ok, I _do_ know how to do FLAG2(a,b) FLAG3(a,b,c) FLAG4(a,b,c,d) if it's worth
going there... (I keep thinking there should be something clever I can do with
varargs and recursive evaluation but it doesn't evaluate recursively.)
Sigh, FLAG() macro is kinda borderline at the best of times, it adds a _little_
convenience and readability, but the recent "FLAG(o) isn't using the local
variable o" confusion points out a downside, and FLAG(a) expanding to
(toys.optflags&FLAG_a) isn't a huge lift...
I've been doing FLAG(a)|FLAG(b)|FLAG(c) but that's long and awkward, and might
produce worse code depending on what the optimizer does (haven't checked, afraid
of what I'd find).
The hard calls are always the small/close ones, never the big ones.
>> + if (groups[i] != egid) {
>> + if ((grp=getgrgid(groups[i]))) showid(",", grp->gr_gid, grp->gr_name);
>> + else printf(",%u", groups[i]);
>>
>> Does this mean if the first group you show is unknown, it'll have a comma before it?
>
> no. there's an unconditional call to showid for the primary group
> above the loop, so there's alway been something printed.
Oh right, groups stored in 2 batches.
Rob
More information about the Toybox
mailing list