Mail Archives: djgpp/1998/02/21/01:31:08
pneyz <pneyz AT bethany DOT edu> 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
- Raw text -