// NewEfm converts a 'errorformat' string to regular expression pattern with
// flags and returns Efm.
//
// quickfix.c: efm_to_regpat
544516
func NewEfm(errorformat string) (*Efm, error) {
	var regpat bytes.Buffer
	var efmp byte
	var i = 0
	var incefmp = func() {
		i++
		efmp = errorformat[i]
	}
	efm := &Efm{}
	regpat.WriteRune('^')
	for ; i < len(errorformat); i++ {
		efmp = errorformat[i]
		if efmp == '%' {
			incefmp()
			// - do not support %>
			if re, ok := fmtpattern[efmp]; ok {
				regpat.WriteString(re)
			} else if efmp == '*' {
				incefmp()
				if efmp == '[' || efmp == '\\' {
					regpat.WriteByte(efmp)
					if efmp == '[' { // %*[^a-z0-9] etc.
						incefmp()
						for efmp != ']' {
							regpat.WriteByte(efmp)
							if i == len(errorformat)-1 {
								return nil, errors.New("E374: Missing ] in format string")
							}
							incefmp()
						}
						regpat.WriteByte(efmp)
					} else { // %*\D, %*\s etc.
						incefmp()
						regpat.WriteByte(efmp)
					}
					regpat.WriteRune('+')
				} else {
					return nil, fmt.Errorf("E375: Unsupported %%%v in format string", string(efmp))
				}
			} else if (efmp == '+' || efmp == '-') &&
				i < len(errorformat)-1 &&
				strchar("DXAEWICZGOPQ", errorformat[i+1]) {
				if efmp == '+' {
					efm.flagplus = true
					incefmp()
				} else if efmp == '-' {
					efm.flagminus = true
					incefmp()
				}
				efm.prefix = efmp
			} else if strchar(`%\.^$?+[`, efmp) {
				// regexp magic characters
				regpat.WriteByte(efmp)
			} else if efmp == '#' {
				regpat.WriteRune('*')
			} else {
				if strchar("DXAEWICZGOPQ", efmp) {
					efm.prefix = efmp
				} else {
					return nil, fmt.Errorf("E376: Invalid %%%v in format string prefix", string(efmp))
				}
			}
		} else { // copy normal character
			if efmp == '\\' && i < len(errorformat)-1 {
				incefmp()
			} else if strchar(`.+*()|[{^$`, efmp) { // escape regexp atoms
				regpat.WriteRune('\\')
			}
			regpat.WriteByte(efmp)
		}
	}
	regpat.WriteRune('$')
	re, err := regexp.Compile(regpat.String())
	if err != nil {
		return nil, err
	}
	efm.regex = re
	return efm, nil
}
868062
func NewValidationError(errorText string, errorFlags uint32) *ValidationError {
	return &ValidationError{
		text:   errorText,
		Errors: errorFlags,
	}
}
982902
func (self *_RegExp_parser) error(offset int, msg string, msgValues ...interface{}) error {
	err := fmt.Errorf(msg, msgValues...)
	self.errors = append(self.errors, err)
	return err
}
1229269
func (lx *lexer) errorf(format string, values ...interface{}) stateFn {
	lx.items <- item{
		itemError,
		fmt.Sprintf(format, values...),
		lx.line,
	}
	return nil
}
21581
func (c *C) Errorf(format string, args ...interface{}) {
	c.logCaller(1)
	c.logString(fmt.Sprintf("Error: "+format, args...))
	c.logNewLine()
	c.Fail()
}
116166
func (ns *Namespace) Errorf(format string, a ...interface{}) string {
	ns.errorLogger.Printf(format, a...)
	return _fmt.Sprintf(format, a...)
}
881557
func NewFlagSetWithEnvPrefix(name string, prefix string, errorHandling ErrorHandling) *FlagSet {
	f := NewFlagSet(name, errorHandling)
	f.envPrefix = prefix
	return f
}
898900
func NewValidationError(err string, warnings ...string) ValidateResponseModel {
	return ValidateResponseModel{
		Error:    err,
		Warnings: warnings,
	}
}
309150
func Errorf(level string, format string, args ...interface{}) {
	std.Errorf(level, format, args...)
}
1244059
func resultErrorFormatNumber(n float64) string {

	if isFloat64AnInteger(n) {
		return fmt.Sprintf("%d", int64(n))
	}

	return fmt.Sprintf("%g", n)
}
86071
func (m *M) AddRegexp(pattern *regexp.Regexp, minifier Minifier) {
	m.mutex.Lock()
	m.pattern = append(m.pattern, patternMinifier{pattern, minifier})
	m.mutex.Unlock()
}
1006785
func Errorf(format string, a ...interface{}) error {
	return fmt.Errorf(format, wrap(a, false)...)
}
431148
func NewRegexStringComparator(pattern string, patternFlags int32,
	charset, engine string) *RegexStringComparator {
	return &RegexStringComparator{
		Pattern:      proto.String(pattern),
		PatternFlags: proto.Int32(patternFlags),
		Charset:      proto.String(charset),
		Engine:       proto.String(engine),
	}
}
354879
func (l *leveledLoggerPrintferShim) Errorf(format string, v ...interface{}) {
	if l.level >= printferLevelError {
		l.logger.Printf(format+"\n", v...)
	}
}
703036
func NewIf(a, operator, b string) (If, error) {
	if _, ok := conditions[operator]; !ok {
		return If{}, fmt.Errorf("invalid operator %v", operator)
	}
	return If{
		A:        a,
		Operator: operator,
		B:        b,
	}, nil
}
64500
func (l *pageLexer) errorf(format string, args ...interface{}) stateFunc {
	l.items = append(l.items, Item{tError, l.start, []byte(fmt.Sprintf(format, args...))})
	return nil
}
499360
func RegexError(msg string, fmt string, examples ...string) string {
	if len(examples) == 0 {
		return msg + " (regex used for validation is '" + fmt + "')"
	}
	msg += " (e.g. "
	for i := range examples {
		if i > 0 {
			msg += " or "
		}
		msg += "'" + examples[i] + "', "
	}
	msg += "regex used for validation is '" + fmt + "')"
	return msg
}