| 278 | } |
| 279 | |
| 280 | func (m *matcher) match(b []byte, beginText, endText bool) (end int) { |
| 281 | // fmt.Printf("%v\n", m.prog) |
| 282 | |
| 283 | d := m.startLine |
| 284 | if beginText { |
| 285 | d = m.start |
| 286 | } |
| 287 | // m.z1.dec(d.enc) |
| 288 | // fmt.Printf("%v (%v)\n", &m.z1, d==&dmatch) |
| 289 | for i, c := range b { |
| 290 | d1 := d.next[c] |
| 291 | if d1 == nil { |
| 292 | if c == '\n' { |
| 293 | if d.matchNL { |
| 294 | return i |
| 295 | } |
| 296 | d1 = m.startLine |
| 297 | } else { |
| 298 | d1 = m.computeNext(d, int(c)) |
| 299 | } |
| 300 | d.next[c] = d1 |
| 301 | } |
| 302 | d = d1 |
| 303 | // m.z1.dec(d.enc) |
| 304 | // fmt.Printf("%#U: %v (%v, %v, %v)\n", c, &m.z1, d==&dmatch, d.matchNL, d.matchEOT) |
| 305 | } |
| 306 | if d.matchNL || endText && d.matchEOT { |
| 307 | return len(b) |
| 308 | } |
| 309 | return -1 |
| 310 | } |
| 311 | |
| 312 | func (m *matcher) matchString(b string, beginText, endText bool) (end int) { |
| 313 | d := m.startLine |