Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!mcvax!kth!osiris!uplog!lynx!pem From: pem@zyx.SE (Per-Erik Martin) Newsgroups: comp.lang.c Subject: Re: Want a way to strip comments from a Message-ID: <858@lynx.zyx.SE> Date: 23 Mar 89 16:25:38 GMT References: <7150@siemens.UUCP> <9900010@bradley> <4896@cbnews.ATT.COM> <852@lynx.zyx.SE> <9833@megaron.arizona.edu> Reply-To: pem@lynx.zyx.SE (Per-Erik Martin) Organization: ZYX Sweden AB, Stockholm, Sweden Lines: 33 In article <9833@megaron.arizona.edu> rupley@arizona.edu (John Rupley) writes: > >This one fails, too. Try: > > /***/ hi there /**/ > Oops! Well, if you change the '*'-case in 'in_comment:' to this: do { if ((c = (char)getchar()) == '/') goto into_code; } while (c == '*'); it should work better. (Funny no one found the other bug yet... What do you expect after 15 minutes? ;-) >Goes to show, for a quick and clean coding of a pattern-matching >automaton, think Lex. The Lex source that was posted is so simple it >would be hard to get the logic wrong. Two out of two C postings suggest >that it may be easier to err in coding the same automaton in C. > >Not to imply that C has no advantages -- following comparison is for >size of source and for time of uncommenting main.c of an emacs distribution: > >[...timings...] Another advantage with C is that it's portable outside the Unix universe... -- ------------------------------------------------------------------------------- - Per-Erik Martin, ZYX Sweden AB, Bangardsgatan 13, S-753 20 Uppsala, Sweden - - Email: pem@zyx.SE - -------------------------------------------------------------------------------