// parseChunkFmt
774390
func (wav *Reader) parseChunkFmt() (err error) {
	wav.chunkFmt = new(riffChunkFmt)

	if err = binary.Read(wav.input, binary.LittleEndian, wav.chunkFmt); err != nil {
		return err
	}

	if wav.canonical == false {
		var extraparams uint32
		// Get extra params size
		if err = binary.Read(wav.input, binary.LittleEndian, &extraparams); err != nil {
			return err
		}
		// Skip them
		if _, err = wav.input.Seek(int64(extraparams), os.SEEK_CUR); err != nil {
			return err
		}
	}

	// Is audio supported ?
	if wav.chunkFmt.AudioFormat != 1 {
		return ErrFormatNotSupported
	}

	return nil
}
241368
func (fs FS) ParseMDStat() (mdstates []MDStat, err error) {
	mdStatusFilePath := fs.Path("mdstat")
	content, err := ioutil.ReadFile(mdStatusFilePath)
	if err != nil {
		return []MDStat{}, fmt.Errorf("error parsing %s: %s", mdStatusFilePath, err)
	}

	mdStates := []MDStat{}
	lines := strings.Split(string(content), "\n")
	for i, l := range lines {
		if l == "" {
			continue
		}
		if l[0] == ' ' {
			continue
		}
		if strings.HasPrefix(l, "Personalities") || strings.HasPrefix(l, "unused") {
			continue
		}

		mainLine := strings.Split(l, " ")
		if len(mainLine) < 3 {
			return mdStates, fmt.Errorf("error parsing mdline: %s", l)
		}
		mdName := mainLine[0]
		activityState := mainLine[2]

		if len(lines) <= i+3 {
			return mdStates, fmt.Errorf(
				"error parsing %s: too few lines for md device %s",
				mdStatusFilePath,
				mdName,
			)
		}

		active, total, size, err := evalStatusline(lines[i+1])
		if err != nil {
			return mdStates, fmt.Errorf("error parsing %s: %s", mdStatusFilePath, err)
		}

		// j is the line number of the syncing-line.
		j := i + 2
		if strings.Contains(lines[i+2], "bitmap") { // skip bitmap line
			j = i + 3
		}

		// If device is syncing at the moment, get the number of currently
		// synced bytes, otherwise that number equals the size of the device.
		syncedBlocks := size
		if strings.Contains(lines[j], "recovery") || strings.Contains(lines[j], "resync") {
			syncedBlocks, err = evalBuildline(lines[j])
			if err != nil {
				return mdStates, fmt.Errorf("error parsing %s: %s", mdStatusFilePath, err)
			}
		}

		mdStates = append(mdStates, MDStat{
			Name:          mdName,
			ActivityState: activityState,
			DisksActive:   active,
			DisksTotal:    total,
			BlocksTotal:   size,
			BlocksSynced:  syncedBlocks,
		})
	}

	return mdStates, nil
}
437101
func (p *Parser) ParseBytes(b []byte, v interface{}) error {
	return p.Parse(bytes.NewReader(b), v)
}
908836
func newChunkedSeq(v *PVector, i int, offset int) *chunkedSeq {
	return newChunkedSeqM(nil, v, v.arrayFor(i), i, offset)
}
212255
func ParseMessageFileBytes(buf []byte, path string, unmarshalFuncs map[string]UnmarshalFunc) (*MessageFile, error) {
	lang, format := parsePath(path)
	tag := language.Make(lang)
	messageFile := &MessageFile{
		Path:   path,
		Tag:    tag,
		Format: format,
	}
	if len(buf) == 0 {
		return messageFile, nil
	}
	unmarshalFunc := unmarshalFuncs[messageFile.Format]
	if unmarshalFunc == nil {
		if messageFile.Format == "json" {
			unmarshalFunc = json.Unmarshal
		} else {
			return nil, fmt.Errorf("no unmarshaler registered for %s", messageFile.Format)
		}
	}
	var err error
	var raw interface{}
	if err = unmarshalFunc(buf, &raw); err != nil {
		return nil, err
	}

	if messageFile.Messages, err = recGetMessages(raw, isMessage(raw), true); err != nil {
		return nil, err
	}

	return messageFile, nil
}
557795
func parseAct(desc string) (string, actFunc) {
	for k, v := range actMap {
		if strings.HasPrefix(desc, k) {
			return k, v
		}
	}
	return "", nil
}
1007714
func parseAmzDate(amzDateStr string) (amzDate time.Time, apiErr APIErrorCode) {
	for _, dateFormat := range amzDateFormats {
		amzDate, err := time.Parse(dateFormat, amzDateStr)
		if err == nil {
			return amzDate, ErrNone
		}
	}
	return time.Time{}, ErrMalformedDate
}
1053776
func ParseString(cfg API, input string) *Iterator {
	return ParseBytes(cfg, []byte(input))
}
937847
func formatCommitDesc(desc string) template.HTML {
	chunks := []formatChunk{{str: desc}}
	// Replace BUG: lines with URLs by rewriting all bug numbers with
	// links. Run this first so later rules do not interfere with it. This
	// allows a line like the following to work:
	//
	// Bug: https://crbug.com/1234, 5678
	chunks = replaceAllInChunks(chunks, rBUGLINE, func(s string) template.HTML {
		sChunks := []formatChunk{{str: s}}
		// The call later in the parent function will not reach into
		// sChunks, so run it separately.
		sChunks = replaceLinkChunks(sChunks)
		sChunks = replaceAllInChunks(sChunks, rBUG, func(sBug string) template.HTML {
			path := strings.Replace(strings.Replace(sBug, "#", "", 1), ":", "/", 1)
			return makeLink(sBug, "https://crbug.com/"+path)
		})
		return chunksToHTML(sChunks)
	})
	chunks = replaceLinkChunks(chunks)
	return chunksToHTML(chunks)
}
341180
func Chunk(tagged []tag.Token, rx *regexp.Regexp) []string {
	chunks := []string{}
	for _, loc := range Locate(tagged, rx) {
		res := ""
		for t, tt := range tagged[loc[0]:loc[1]] {
			if t != 0 {
				res += " "
			}
			res += tt.Text
		}
		chunks = append(chunks, res)
	}
	return chunks
}
267266
func (c *chunkedSeq) ChunkedFirst() iseq.Chunk {
	return newArrayChunk2(c.node, c.offset)
}
97149
func ParseHEX(input string, length int) ([]byte, error) {
	if input == "" {
		return make([]byte, length), nil
	}

	pattern := regexp.MustCompile(fmt.Sprintf("^[[:xdigit:]]{%d}$", length*2))

	valid := pattern.MatchString(input)
	if !valid {
		return nil, fmt.Errorf("Invalid input: %s is not hex", input)
	}

	slice, _ := hex.DecodeString(input)

	return slice, nil
}
113993
func compileChunk(context *funcContext, chunk []ast.Stmt) { // {{{
	for _, stmt := range chunk {
		compileStmt(context, stmt)
	}
}
744693
func parseTxAcceptedNtfnParams(params []json.RawMessage) (*chainhash.Hash,
	btcutil.Amount, error) {

	if len(params) != 2 {
		return nil, 0, wrongNumParams(len(params))
	}

	// Unmarshal first parameter as a string.
	var txHashStr string
	err := json.Unmarshal(params[0], &txHashStr)
	if err != nil {
		return nil, 0, err
	}

	// Unmarshal second parameter as a floating point number.
	var famt float64
	err = json.Unmarshal(params[1], &famt)
	if err != nil {
		return nil, 0, err
	}

	// Bounds check amount.
	amt, err := btcutil.NewAmount(famt)
	if err != nil {
		return nil, 0, err
	}

	// Decode string encoding of transaction sha.
	txHash, err := chainhash.NewHashFromStr(txHashStr)
	if err != nil {
		return nil, 0, err
	}

	return txHash, amt, nil
}
18637
func (b *Buffer) FirstChunk() Chunk {
	if b.first == nil {
		return nil
	}
	return b.first.Chunk
}
526967
func parseHexUint(v []byte) (n uint64, err error) {
	for i, b := range v {
		switch {
		case '0' <= b && b <= '9':
			b = b - '0'
		case 'a' <= b && b <= 'f':
			b = b - 'a' + 10
		case 'A' <= b && b <= 'F':
			b = b - 'A' + 10
		default:
			return 0, errors.New("invalid byte in chunk length")
		}
		if i == 16 {
			return 0, errors.New("http chunk length too large")
		}
		n <<= 4
		n |= uint64(b)
	}
	return
}
1263888
func (parser *Parser) ParseBytes(contents []byte) error {
	if !parser.initialised {
		if err := parser.init(); err != nil {
			return err
		}
	}

	return parser.rt.run(string(contents))
}