Newsgroups: comp.os.msdos.djgpp From: Yedema Subject: Re: Utility to strip comments from C/C++ source? Message-ID: Sender: yedema AT isthp1 Date: Fri, 20 Feb 1998 13:47:53 GMT References: <34ED0154 DOT 83D5B0C9 AT bethany DOT edu> Organization: Philips Research Laboratories Eindhoven, Netherlands Lines: 43 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk pneyz writes: > Is there a DJGPP utility to strip comments from files? I started coding > one then realized someone's probably already done it and it would save > me the trouble. > > If there isn't one, I'd like to submit the one I write (if I have to) to > the next release. Does anyone think this would be a (semi-)useful > utility? I think djgpp comes with the very nice utility `sed'. With the following script you can remove C-comments. (You do very, very much more though) ---8<--- #!/usr/bin/sed -f # Strip comments from C source. # Carlos J.Duarte # if no /* get next /\/\*/!b # here we've got an /*, append lines until get the corresponding # */ :x /\*\//!{ N bx } # delete /*...*/ s/\/\*.*\*\/// :t /^$/d ---8<--- This was written for unix/linux but can easily be ported to dos. (yes it looks like junk) -- Yedema, ing. W.F.D. Philips Research Laboratories Building WL 1 113, Prof. Holstlaan 4, 5656 AA Eindhoven, The Netherlands Phone: +31-40-743938 E-mail: yedema AT natlab DOT research DOT philips DOT com