From 31278bcc6895089c97fc5d038cd1dd99053c3764 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Tue, 10 Nov 2015 01:50:41 +0900 Subject: Fix compatibility issues with OR operator and inverse terms --- src/pattern.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/pattern.go') 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 } -- cgit v1.2.3