glob/util.go

23 lines
343 B
Go
Raw Normal View History

2015-12-24 17:54:54 +03:00
package glob
import (
"strings"
)
func indexByteNonEscaped(source string, needle, escape byte, shift int) int {
i := strings.IndexByte(source, needle)
2015-12-24 19:00:41 +03:00
if i == -1 {
return -1
}
if i == 0 {
return shift
2015-12-24 17:54:54 +03:00
}
if source[i-1] != escape {
return i + shift
}
2016-01-09 02:34:41 +03:00
sh := i + 1
2015-12-24 17:54:54 +03:00
return indexByteNonEscaped(source[sh:], needle, escape, sh)
2016-01-09 02:34:41 +03:00
}