perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Malcolm J Harwood <mjhlist-modp...@liminalflux.net>
Subject Re: svn commit: r372010 - /perl/modperl/trunk/src/modules/perl/modperl_cmd.c
Date Thu, 26 Jan 2006 01:59:14 GMT
On Wednesday 25 January 2006 11:29 pm, Philip M. Gollucci wrote:

> >-    if(0 == strncasecmp(arg, "+inherit", 8)) {
> >+    if (0 == strncasecmp(arg, "+inherit", 8)) {
> >         modperl_cmd_options(parms, mconfig, "+InheritSwitches");
> >     }
> >     else {
>
> Isn't the normal c idiom
> if (!strncasecmp(....) ?

> I don't think I've ever seen that form.... (though correct)

It's somewhat more common with C++. The logic is this:
if you typo:
	if (var == 0) ...
as
	if (var = 0) ...
it will compile, often without even a warning (though more recent versions of 
gcc do complain), but not do what you expect and the bug can be very hard to 
spot. However if you typo:
	if (0 == var) ...
as 
	if (0 = var) ...
you'll get a compile time error, as you can't assign to a constant. So whilst 
it reads strangely to most people, some get in the habit of using that form. 
It wouldn't make a difference in this case, as far as I can tell though.




-- 
"I just think it's rather odd that a nation that prides itself on its virility
 should feel compelled to strap on forty pounds of protective gear just in
 order to play rugby."
- Giles, Buffy the Vampires Slayer: Some Assembly Required

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message