diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2015-11-10 01:50:41 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2015-11-10 01:54:37 +0900 |
commit | 31278bcc6895089c97fc5d038cd1dd99053c3764 (patch) | |
tree | 5087edff8c881fa1b0c320b84d5952b7cc98d010 /src/pattern.go | |
parent | e7e86b68f4e6a27cc071cf48530ad6ae2c0c37bb (diff) |
Fix compatibility issues with OR operator and inverse terms
Diffstat (limited to 'src/pattern.go')
-rw-r--r-- | src/pattern.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/pattern.go b/src/pattern.go index 795fbb52..2abcf439 100644 --- a/src/pattern.go +++ b/src/pattern.go @@ -323,21 +323,24 @@ func (p *Pattern) basicMatch(item *Item) (int, int, int) { func (p *Pattern) extendedMatch(item *Item) []Offset { input := p.prepareInput(item) offsets := []Offset{} -Loop: for _, termSet := range p.termSets { + var offset *Offset for _, term := range termSet { pfun := p.procFun[term.typ] if sidx, eidx, tlen := p.iter(pfun, input, term.caseSensitive, p.forward, term.text); sidx >= 0 { if term.inv { - break Loop + continue } - offsets = append(offsets, Offset{int32(sidx), int32(eidx), int32(tlen)}) + offset = &Offset{int32(sidx), int32(eidx), int32(tlen)} break } else if term.inv { - offsets = append(offsets, Offset{0, 0, 0}) - break + offset = &Offset{0, 0, 0} + continue } } + if offset != nil { + offsets = append(offsets, *offset) + } } return offsets } |