grep replacement

Brandon S. Allbery allbery at ncoast.UUCP
Mon Jun 13 08:30:23 AEST 1988


As quoted from <7944 at alice.UUCP> by andrew at alice.UUCP:
+---------------
| 	the right thing to do is to write a context program that takes
| input looking like "filename:linenumber:goo" and prints whatever context you like.
| we can then take this crap out of grep and diff and make it generally available
| for use with programs like the C compiler and eqn and so on. It can also do
| the right thing with folding together nearby lines. At least one good first
| cut has been put on the net but a C program sounds easy enough to do.
+---------------

A C version has been done; it handles pcc, grep -n, and cpp messages.  I
posted it 2 1/2 years ago.

It does *not* handle diff, since diff's messages are slightly different and
lack filename information; also, since it passes lines it doesn't understand
you'd end up with both regular and context diffs in the same output.  Now if
diff had an option to output in the format

		<filename>:<lineno>[-<lineno>]:<action>

we'd be all set -- I could modify it to handle ranges easily.  (Changes
would be output as "file1:n-m:file was\nfile2:n-m:now is", or something
similar.)

Note that it'd be nice if lint output messages this way as well.  I have a
postprocessor for lint which does this -- even with System V's lint that
can have lint1 and lint2 run separately via .ln files.
-- 
Brandon S. Allbery			  | "Given its constituency, the only
uunet!marque,sun!mandrill}!ncoast!allbery | thing I expect to be "open" about
Delphi: ALLBERY	       MCI Mail: BALLBERY | [the Open Software Foundation] is
comp.sources.misc: ncoast!sources-misc    | its mouth."  --John Gilmore



More information about the Comp.unix.questions mailing list