Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!cs.utexas.edu!rice!sun-spots-request From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.sys.sun Subject: Re: C comment remover Keywords: Source Message-ID: <4288@brazos.Rice.edu> Date: 9 Jan 90 21:57:43 GMT Sender: root@rice.edu Organization: Sun-Spots Lines: 20 Approved: Sun-Spots@rice.edu X-Refs: Original: v8n219, Replies: v8n231 X-Sun-Spots-Digest: Volume 9, Issue 9, message 1 of 14 In article <4041@brazos.Rice.edu> moraes@cs.toronto.edu (Mark Moraes) posted a (slow!) C comment remover I once wrote for fun in sed. Sed *is* a good tool to remove C comments, but it's clearer (and faster!) to divide the task into 3 parts, each having its own sed script. Furthermore there was a small bug in the original script: it replaced each comment by *zero* spaces instead of *one* space (easily fixed). Anyway, below are the 3 scripts, to be used as follows: sed -f Cstrip.1.sed [file] | sed -f Cstrip.2.sed | sed -f Cstrip.3.sed A still more twisted sample file is included. [[Ed's Note: Placed in archives at Rice.]] FTP: Hostname : titan.rice.edu (128.42.1.30) Directory: sun-source Filename : crem.shar Archive Server Address: archive-server@rice.edu Archive Server Command: send sun-source crem.shar