On Sun, 8 Jan 2012, Bruce Evans wrote:
...
Fixing these style bugs gives something like:
%%%
/*
* Set end pointer. First make sure that p1 is not
* the empty string..
*/
p2 = *p1 == '\0' ? p1 + p1 + 1;
Grr, typo. One of the `+'s should be `:'. I hope I inverted the logic
of this expression correctly.
/* Set conversion string. */
cs[0] = *p1;
cs[1] = '\0';
%%%
Possible furthe improvements:
- some programmers can't would add unnecessary parentheses for the ?:
operator. Even I might add them.
Since I changed `*p1' to `*p1 == `\0'' and inverted the logic, it has an
extra operator so it needs the parentheses more than before:
p2 = (*p1 == '\0' ? p1 : p1 + 1);
Not:
p2 = (*p1 == '\0') ? p1 : p1 + 1;
(since this adds parentheses where they are least needed), or
p2 = ((*p1 == '\0') ? p1 : p1 + 1);
(since this adds layers of parentheses which must be parsed to
see where they actually are).
Bruce
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"