15
16
The three most significant features of agrep that are not supported by
16
17
the grep family are
17
18
1) the ability to search for approximate patterns;
18
for example, "agrep -2 homogenos foo" will find homogeneous as well
19
as any other word that can be obtained from homogenos with at most
20
2 substitutions, insertions, or deletions.
21
"agrep -B homogenos foo" will generate a message of the form
22
best match has 2 errors, there are 5 matches, output them? (y/n)
19
for example, "agrep -2 homogenos foo" will find homogeneous as well
20
as any other word that can be obtained from homogenos with at most
21
2 substitutions, insertions, or deletions.
22
"agrep -B homogenos foo" will generate a message of the form
23
best match has 2 errors, there are 5 matches, output them? (y/n)
23
24
2) agrep is record oriented rather than just line oriented; a record
24
is by default a line, but it can be user defined;
25
for example, "agrep -d '^From ' 'pizza' mbox"
26
outputs all mail messages that contain the keyword "pizza".
27
Another example: "agrep -d '$$' pattern foo" will output all
28
paragraphs (separated by an empty line) that contain pattern.
25
is by default a line, but it can be user defined;
26
for example, "agrep -d '^From ' 'pizza' mbox"
27
outputs all mail messages that contain the keyword "pizza".
28
Another example: "agrep -d '$$' pattern foo" will output all
29
paragraphs (separated by an empty line) that contain pattern.
29
30
3) multiple patterns with AND (or OR) logic queries.
30
For example, "agrep -d '^From ' 'burger,pizza' mbox"
31
outputs all mail messages containing at least one of the
32
two keywords (, stands for OR).
33
"agrep -d '^From ' 'good;pizza' mbox" outputs all mail messages
34
containing both keywords.
31
For example, "agrep -d '^From ' 'burger,pizza' mbox"
32
outputs all mail messages containing at least one of the
33
two keywords (, stands for OR).
34
"agrep -d '^From ' 'good;pizza' mbox" outputs all mail messages
35
containing both keywords.
36
37
Putting these options together one can ask queries like
87
88
7. fix a bug regarding exit status.
91
-------------------------------------------------------------------------------
92
REVISIONS TO AGREP, FALL '93
94
8. Options can now be specified in a single group of characters after one '-'.
97
9. Made agrep callable as a library routine from a separate function. The
98
interface is: memagrep(argc, argv, searchbufferlen, searchbuffer),
99
the pattern to be searched for and the options being specified EXACTLY as
100
if they are being specified on the command line. The only difference is
101
that instead of the file-names to look at, the user should specify a buffer
102
and its length. Sample user programs are in ../user directory.
104
In memagrep(), there are TWO peculiarities:
105
1. Peculiarity #1 -- at the end of the buffer, the user must have N bytes
106
of valid virtual memory, where N is the length of the pattern to be
107
searched. This space is used by agrep to speed up the checking of the
108
termination condition. Its contents are restored before memagrep()
109
returns -- however, some space must be there... else you'll get SIGSEGV.
110
I might trap segv and do a longjmp, but that'll be in a new version!
111
2. The search buffer must begin with a newline so that it is easy for
112
agrep to output matched lines. This also avoids some copying.
113
Ofcourse, if we copied the user's search buffer into another buffer which
114
meets both the above conditions, memagrep() will no longer be fast -- and
115
speed is the primary goal.
119
10. Added some filter-programs to make agrep search thru compressed files.
120
Also added some features in the Makefile which allows the user to build
121
an agrep with a dummyfilter so that agrep remains independent of tcompress.
122
The definitions needed in agrep to interface with tcompress are in defs.h
126
11. Added a library interface for searching thru a specified set of files,
127
fileagrep(), which is similar to memagrep(). This is used by glimpse.
128
Had to modify some other things and fix some bugs (see CHANGES).
130
- Dec 1993 (coding), Jan 1993 (debugging).
131
-------------------------------------------------------------------------------
133
CODING NOTE: sgrep.c and newmgrep.c use a similar while(fill_buf) loop
134
with start and end, while others use loops with an internal variable i.