[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug in examples;boyer-moore.lisp

There is a subtle bug in the boyer-moore.lisp example file.  It does not
seriously effect its use by the revised Search Files command, but is a
problem for other applications.

The bug is that the variable BASE in find-bm-tables-in-file is incremented
by $bm-fuller-size each time a new block is fsread, but due to the way the
algorithm is written, it should advance by len-1 fewer bytes the first
time.  The effect of the bug is that for instances of the string found in
the first block read, the position reported is the beginning of the matched
string, whereas for subsequent blocks it is one byte before the end of the
matched string.  One way to fix it is to replace the line
            (incf base $bm-buffer-size)
            (if (zerop base)
              (setq base (- size len-1))
              (incf base $bm-buffer-size))

I have uploaded a new version of boyer-moore.lisp to the contrib directory
at ftp.digitool.com which makes this change as well as one other.  The
other is to allow the PATHNAME argument of bm-do-dialog-file-search to be a
list of pathnames identifying files; in this case, the search is over all
those files.  This makes it easier to augment a defsystem with search

Peter Szolovits