coding style for who.c
Rob Landley
rob at landley.net
Sat Mar 11 13:23:54 PST 2006
On Saturday 11 March 2006 2:26 pm, Robin Farine wrote:
> On Saturday March 11 2006 19:50, Devin Bayer wrote:
> > In addition, I dislike having to make
> > if(a = strchr(str,'-'));
> > into
> > if((a = strchr(str,'-')));
> >
> > How can the second one be considered easier to read? To fix this
> > you need to add -Wno-parentheses to the CPPFLAGS.
>
> It is more to make explicit that you want an '=' instead of an '=='
> here than to improve readability, likewise for &, |, ... vs &&,
For & the C precedence rules are actually wrong, it should bind _tighter_ than
== and friends, but doesn't because way back in the day there was no && and &
was used for decision making. Meaning x==2 & y had to be (x==2) & y, not
x == (2 & y), because & had to fill in for &&.
By the time && was introduced, retroactively changing the precedence of &
would have broken too much existing code. So there you can't get away from
the parentheses...
Rob
--
Never bet against the cheap plastic solution.
More information about the busybox
mailing list