Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!sdd.hp.com!wuarchive!uunet!mcsun!unido!mikros!mwtech!martin From: martin@mwtech.UUCP (Martin Weitzel) Newsgroups: comp.lang.c Subject: Re: "str*cmp()" ain't Boolean (was Re: v18i058: mush - Mail User's Shell, Part01/22) Message-ID: <1124@mwtech.UUCP> Date: 8 May 91 12:42:04 GMT References: <1991Apr24.220750.15603@robobar.co.uk> <20523@ogicse.ogi.edu> <1991May1.181910.28750@robobar.co.uk> <7609@auspex.auspex.com> <1 Reply-To: martin@mwtech.UUCP (Martin Weitzel) Organization: MIKROS Systemware, Darmstadt/W-Germany Lines: 29 In article <1991May7.012817.4395@rlgvax.Reston.ICL.COM> scc@rlgvax.Reston.ICL.COM (Stephen Carlson) writes: >#define streq !strcmp >#define strneq !strncmp What about: #define strdiff strcmp #define strndiff strncmp if (strdiff("foo", "bar") == 0) /* if there is no difference ... */ if (!strdiff("foo", "bar")) /* if there is no difference ... */ if (strdiff("foo", "bar")) /* if there IS a difference ... */ The nice thing with this approach is that you can almost blindly convert any source which does NOT use this style: %s/\/strdiff/g. The other nice thing is that, after you get tired of changing the sources written by others, sooner or later your eyes and brains get trained simply to READ any "strcmp" you encounter as "strdiff" ... (There's also a minor nitpick with the solution of the original poster: "*neq" tastes slightly as "not equal" to some programmers. I admit that "*ndiff" could also be misinterpreted in this way, but IMHO "neq" has made it into some computer languages, "ndiff" hasn't.) -- Martin Weitzel, email: martin@mwtech.UUCP, voice: 49-(0)6151-6 56 83