// toSemVerRange converts the input to a semantic version range.
// E.g., ">=1.0"             -> ">=1.0.x"
//       ">=1"               -> ">=1.x"
//       ">=1 <=2.3"         -> ">=1.x <=2.3.x"
//       ">1 || >3.1.0 !4.2" -> ">1.x || >3.1.0 !4.2.x"
335647
func toSemVerRange(input string) string {
	var output []string
	fields := strings.Fields(input)
	for _, f := range fields {
		numDots, hasDigits := 0, false
		for _, c := range f {
			switch {
			case c == '.':
				numDots++
			case c >= '0' && c <= '9':
				hasDigits = true
			}
		}
		if hasDigits && numDots < semVerDotsCount {
			f = strings.TrimRight(f, " ")
			f += ".x"
		}
		output = append(output, f)
	}
	return strings.Join(output, " ")
}
138781
func (c *dlchunk) ByteRange() string {
	if len(c.withRange) != 0 {
		return c.withRange
	}

	return fmt.Sprintf("bytes=%d-%d", c.start, c.start+c.size-1)
}
310569
func (s *SeqSet) AddRange(Start, Stop uint32) {
	if (Stop < Start && Stop != 0) || Start == 0 {
		s.insert(Seq{Stop, Start})
	} else {
		s.insert(Seq{Start, Stop})
	}
}
769758
func (t *TSMReader) OverlapsKeyPrefixRange(min, max []byte) bool {
	return t.index.OverlapsKeyPrefixRange(min, max)
}
569119
func UInt8Range(min, max uint8) gopter.Gen {
	return UInt64Range(uint64(min), uint64(max)).
		Map(uint64To8).
		WithShrinker(UInt8Shrinker).
		SuchThat(func(v uint8) bool {
			return v >= min && v <= max
		})
}
686259
func (m *resolversMap) Range(f func(key string, value resolver.Resolver) bool) {
	m.data.Range(func(k, v interface{}) bool {
		key, ok := k.(string)
		if !ok {
			return false
		}
		value, ok := v.(resolver.Resolver)
		if !ok {
			return false
		}
		return f(key, value)
	})
}
1209555
func (b *Bitmap) SliceRange(start, end uint64) []uint64 {
	var a []uint64
	itr := b.Iterator()
	itr.Seek(start)
	for v, eof := itr.Next(); !eof && v < end; v, eof = itr.Next() {
		a = append(a, v)
	}
	return a
}
360390
func ParsePortRange(value string) (*PortRange, error) {
	pr := &PortRange{}
	err := pr.Set(value)
	if err != nil {
		return nil, err
	}
	return pr, nil
}
498441
func EnumRange(db XODB, v0 pgtypes.Anyenum, v1 pgtypes.Anyenum, v2 pgtypes.Anyenum) (pgtypes.Anyarray, error) {
	var err error

	// sql query
	const sqlstr = `SELECT pg_catalog.enum_range($1, $2, $3)`

	// run query
	var ret pgtypes.Anyarray
	XOLog(sqlstr, v0, v1, v2)
	err = db.QueryRow(sqlstr, v0, v1, v2).Scan(&ret)
	if err != nil {
		return pgtypes.Anyarray{}, err
	}

	return ret, nil
}
47336
func Parse(in string) *Version {
	v := &Version{}

	sp := strings.Split(in, ".")
	if len(sp) != 3 {
		v.err = errors.Errorf("passed string is not following to semver: %s", in)
		return v
	}

	v.major(sp[0])
	v.minor(sp[1])
	v.patch(sp[2])

	return v
}
625177
func getRange(expr string, r bounds) (uint64, error) {
	var (
		start, end, step uint
		rangeAndStep     = strings.Split(expr, "/")
		lowAndHigh       = strings.Split(rangeAndStep[0], "-")
		singleDigit      = len(lowAndHigh) == 1
		err              error
	)

	var extra uint64
	if lowAndHigh[0] == "*" || lowAndHigh[0] == "?" {
		start = r.min
		end = r.max
		extra = starBit
	} else {
		start, err = parseIntOrName(lowAndHigh[0], r.names)
		if err != nil {
			return 0, err
		}
		switch len(lowAndHigh) {
		case 1:
			end = start
		case 2:
			end, err = parseIntOrName(lowAndHigh[1], r.names)
			if err != nil {
				return 0, err
			}
		default:
			return 0, fmt.Errorf("Too many hyphens: %s", expr)
		}
	}

	switch len(rangeAndStep) {
	case 1:
		step = 1
	case 2:
		step, err = mustParseInt(rangeAndStep[1])
		if err != nil {
			return 0, err
		}

		// Special handling: "N/step" means "N-max/step".
		if singleDigit {
			end = r.max
		}
	default:
		return 0, fmt.Errorf("Too many slashes: %s", expr)
	}

	if start < r.min {
		return 0, fmt.Errorf("Beginning of range (%d) below minimum (%d): %s", start, r.min, expr)
	}
	if end > r.max {
		return 0, fmt.Errorf("End of range (%d) above maximum (%d): %s", end, r.max, expr)
	}
	if start > end {
		return 0, fmt.Errorf("Beginning of range (%d) beyond end of range (%d): %s", start, end, expr)
	}
	if step == 0 {
		return 0, fmt.Errorf("Step of range should be a positive number: %s", expr)
	}

	return getBits(start, end, step) | extra, nil
}
175534
func withRange(v string, start, end int) string {
	s, e := redisRange(len(v), start, end, true /* string getrange symantics */)
	return v[s:e]
}
1335535
func NewRange(from int, to int) (*Range, error) {
	return (&rangeBuilder{}).from(from, nil).to(to, nil).Range()
}
635224
func ParseRange(value string) (*Range, error) {
	value = strings.TrimSpace(value)
	b := &rangeBuilder{}
	if value == "" {
		return b.Range()
	}
	parts := strings.Split(value, "-")
	switch len(parts) {
	case 1:
		num, err := parseInt(parts[0])
		return b.from(num, err).to(num, err).Range()
	case 2:
		if parts[0] != "" {
			b.from(parseInt(parts[0]))
		}
		if parts[1] != "" {
			b.to(parseInt(parts[1]))
		}
		return b.Range()
	default:
		return nil, &ErrParseRange{}
	}
}
797106
func Convert_v1_IDRange_To_security_IDRange(in *v1.IDRange, out *security.IDRange, s conversion.Scope) error {
	return autoConvert_v1_IDRange_To_security_IDRange(in, out, s)
}
1182051
func Convert_core_LimitRangeItem_To_v1_LimitRangeItem(in *core.LimitRangeItem, out *v1.LimitRangeItem, s conversion.Scope) error {
	return autoConvert_core_LimitRangeItem_To_v1_LimitRangeItem(in, out, s)
}
660375
func (vr *versionRange) rangeFunc() Range {
	return Range(func(v Version) bool {
		return vr.c(v, vr.v)
	})
}