mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
explanatory comment for CompileMasks
This commit is contained in:
parent
be0dedf260
commit
d092f6b330
@ -432,12 +432,6 @@ func (set *UserMaskSet) Length() int {
|
|||||||
return len(set.masks)
|
return len(set.masks)
|
||||||
}
|
}
|
||||||
|
|
||||||
// setRegexp generates a regular expression from the set of user mask
|
|
||||||
// strings. Masks are split at the two types of wildcards, `*` and
|
|
||||||
// `?`. All the pieces are meta-escaped. `*` is replaced with `.*`,
|
|
||||||
// the regexp equivalent. Likewise, `?` is replaced with `.`. The
|
|
||||||
// parts are re-joined and finally all masks are joined into a big
|
|
||||||
// or-expression.
|
|
||||||
func (set *UserMaskSet) setRegexp() {
|
func (set *UserMaskSet) setRegexp() {
|
||||||
set.RLock()
|
set.RLock()
|
||||||
maskExprs := make([]string, len(set.masks))
|
maskExprs := make([]string, len(set.masks))
|
||||||
|
@ -46,6 +46,9 @@ func CompileGlob(glob string, submatch bool) (result *regexp.Regexp, err error)
|
|||||||
return regexp.Compile(buf.String())
|
return regexp.Compile(buf.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Compile a list of globs into a single or-expression that matches any one of them.
|
||||||
|
// This is used for channel ban/invite/exception lists. It's applicable to k-lines
|
||||||
|
// but we're not using it there yet.
|
||||||
func CompileMasks(masks []string) (result *regexp.Regexp, err error) {
|
func CompileMasks(masks []string) (result *regexp.Regexp, err error) {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
buf.WriteString("^(")
|
buf.WriteString("^(")
|
||||||
|
Loading…
Reference in New Issue
Block a user