"str*cmp()" ain't Boolean (was Re: v18i058: mush - Mail User's Shell, Part01/22)

Ronald S H Khoo ronald at robobar.co.uk
Sat May 4 23:56:40 AEST 1991


guy at auspex.auspex.com (Guy Harris) writes:

>  >> My copy says !strncmp(p, login, strlen(login)) ....
>  >Ooops.  Finger trouble.  So does mine.
 
> Perhaps this is a hint that one shouldn't treat "strncmp()" as if it
> were a Boolean function, and should instead compare its result with 0
> explicitly, e.g. if you're comparing strings for equality, use "=="?

I must admit that the !strncmp() construct which appears all over the
code is one of the things that I find very hard to follow.  If I need to
understand a piece of the code, I tend to rewrite it as == 0 first
before looking at it :-).  But, it's *their* code, which I'm grateful
for, so I ain't going to complain about it.  Guy's right that I can't
read !strcmp, but I wasn't actually complaining about it, just noting
that I had seen or copied it wrong originally.
-- 
Ronald Khoo <ronald at robobar.co.uk> +44 81 991 1142 (O) +44 71 229 7741 (H)



More information about the Comp.lang.c mailing list