// Match returns the greatest named log level that is less than or equal to
// the receiver log level. For example, if the log level is 43, Match() will
// return 40 (Warning)
965235
func (l LogLevel) Match() LogLevel {
	if l >= Critical {
		return Critical
	}
	if l >= Error {
		return Error
	}
	if l >= Warning {
		return Warning
	}
	if l >= Notice {
		return Notice
	}
	if l >= Info {
		return Info
	}
	if l >= Debug {
		return Debug
	}
	if l >= Trace {
		return Trace
	}
	return 0
}
8066
func matchLevel(l *level, toks []string, results *SublistResult) {
	var pwc, n *node
	for i, t := range toks {
		if l == nil {
			return
		}
		if l.fwc != nil {
			addNodeToResults(l.fwc, results)
		}
		if pwc = l.pwc; pwc != nil {
			matchLevel(pwc.next, toks[i+1:], results)
		}
		n = l.nodes[t]
		if n != nil {
			l = n.next
		} else {
			l = nil
		}
	}
	if n != nil {
		addNodeToResults(n, results)
	}
	if pwc != nil {
		addNodeToResults(pwc, results)
	}
}
1250448
func (rc *RelationConstraint) match(ctx context.Context, s *search, pn blob.Ref, at time.Time) (ok bool, err error) {
	corpus := s.h.corpus
	if corpus == nil {
		// TODO: care?
		return false, errors.New("RelationConstraint requires an in-memory corpus")
	}

	var foreachClaim func(pn blob.Ref, at time.Time, f func(cl *camtypes.Claim) bool)
	// relationRef returns the relevant blobRef from the claim if cl defines
	// the kind of relation we are looking for, (blob.Ref{}, false) otherwise.
	var relationRef func(cl *camtypes.Claim) (blob.Ref, bool)
	switch rc.Relation {
	case "parent":
		foreachClaim = corpus.ForeachClaimBack
		relationRef = func(cl *camtypes.Claim) (blob.Ref, bool) { return cl.Permanode, true }
	case "child":
		foreachClaim = corpus.ForeachClaim
		relationRef = func(cl *camtypes.Claim) (blob.Ref, bool) { return blob.Parse(cl.Value) }
	default:
		panic("bogus")
	}

	var matcher matchFn
	if rc.Any != nil {
		matcher = rc.Any.matcher()
	} else {
		matcher = rc.All.matcher()
	}

	var anyGood bool
	var anyBad bool
	var lastChecked blob.Ref
	var permanodesChecked map[blob.Ref]bool // lazily created to optimize for common case of 1 match
	foreachClaim(pn, at, func(cl *camtypes.Claim) bool {
		if !rc.matchesAttr(cl.Attr) {
			return true // skip claim
		}
		if lastChecked.Valid() {
			if permanodesChecked == nil {
				permanodesChecked = make(map[blob.Ref]bool)
			}
			permanodesChecked[lastChecked] = true
			lastChecked = blob.Ref{} // back to zero
		}
		relRef, ok := relationRef(cl)
		if !ok {
			// The claim does not define the kind of relation we're looking for
			// (e.g. it sets a tag vale), so we continue to the next claim.
			return true
		}
		if permanodesChecked[relRef] {
			return true // skip checking
		}
		if !corpus.PermanodeHasAttrValue(cl.Permanode, at, cl.Attr, cl.Value) {
			return true // claim once matched permanode, but no longer
		}

		var bm camtypes.BlobMeta
		bm, err = s.blobMeta(ctx, relRef)
		if err != nil {
			return false
		}
		ok, err = matcher(ctx, s, relRef, bm)
		if err != nil {
			return false
		}
		if ok {
			anyGood = true
			if rc.Any != nil {
				return false // done. stop searching.
			}
		} else {
			anyBad = true
			if rc.All != nil {
				return false // fail fast
			}
		}
		lastChecked = relRef
		return true
	})
	if err != nil {
		return false, err
	}
	if rc.All != nil {
		return anyGood && !anyBad, nil
	}
	return anyGood, nil
}
1298665
func (info *MailboxInfo) Match(reference, pattern string) bool {
	name := info.Name

	if strings.HasPrefix(pattern, info.Delimiter) {
		reference = ""
		pattern = strings.TrimPrefix(pattern, info.Delimiter)
	}
	if reference != "" {
		if !strings.HasSuffix(reference, info.Delimiter) {
			reference += info.Delimiter
		}
		if !strings.HasPrefix(name, reference) {
			return false
		}
		name = strings.TrimPrefix(name, reference)
	}

	return info.match(name, pattern)
}
1182557
func Match(needles []string, source string, log *logrus.Entry) bool {
	classes, err := ReadClasses(source)
	if err != nil {
		log.Warnf("Could not parse classes file %s: %s", source, err)
		return false
	}

	matched := 0
	failed := 0

	for _, needle := range needles {
		if strings.HasPrefix(needle, "/") && strings.HasSuffix(needle, "/") {
			needle = strings.TrimPrefix(needle, "/")
			needle = strings.TrimSuffix(needle, "/")

			if hasClassMatching(needle, classes) {
				matched++
			} else {
				failed++
			}

			continue
		}

		if hasClass(needle, classes) {
			matched++
		} else {
			failed++
		}
	}

	return failed == 0 && matched > 0
}
678760
func (efm *Efm) Match(s string) *Match {
	ms := efm.regex.FindStringSubmatch(s)
	if len(ms) == 0 {
		return nil
	}
	match := &Match{}
	names := efm.regex.SubexpNames()
	for i, name := range names {
		if i == 0 {
			continue
		}
		m := ms[i]
		switch name {
		case "f":
			match.F = m
		case "n":
			match.N = mustAtoI(m)
		case "l":
			match.L = mustAtoI(m)
		case "c":
			match.C = mustAtoI(m)
		case "t":
			match.T = m[0]
		case "m":
			match.M = m
		case "r":
			match.R = m
		case "p":
			match.P = m
		case "v":
			match.V = mustAtoI(m)
		case "s":
			match.S = m
		}
	}
	return match
}
347589
func match(regex, text string) string {
	if matched, _ := regexp.MatchString(regex, text); matched {
		return regexp.MustCompile(regex).ReplaceAllString(text, "$1")
	}
	return ""
}
170886
func Match(pattern, name string) (bool, error) {
	return defaultGlobber.Match(pattern, name)
}
733994
func match(a, b string) bool {
	if wildcard(a) {
		return true
	}
	if wildcard(b) {
		return true
	}
	return strings.EqualFold(a, b)
}
428954
func (c Conversation) Match(position int) (string, error) {
	return c.match.Match(position)
}
1099027
func (t *termMatcher) match(term string) bool {
	for _, o := range t.TermOptions {
		if o.match(term) {
			return true
		}
	}
	return false
}
743396
func (chunk ChunkChecksum) Match(other ChunkChecksum) bool {
	weakEqual := bytes.Compare(chunk.WeakChecksum, other.WeakChecksum) == 0
	strongEqual := false
	if weakEqual {
		strongEqual = bytes.Compare(chunk.StrongChecksum, other.StrongChecksum) == 0
	}
	return weakEqual && strongEqual
}
22969
func (uo *UnitOption) Match(other *UnitOption) bool {
	return uo.Section == other.Section &&
		uo.Name == other.Name &&
		uo.Value == other.Value
}
457218
func (f MatchFunc) Match(w io.Writer, r io.Reader) bool {
	return f(w, r)
}
856354
func (args Args) Match(field, source string) bool {
	if args.ExactMatch(field, source) {
		return true
	}

	fieldValues := args.fields[field]
	for name2match := range fieldValues {
		match, err := regexp.MatchString(name2match, source)
		if err != nil {
			continue
		}
		if match {
			return true
		}
	}
	return false
}
432557
func (c *Constraint) Match(v string) bool {
	if c.Excludes(v) {
		return false
	}
	if c.Includes(v) {
		return true
	}
	if len(c.Include) == 0 {
		return true
	}
	return false
}
528395
func (a *archive) Match(n ast.Node, c *gosec.Context) (*gosec.Issue, error) {
	if node := a.calls.ContainsCallExpr(n, c, false); node != nil {
		for _, arg := range node.Args {
			var argType types.Type
			if selector, ok := arg.(*ast.SelectorExpr); ok {
				argType = c.Info.TypeOf(selector.X)
			} else if ident, ok := arg.(*ast.Ident); ok {
				if ident.Obj != nil && ident.Obj.Kind == ast.Var {
					decl := ident.Obj.Decl
					if assign, ok := decl.(*ast.AssignStmt); ok {
						if selector, ok := assign.Rhs[0].(*ast.SelectorExpr); ok {
							argType = c.Info.TypeOf(selector.X)
						}
					}
				}
			}

			if argType != nil && argType.String() == a.argType {
				return gosec.NewIssue(c, n, a.ID(), a.What, a.Severity, a.Confidence), nil
			}
		}
	}
	return nil, nil
}