[ILUG] strip comments utility
Smelly Pooh
plop at redbrick.dcu.ie
Fri Dec 8 01:07:22 GMT 2000
In reply to John McCormac's flatulent wordings,
>
>
> On Thu, 7 Dec 2000, Michael Turley wrote:
>
> > Does anyone know of a utility to strip C style (/* */)
> > comments from code. I have a rake of stuff with alot
> > of CVSg material which I would like to remove. Does
> > CVS have this type of functionality?
>
> You could try something along the lines of:
>
> perl -p -i.bak -e 's/oldstring/newstring/g' filename
>
> The incantation for the comments would be something along the lines of
> [\/*][a-zA-Z0-9-.,]*[*\/] though that may blow the machine up and do
> irreprable harm. Perhaps some of the Regexp experts here could give the
> right incantation.
cpp will strip comments, but also add stuff in include files
perl wise...
perl -n -e 'print unless (/\/\*/ .. /\*\//)' filename
should do fine
More information about the ILUG
mailing list