RHEL requires the source code for dependencies to be included in the srpm. The spec file already expects that, but we've only included the vendored modules (i.e., the `vendor` directory) in the `rhel-8.2.` branch. Move vendoring to master, so that we can build RHEL packages from it as well. This commit is the result of running `go mod vendor`, which includes the vendored sources and updates go.mod and go.sum files. Fedora requires the opposite: dependencies should not be vendored. The spec file already ignores the `vendor` directory by default.
48 lines
773 B
Go
48 lines
773 B
Go
package match
|
|
|
|
import (
|
|
"fmt"
|
|
"unicode/utf8"
|
|
)
|
|
|
|
type Range struct {
|
|
Lo, Hi rune
|
|
Not bool
|
|
}
|
|
|
|
func NewRange(lo, hi rune, not bool) Range {
|
|
return Range{lo, hi, not}
|
|
}
|
|
|
|
func (self Range) Len() int {
|
|
return lenOne
|
|
}
|
|
|
|
func (self Range) Match(s string) bool {
|
|
r, w := utf8.DecodeRuneInString(s)
|
|
if len(s) > w {
|
|
return false
|
|
}
|
|
|
|
inRange := r >= self.Lo && r <= self.Hi
|
|
|
|
return inRange == !self.Not
|
|
}
|
|
|
|
func (self Range) Index(s string) (int, []int) {
|
|
for i, r := range s {
|
|
if self.Not != (r >= self.Lo && r <= self.Hi) {
|
|
return i, segmentsByRuneLength[utf8.RuneLen(r)]
|
|
}
|
|
}
|
|
|
|
return -1, nil
|
|
}
|
|
|
|
func (self Range) String() string {
|
|
var not string
|
|
if self.Not {
|
|
not = "!"
|
|
}
|
|
return fmt.Sprintf("<range:%s[%s,%s]>", not, string(self.Lo), string(self.Hi))
|
|
}
|