Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!hc!lll-winken!uunet!mcvax!hp4nl!philmds!leo From: leo@philmds.UUCP (Leo de Wit) Newsgroups: comp.lang.c Subject: Re: Want a way to strip comments from a Message-ID: <987@philmds.UUCP> Date: 22 Mar 89 12:08:17 GMT References: <7150@siemens.UUCP> <9900010@bradley> <4896@cbnews.ATT.COM> <978@philmds.UUCP> <3114@nunki.usc.edu> <983@philmds.UUCP> <852@lynx.zyx.SE> Reply-To: leo@philmds.UUCP (Leo de Wit) Organization: Philips I&E DTS Eindhoven Lines: 19 In article <852@lynx.zyx.SE> pem@spunk.zyx.SE (Per-Erik Martin) writes: |Here's another example in C. It *is* a piece of cake (15 minutes work). |The problem can be described with a simple automata which is easily coded |in in C (with goto's, >yech<). I've tested it on most of the pathological |examples given in this group and it seems to work. [] Appearances are deceptive, it won't handle trigraphs. For instance, try: ??' (trigraph for ^) and your code thinks it is in_char. What's worse, on systems where char isn't signed and EOF == -1, it will fail to see EOF (suggestion: don't use a char to compare against EOF). Another cake that is hard to digest (let alone the goto's, it was baked in only 15 minutes) 8-). Leo. P.S. What's the benefit of having a separate program strip off comments anyway?