home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / c / 18624 < prev    next >
Encoding:
Text File  |  1992-12-21  |  1.4 KB  |  37 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!taumet!steve
  3. From: steve@taumet.com (Steve Clamage)
  4. Subject: Re: Questions about token merging and trigraphs
  5. Message-ID: <1992Dec18.162011.374@taumet.com>
  6. Organization: TauMetric Corporation
  7. References: <42098@pprg.eece.unm.edu.pprg.unm.edu> <1TA04E3@cdis-1.compu.com> <mcdonald.610@aries.scs.uiuc.edu> <2408@sdrc.COM>
  8. Date: Fri, 18 Dec 1992 16:20:11 GMT
  9. Lines: 26
  10.  
  11. scjones@thor.sdrc.com (Larry Jones) writes:
  12.  
  13. >> BECAUSE OF THEM, it is **IMPOSSIBLE** to write code that is both
  14. >> K&R I and ANSI!!!
  15.  
  16. >Nonsense -- simply avoid using those combinations of characters.  Since
  17. >you presumably have to continue to support your existing file format,
  18. >you can't follow that advice, but you can do something like:
  19.  
  20. >    const char delims[5][4] = {
  21. >        { '?', '?', '!', '\0' }, ...
  22.  
  23. Actually, it's easier than that.
  24.  
  25. You can replace, for example, "??!" with "?\?!".
  26. The escaped second question mark breaks up the trigraph.
  27.  
  28. This means you can write a simple filter (or editor script) which
  29. blindly replaces the trigraph sequences with versions as above.
  30. You can apply it to any code which was not intended to be compiled
  31. as having trigraphs.  The result will work with both K&R and Standard
  32. compilers.  (If you used a trigraph-like sequence in a comment, you
  33. would also get the escaped question mark there.)
  34. -- 
  35.  
  36. Steve Clamage, TauMetric Corp, steve@taumet.com
  37.