botscanmatch

package
v1.230.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2026 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Matcher

type Matcher struct {
	// contains filtered or unexported fields
}

Matcher reproduces `grep -E -f` over a pattern list with bounded memory.

func Compile

func Compile(patterns []string) (*Matcher, error)

Compile builds a Matcher from ERE patterns (one per line, as in build_prefilter's $_pf: line-anchors already stripped). A pattern that fails RE2 compilation is skipped from the confirm step but its literal anchor (if any) still contributes to the prefilter (fail-open to a candidate, never a false negative). Returns an error only if NO pattern is usable.

func (*Matcher) Filter

func (m *Matcher) Filter(r io.Reader, w io.Writer) error

Filter streams lines from r and writes the matching ones to w (drop-in for grep -E -f). Lines are matched without their trailing newline; the newline is preserved on output.

func (*Matcher) MatchLine

func (m *Matcher) MatchLine(line []byte) bool

MatchLine reports whether grep -E -f would keep this line (any pattern matches).

func (*Matcher) Skipped

func (m *Matcher) Skipped() []string

Skipped returns patterns dropped because they failed RE2 compilation (e.g. the known |-delimiter mis-split alternation patterns). These are also non-functional in the shell matcher, so dropping them is behavior-preserving; the caller may log them for visibility.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL