Dec 192017
BM is a fast pattern matching utility that uses the Boyer-Moore method, and includes full C source code.
File BMGREP2.ZIP from The Programmer’s Corner in
Category C Source Code
BM is a fast pattern matching utility that uses the Boyer-Moore method, and includes full C source code.
File Name File Size Zip Size Zip Type
BM.1 2810 1342 deflated
BM.C 5121 1640 deflated
BM.H 575 327 deflated
BMG.PRJ 133 85 deflated
EXECUTE.C 3188 1122 deflated
EXTERN.H 765 314 deflated
EXTRARC.G 623 307 deflated
GETPATFI.C 1589 602 deflated
GLOBAL.C 786 326 deflated
MAKEDESC.C 806 332 deflated
MAKEFILE 1641 581 deflated
MAKESKIP.C 1517 652 deflated
MATCHFOU.C 1199 542 deflated
MKDESCVE.C 970 408 deflated
MOVERESI.C 1300 565 deflated
PRINTLIN.C 1491 490 deflated
PUTUSAGE.C 997 438 deflated
README 2781 1398 deflated
SEARCH.C 1707 548 deflated
TCCONFIG.TC 1380 358 deflated

Download File BMGREP2.ZIP Here

Contents of the README file

Bm is a fast pattern matching utility, intended to be almost
identical in functionality to fgrep (ugh!) but much faster. It uses
the Boyer-Moore algorithm, as described in the papers listed below:

D.E. Knuth, J.H. Morris, V.R. Pratt,"Fast Pattern Matching in Strings",
SIAM J. Comput., 6(2), June 1977, 323-350,

Z. Galil,
"On Improving the Worst Case Running Time of the Boyer-Moore String
Matching Algorithm",
CACM, 22(9), Sept. 1979, ACM,

R.S. Boyer, J.S. Moore,"A Fast String Searching Algorithm", CACM, 20(10),
Oct. 1977, 762-772,

G. de V. Smit,"A Comparison of Three String Matching Algorithms",
Software - Practice and Experience, vol. 12, 1982, 57-66,

*** NOTE *** There are certain system dependencies in the code.
Please check whether your system uses "index" or "strchr" to
find a character in a string: this affects MkDescVec.c.
Also check whether your system uses or .
This affects match.c/bm.c, MkDescVec.c, and PrintLine.c.
Also check whether your system has "bcopy". If so, see MoveResidue.c

The files are MkDescVec.c, PrintLine.c, bm.c, and
Execute.c: search a file for the patterns
Extern.h: declarations of externs
GetPatFile.c: read in patterns from a file and set up a vector of
pattern descriptors
Global.c: global variables (complement to Extern.h)
MakeDesc.c: create a pattern descriptor for one pattern, including
skip tables, etc.
MakeSkip.c: make the skip tables for one pattern
Makefile: you can figure this one out for yourself
MatchFound.c: what to do when you actually FIND a pattern - print it,
update flags, etc.
MkDescVec.c: make a vector of pattern descriptors, given a string
of newline-separated patterns
MoveResidue.c: when you come to the end of the buffer, move the
unsearched "residue" to the beginning and start again
PrintLine.c: print the appropriate stuff after finding a match
PutUsage.c: mini-man page.
README: this file
Search.c: the guts. Implements B-M algorithm given a pattern, skip
tables for the pattern, and a buffer to search
bm.c: mainline. mostly interpreting the command line and tidying
up at the end. Calls Execute for each file.
bm.h: constants
bm.p: man page

Revision history:

9/30/87 -- Thomas A. Lundin
Graphics Unlimited Inc.
3000 Second Street North
Minneapolis, MN 55411
(612) 588-7571

a couple of trivial statement mods for Turbo-C compatibility;
some heavier changes for PC-DOS file argument handling;
added -m switch for forced case match;
made case-ignore the default condition.

10/05/87 -- Tom again.

added -t switch for screen output truncation to 80 chars;
fixed bug in case-ignore pattern matching.

 December 19, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>