MCPcopy Index your code
hub / github.com/google/codesearch / grep

Function grep

regexp/regexp_test.go:165–189  ·  view source on GitHub ↗
(re *Regexp, b []byte)

Source from the content-addressed store, hash-verified

163}
164
165func grep(re *Regexp, b []byte) []int {
166 var m []int
167 lineno := 1
168 for {
169 i := re.Match(b, true, true)
170 if i < 0 {
171 break
172 }
173 start := bytes.LastIndex(b[:i], nl) + 1
174 end := i + 1
175 if end > len(b) {
176 end = len(b)
177 }
178 lineno += bytes.Count(b[:start], nl)
179 m = append(m, lineno)
180 if start < end && b[end-1] == '\n' {
181 lineno++
182 }
183 b = b[end:]
184 if len(b) == 0 {
185 break
186 }
187 }
188 return m
189}
190
191var grepTests = []struct {
192 re string

Callers 1

TestMatchFunction · 0.85

Calls 1

MatchMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…