home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / c / 16281 < prev    next >
Encoding:
Text File  |  1992-11-10  |  2.0 KB  |  47 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!ferkel.ucsb.edu!taco!gatech!darwin.sura.net!zaphod.mps.ohio-state.edu!cs.utexas.edu!csc.ti.com!tilde.csc.ti.com!mksol!mccall
  3. From: mccall@mksol.dseg.ti.com (fred j mccall 575-3539)
  4. Subject: Re: Hows this for odd
  5. Message-ID: <1992Nov10.161008.27590@mksol.dseg.ti.com>
  6. Organization: Texas Instruments Inc
  7. References: <1992Nov9.102217.23060@monu6.cc.monash.edu.au> <1992Nov9.231340.10201@ptcburp.ptcbu.oz.au>
  8. Date: Tue, 10 Nov 1992 16:10:08 GMT
  9. Lines: 36
  10.  
  11. In <1992Nov9.231340.10201@ptcburp.ptcbu.oz.au> michi@ptcburp.ptcbu.oz.au (Michael Henning) writes:
  12.  
  13. >bena@yoyo.cc.monash.edu.au (Ben Aveling) writes:
  14.  
  15. >>Just recently I saw the following fragment of code, and I thought I'd share
  16. >>it with you all.  (This is real code, part of a real program people will
  17. >>pay money for.)
  18.  
  19. >>    ... ,(i==0)?TRUE:FALSE,...
  20.  
  21. >From the source code for a popular UNIX debugger:
  22.  
  23. >    if (strncmp(p, "", 1) != 0) {
  24. >        ...
  25. >    }
  26.  
  27. >There are lots of gems like that around :-(
  28.  
  29. Well, I generally do the explicit comparison on string comparisons,
  30. too, because I ran into at least one compiler that would fail to
  31. return the 'correct' answer if the result was negative (it would claim
  32. 'false', even though a non-zero ought to be true).  Yes, this compiler
  33. was broken, but given the choice between working around where it was
  34. broken and having my code be broken, I chose the former.
  35.  
  36. I'm afraid I find this other idiom ("(i==0)?TRUE:FALSE") to be just a
  37. bit peculiar, though.  Someone else made the point that TRUE and FALSE
  38. might have been redefined to some 'program specific' values, but why
  39. write code that works against the language by defining your own
  40. 'special' TRUE and FALSE values?
  41.  
  42. -- 
  43. "Insisting on perfect safety is for people who don't have the balls to live
  44.  in the real world."   -- Mary Shafer, NASA Ames Dryden
  45. ------------------------------------------------------------------------------
  46. Fred.McCall@dseg.ti.com - I don't speak for others and they don't speak for me.
  47.