On Dec 17, 2009, at 9:24 AM, Simon Fraser wrote:
On Dec 16, 2009, at 10:02 PM, Peter Kasting wrote:
On Wed, Dec 16, 2009 at 9:12 PM, Alexey Proskuryakov
<[email protected]> wrote:
As current style rules say that tests for zero/non-zero should all
be done without equality comparisons. However, this rule can cause
significant readability problems if blindly applied to strcmp: if (!
strcmp(string, "foobar")) naturally reads as "does not equal".
I have always found !strcmp() to be more readable than the == 0
form, rather than less. I don't have a logical explanation for
this, it just reads as "if strcmp didn't find differences" to me.
I definitely wish we'd be consistent in our usage whichever way
people agree on.
The better solution here would be to have an inline function strequal
() that returns a bool, and use that instead of strcmp() when
testing for equality.
Agreed. Both !strcmp(...) and strcmp(...) == 0 are potentially
confusing, and we have it in our power to limit the potential
confusion to only one place in the code.
Regards,
Maciej
_______________________________________________
webkit-dev mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev