Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!pasteur!ames!ig!arizona!rupley From: rupley@arizona.edu (John Rupley) Newsgroups: comp.lang.c Subject: Re: not the way ... (was Re: Want a way to strip comments from a) Summary: close but no cigar Message-ID: <9881@megaron.arizona.edu> Date: 25 Mar 89 03:45:06 GMT References: <7150@siemens.UUCP> <9900010@bradley> <4221@omepd.UUCP> <1492@wpi.wpi.edu> Organization: U of Arizona CS Dept, Tucson Lines: 27 In article <1492@wpi.wpi.edu>, lfoard@wpi.wpi.edu (Lawrence C Foard) writes: > I tried the comment stripper I poster earlier today on these pathological > cases and it seems to get the right answer. Close, but no cigar. We're talking real pathology, here.... try: (echo '/*';yes '*//*';echo 'cosmetic */') | stripper_name Recursion blows the stack for your program. Previously posted strippers handle the above. If you insist on a compilable file, use a script to produce: /* [stack-blowing number of lines of *//*] */ compilable program text Why strip comments? (1) the original poster had a broken compiler that choked on comments; (2) the start of a cheap way to get a list or inverted index of identifiers (cpp does too much). I suspect all useful points (and more? :-) have been made about comment stripping -- perhaps this thread should die now. John Rupley rupley!local@megaron.arizona.edu