// Temporary workaround for yaml lib generating incorrect yaml with long strings
// that do not contain \n.
971438
func forceMultiLine(s string) string {
	if len(s) > 60 && !strings.Contains(s, "\n") {
		s = s + "\n"
	}
	return s
}
218663
func GetDefaultPrefixLengths() (s6 []int, s4 []int) {
	// These *must* be in the order of longest prefix to shortest, as the
	// LPM implementation on older kernels depends on this ordering.
	s6 = []int{net.IPv6len * 8, 0}
	s4 = []int{net.IPv4len * 8, 0}
	return
}
1303469
func YAMLDoc(path string) (json.RawMessage, error) {
	yamlDoc, err := YAMLData(path)
	if err != nil {
		return nil, err
	}

	data, err := YAMLToJSON(yamlDoc)
	if err != nil {
		return nil, err
	}

	return data, nil
}
231005
func YAMLHandler(front string) (map[string]interface{}, error) {
	out := make(map[string]interface{})
	err := yaml.Unmarshal([]byte(front), out)
	if err != nil {
		return nil, err
	}
	return out, nil
}
386743
func LongestCommonPrefix(strs ...string) string {
	switch len(strs) {
	case 0:
		return "" // idiots
	case 1:
		return strs[0]
	}

	min := strs[0]
	max := strs[0]

	for _, s := range strs[1:] {
		switch {
		case s < min:
			min = s
		case s > max:
			max = s
		}
	}

	for i := 0; i < len(min) && i < len(max); i++ {
		if min[i] != max[i] {
			return min[:i]
		}
	}

	// In the case where lengths are not equal but all bytes
	// are equal, min is the answer ("foo" < "foobar").
	return min
}
136931
func MultiLineString(mls orb.MultiLineString, proj orb.Projection) orb.MultiLineString {
	for i := range mls {
		mls[i] = LineString(mls[i], proj)
	}

	return mls
}
282697
func numLabelsToString(numLabels map[string][]int64, numUnits map[string][]string) string {
	ls := []string{}
	for k, v := range numLabels {
		units := numUnits[k]
		var labelString string
		if len(units) == len(v) {
			values := make([]string, len(v))
			for i, vv := range v {
				values[i] = fmt.Sprintf("%d %s", vv, units[i])
			}
			labelString = fmt.Sprintf("%s:%v", k, values)
		} else {
			labelString = fmt.Sprintf("%s:%v", k, v)
		}
		ls = append(ls, labelString)
	}
	sort.Strings(ls)
	return strings.Join(ls, " ")
}
796704
func UnionString(args ...[]string) []string {
	// create a temporary map to hold the contents of the arrays
	tempMap := make(map[string]uint8)

	// write the contents of the arrays as keys to the map. The map values don't matter
	for _, arg := range args {
		for idx := range arg {
			tempMap[arg[idx]] = 0
		}
	}

	// the map keys are now unique instances of all of the array contents
	tempArray := make([]string, 0)
	for key := range tempMap {
		tempArray = append(tempArray, key)
	}

	return tempArray
}
1348612
func yaml_emitter_set_encoding(emitter *yaml_emitter_t, encoding yaml_encoding_t) {
	if emitter.encoding != yaml_ANY_ENCODING {
		panic("must set the output encoding only once")
	}
	emitter.encoding = encoding
}
773154
func (s ImportHelper) String() string {
	copy := s
	bytes, err := yaml.Marshal(copy)
	if err != nil {
		log.Info(nil, map[string]interface{}{
			"err": err,
		}, "failed to marshal space template to YAML")
		return ""
	}
	return string(bytes)
}
35191
func (y *Yaml) GetArraySize() (int, error) {
	a, err := y.Array()
	if err != nil {
		return 0, err
	}
	return len(a), nil
}
1020994
func FlattenString(nestedstr, prefix string, style SeparatorStyle) (string, error) {
	var nested map[string]interface{}
	err := json.Unmarshal([]byte(nestedstr), &nested)
	if err != nil {
		return "", err
	}

	flatmap, err := Flatten(nested, prefix, style)
	if err != nil {
		return "", err
	}

	flatb, err := json.Marshal(&flatmap)
	if err != nil {
		return "", err
	}

	return string(flatb), nil
}
1081373
func yamlTags(t reflect.Type) map[string]int {
	if t.Kind() != reflect.Struct {
		panic(errors.Errorf("cannot get yaml tags on type %s", t))
	}
	tags := make(map[string]int)
	for i := 0; i < t.NumField(); i++ {
		f := t.Field(i)
		if f.Type != reflect.TypeOf("") {
			continue
		}
		if tag := f.Tag.Get("yaml"); tag != "" {
			if i := strings.Index(tag, ","); i >= 0 {
				tag = tag[0:i]
			}
			if tag == "-" {
				continue
			}
			if tag != "" {
				f.Name = tag
			}
		}
		tags[f.Name] = i
	}
	return tags
}
818929
func (y *YAMLParser) Init(b *bytes.Buffer) bool {
	meta, data := splitBuffer(b, "---")
	if meta == nil || data == nil {
		return false
	}
	y.markdown = data

	m := make(map[string]interface{})
	if err := yaml.Unmarshal(meta.Bytes(), &m); err != nil {
		return false
	}
	y.metadata = NewMetadata(m)

	return true
}
978567
func longFilenameSupport(path string) string {
	if filepath.IsAbs(path) && !strings.HasPrefix(path, `\\`) {
		return `\\?\` + path
	}
	return path
}
1076097
func YamlToJSON(bytes []byte) (string, error) {
	var anomaly map[string]string

	if err := yaml.Unmarshal(bytes, &anomaly); err != nil {
		return "", err
	}

	retVal, err := json.Marshal(&anomaly)

	if err != nil {
		return "", err
	}

	return string(retVal), nil
}
638120
func (m *NamedString) ToRawInfo() interface{} {
	info := yaml.MapSlice{}
	if m == nil {
		return info
	}
	if m.Name != "" {
		info = append(info, yaml.MapItem{Key: "name", Value: m.Name})
	}
	if m.Value != "" {
		info = append(info, yaml.MapItem{Key: "value", Value: m.Value})
	}
	return info
}