[Bug 258616] fgrep fails to find string that is present

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 20 Sep 2021 08:27:21 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=258616

--- Comment #3 from Darren Tucker <dtucker@dtucker.net> ---
oh, it looks like /usr/bin/grep is gnu/usr.bin/grep and not usr.bin/grep:

$ grep --version
grep (GNU grep) 2.5.1-FreeBSD [...]

building gnu/usr.bin/grep does indeed reproduce the problem.

I reproduced the problem with stock GNU grep v2.5.1 and found that it was fixed
between 2.18 and 2.19 in this upstream commit:

commit 757381e58d669729510a89c323d4698f9a81f6c0
Author: Norihiro Tanaka <noritnk@kcn.ne.jp>
Date:   Sat Mar 15 14:41:52 2014 +0900

    grep: use the Galil rule for Boyer-Moore algorithm in KWSet

    The Boyer-Moore algorithm is O(m*n), which means it may be much
    slower than the DFA.  Its Galil rule variant is O(n) and increases
    efficiency in the typical case; it skips sections that are known
    to match and does not compare more than once for a position in the text.
    To use the Galil rule, look for the delta2 shift at each position
    from the trie instead of the 'mind2' value.
    * src/kwset.c (struct kwset): Replace member 'mind2' with 'shift'.
    (kwsprep): Look for the delta2 shift.
    (bmexec): Use it.

-- 
You are receiving this mail because:
You are the assignee for the bug.