// convertNewlines converts "\r" and "\r\n" in s to "\n".
// The conversion happens in place, but the resulting slice may be shorter.
162361
func convertNewlines(s []byte) []byte {
	for i, c := range s {
		if c != '\r' {
			continue
		}

		src := i + 1
		if src >= len(s) || s[src] != '\n' {
			s[i] = '\n'
			continue
		}

		dst := i
		for src < len(s) {
			if s[src] == '\r' {
				if src+1 < len(s) && s[src+1] == '\n' {
					src++
				}
				s[dst] = '\n'
			} else {
				s[dst] = s[src]
			}
			src++
			dst++
		}
		return s[:dst]
	}
	return s
}
1028386
func parseLine(line string) (string, []string, error) {
	line = strings.TrimLeftFunc(line, unicode.IsSpace)
	shellwords.ParseEnv = false
	shellwords.ParseBacktick = false
	fields, err := shellwords.Parse(line)
	if err != nil {
		return "", []string{}, err
	}

	//ignore empty lines
	if len(fields) == 0 {
		return "", []string{}, nil
	}
	var cmd string
	if strings.HasPrefix(fields[0], "#") {
		cmd = "#"
	} else {
		cmd = fields[0]
	}
	args := fields[1:] //remove first element(cmd)
	for i, _ := range args {
		args[i] = strings.TrimFunc(args[i], unicode.IsSpace)
	}
	return cmd, args, nil
}
1090984
func convertNovaAddresses(publicIP string, addresses map[string][]nova.IPAddress) []network.Address {
	var machineAddresses []network.Address
	if publicIP != "" {
		publicAddr := network.NewScopedAddress(publicIP, network.ScopePublic)
		machineAddresses = append(machineAddresses, publicAddr)
	}
	// TODO(gz) Network ordering may be significant but is not preserved by
	// the map, see lp:1188126 for example. That could potentially be fixed
	// in goose, or left to be derived by other means.
	for netName, ips := range addresses {
		networkScope := network.ScopeUnknown
		if netName == "public" {
			networkScope = network.ScopePublic
		}
		for _, address := range ips {
			// If this address has already been added as a floating IP, skip it.
			if publicIP == address.Address {
				continue
			}
			// Assume IPv4 unless specified otherwise
			addrtype := network.IPv4Address
			if address.Version == 6 {
				addrtype = network.IPv6Address
			}
			machineAddr := network.NewScopedAddress(address.Address, networkScope)
			if machineAddr.Type != addrtype {
				logger.Warningf("derived address type %v, nova reports %v", machineAddr.Type, addrtype)
			}
			machineAddresses = append(machineAddresses, machineAddr)
		}
	}
	return machineAddresses
}
1081463
func trimEmptyLines(lines []string) []string {
	for len(lines) > 0 && lines[0] == "" {
		lines = lines[1:]
	}
	for len(lines) > 0 && lines[len(lines)-1] == "" {
		lines = lines[:len(lines)-1]
	}
	return lines
}
416324
func (s *Scheme) Convert(in, out interface{}) error {
	return s.raw.Convert(in, out)
}
667790
func (ui *UI) DisplayNewline() {
	ui.terminalLock.Lock()
	defer ui.terminalLock.Unlock()

	fmt.Fprintf(ui.Out, "\n")
}
1241838
func stringSlice(sliceLike interface{}) []string {
	var strSlice []string
	switch sl := sliceLike.(type) {
	case string:
		if len(sl) > 0 {
			parts, err := shlex.Split(expandEnv(sl))
			if err != nil {
				printErrorf("Error when parsing cmd `%v`: %v. Proceeding with %q.", sl, err, parts)
			}
			strSlice = append(strSlice, parts...)
		}
	case []interface{}:
		parts := make([]string, len(sl))
		for i, v := range sl {
			parts[i] = expandEnv(fmt.Sprintf("%v", v))
		}
		strSlice = append(strSlice, parts...)
	default:
		panic(StatusError{fmt.Errorf("unknown type: %v", sl), 65})
	}
	return strSlice
}
211713
func New() locales.Translator {
	return &nn{
		locale:                 "nn",
		pluralsCardinal:        []locales.PluralRule{2, 6},
		pluralsOrdinal:         nil,
		pluralsRange:           nil,
		decimal:                ",",
		group:                  " ",
		minus:                  "−",
		percent:                "%",
		perMille:               "‰",
		timeSeparator:          ":",
		inifinity:              "∞",
		currencies:             []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNH", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "kr", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "STN", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"},
		percentSuffix:          " ",
		currencyPositiveSuffix: " ",
		currencyNegativeSuffix: " ",
		monthsAbbreviated:      []string{"", "jan.", "feb.", "mars", "apr.", "mai", "juni", "juli", "aug.", "sep.", "okt.", "nov.", "des."},
		monthsNarrow:           []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"},
		monthsWide:             []string{"", "januar", "februar", "mars", "april", "mai", "juni", "juli", "august", "september", "oktober", "november", "desember"},
		daysAbbreviated:        []string{"sø.", "må.", "ty.", "on.", "to.", "fr.", "la."},
		daysNarrow:             []string{"S", "M", "T", "O", "T", "F", "L"},
		daysShort:              []string{"sø.", "må.", "ty.", "on.", "to.", "fr.", "la."},
		daysWide:               []string{"søndag", "måndag", "tysdag", "onsdag", "torsdag", "fredag", "laurdag"},
		periodsAbbreviated:     []string{"f.m.", "e.m."},
		periodsNarrow:          []string{"f.m.", "e.m."},
		periodsWide:            []string{"formiddag", "ettermiddag"},
		erasAbbreviated:        []string{"f.Kr.", "e.Kr."},
		erasNarrow:             []string{"f.Kr.", "e.Kr."},
		erasWide:               []string{"f.Kr.", "e.Kr."},
		timezones:              map[string]string{"HADT": "sumartid for Hawaii og Aleutene", "CHADT": "sumartid for Chatham", "MYT": "malaysisk tid", "EST": "normaltid for den nordamerikansk austkysten", "MDT": "MDT", "CAT": "sentralafrikansk tid", "CDT": "sumartid for sentrale Nord-Amerika", "HKT": "hongkongkinesisk normaltid", "IST": "indisk tid", "LHST": "normaltid for Lord Howe-øya", "MST": "MST", "HKST": "hongkongkinesisk sumartid", "VET": "venezuelansk tid", "HNCU": "kubansk normaltid", "WAST": "vestafrikansk sommartid", "PDT": "sumartid for den nordamerikanske stillehavskysten", "ADT": "sumartid for den nordamerikanske atlanterhavskysten", "AEST": "austaustralsk standardtid", "WIB": "vestindonesisk tid", "HEEG": "austgrønlandsk sumartid", "∅∅∅": "asorisk sumartid", "WART": "vestargentinsk normaltid", "HENOMX": "sumartid for nordvestlege Mexico", "JDT": "japansk sumartid", "ACST": "sentralaustralsk standardtid", "ACDT": "sentralaustralsk sommartid", "ACWST": "vest-sentralaustralsk standardtid", "GMT": "Greenwich middeltid", "AEDT": "austaustralsk sommartid", "SAST": "sørafrikansk tid", "COST": "kolombiansk sumartid", "HNPMX": "normaltid for den meksikanske stillehavskysten", "AST": "normaltid for den nordamerikanske atlanterhavskysten", "LHDT": "sumartid for Lord Howe-øya", "CLST": "chilensk sumartid", "ART": "argentinsk normaltid", "ARST": "argentinsk sumartid", "PST": "normaltid for den nordamerikanske stillehavskysten", "BOT": "boliviansk tid", "HNT": "normaltid for Newfoundland", "WIT": "austindonesisk tid", "OESZ": "austeuropeisk sommartid", "GFT": "tidssone for Fransk Guyana", "HAST": "normaltid for Hawaii og Aleutene", "COT": "kolombiansk normaltid", "ChST": "tidssone for Chamorro", "WESZ": "vesteuropeisk sommartid", "WITA": "sentralindonesisk tid", "EAT": "austafrikansk tid", "WAT": "vestafrikansk standardtid", "NZDT": "nyzealandsk sumartid", "JST": "japansk normaltid", "HNOG": "vestgrønlandsk normaltid", "MESZ": "sentraleuropeisk sommartid", "NZST": "nyzealandsk normaltid", "MEZ": "sentraleuropeisk standardtid", "TMST": "turkmensk sumartid", "AWST": "vestaustralsk standardtid", "HNPM": "normaltid for Saint-Pierre-et-Miquelon", "CHAST": "normaltid for Chatham", "OEZ": "austeuropeisk standardtid", "HECU": "kubansk sumartid", "EDT": "sumartid for den nordamerikansk austkysten", "ACWDT": "vest-sentralaustralsk sommartid", "HNNOMX": "normaltid for nordvestlege Mexico", "CLT": "chilensk normaltid", "AKDT": "alaskisk sumartid", "HEOG": "vestgrønlandsk sumartid", "UYST": "uruguayansk sumartid", "AWDT": "vestaustralsk sommartid", "GYT": "guyansk tid", "UYT": "uruguayansk normaltid", "CST": "normaltid for sentrale Nord-Amerika", "AKST": "alaskisk normaltid", "WARST": "vestargentinsk sumartid", "HAT": "sumartid for Newfoundland", "TMT": "turkmensk normaltid", "HEPM": "sumartid for Saint-Pierre-et-Miquelon", "SRT": "surinamsk tid", "HEPMX": "sumartid for den meksikanske stillehavskysten", "WEZ": "vesteuropeisk standardtid", "BT": "bhutansk tid", "SGT": "singaporsk tid", "ECT": "ecuadoriansk tid", "HNEG": "austgrønlandsk normaltid"},
	}
}
818984
func NewLine(pos position, ws string, item Item, le string) *Line {
	return &Line{
		pos: pos,

		ws:   ws,
		item: item,
		le:   le,
	}
}
1173360
func convertToLeftJoin(ajoin *sqlparser.JoinTableExpr) {
	newRHS := ajoin.LeftExpr
	// If the LHS is a join, we have to parenthesize it.
	// Otherwise, it can be used as is.
	if _, ok := newRHS.(*sqlparser.JoinTableExpr); ok {
		newRHS = &sqlparser.ParenTableExpr{
			Exprs: sqlparser.TableExprs{newRHS},
		}
	}
	ajoin.LeftExpr, ajoin.RightExpr = ajoin.RightExpr, newRHS
	ajoin.Join = sqlparser.LeftJoinStr
}
1322994
func ReplaceLeft(s, old, new string) string {
	old_len, new_len, i, n := len(old), len(new), 0, 0
	for ; i < len(s) && strings.HasPrefix(s[i:], old); n += 1 {
		i += old_len
	}

	// simple optimization
	if n == 0 {
		return s
	}

	// allocating space for the new string
	newLen := n*new_len + len(s[i:])
	replacement := make([]byte, newLen, newLen)

	j := 0
	for ; j < n*new_len; j += new_len {
		copy(replacement[j:j+new_len], new)
	}

	copy(replacement[j:], s[i:])
	return string(replacement)
}
81155
func New(Words, Results []string, Data []interface{}, Converter func(string) []byte) *InvertedSuffix {
	CharCount := 0
	NewWords := make([][]byte, len(Words))
	for i, Word := range Words {
		NewWord := Converter(Word)
		NewWords[i] = NewWord
		CharCount += len(NewWord)
	}
	WordIndex := make([]int, 0, CharCount)
	SuffixIndex := make([]int, 0, CharCount)
	for i, NewWord := range NewWords {
		for j := 0; j < len(NewWord); j++ {
			WordIndex = append(WordIndex, i)
			SuffixIndex = append(SuffixIndex, j)
		}
	}
	sort.Sort(&sortWrapper{WordIndex, SuffixIndex, NewWords})
	Suffixes := &InvertedSuffix{WordIndex, SuffixIndex, NewWords, Results, Data, Converter}
	return Suffixes
}
295854
func (t *Trie) convert(origin string) (result string) {
	root := t
	originRune := []rune(origin)
	result = ""

	for l := 0; l < len(originRune); l++ {
		t = root
		foundVal := ""
		depth := 0
		for i := 0; i+l < len(originRune); i++ {
			letter := string(originRune[l+i])
			if t.children[letter] == nil {
				// not found
				break
			}
			if len(t.children[letter].values) > 0 {
				foundVal = t.children[letter].values[0]
				depth = i
			}
			t = t.children[letter]
		}
		if foundVal != "" {
			result += foundVal
			l += depth
		} else {
			result += string(originRune[l : l+1])
		}
	}
	return result
}
548510
func (builder *Builder) NextLine(n uint) *Builder {
	return builder.With(NextLine(n))
}
1229881
func allSpaceWithNewline(str string) bool {
	var seenNewline = false
	for _, ch := range str {
		if !unicode.IsSpace(ch) {
			return false
		}
		if isEndOfLine(ch) {
			seenNewline = true
		}
	}
	return seenNewline
}
1226415
func ConvertSnapErrors(s []*SnapError) []serror.SnapError {
	rerrs := make([]serror.SnapError, len(s))
	for i, err := range s {
		rerrs[i] = serror.New(errors.New(err.ErrorString), GetFields(err))
	}
	return rerrs
}
1217095
func NewStringSlice(val []string, p *[]string) *StringSliceValue {
	*p = val
	return (*StringSliceValue)(p)
}