// next reads the next rune from the bufferred reader. Returns the rune(0) if
// an error occurs (or io.EOF is returned).
336412
func (s *Scanner) next() rune {
	ch, size, err := s.buf.ReadRune()
	if err != nil {
		// advance for error reporting
		s.srcPos.Column++
		s.srcPos.Offset += size
		s.lastCharLen = size
		return eof
	}

	// remember last position
	s.prevPos = s.srcPos

	s.srcPos.Column++
	s.lastCharLen = size
	s.srcPos.Offset += size

	if ch == utf8.RuneError && size == 1 {
		s.err("illegal UTF-8 encoding")
		return ch
	}

	if ch == '\n' {
		s.srcPos.Line++
		s.lastLineLen = s.srcPos.Column
		s.srcPos.Column = 0
	}

	if ch == '\x00' {
		s.err("unexpected null character (0x00)")
		return eof
	}

	if ch == '\uE123' {
		s.err("unicode code point U+E123 reserved for internal use")
		return utf8.RuneError
	}

	// debug
	// fmt.Printf("ch: %q, offset:column: %d:%d\n", ch, s.srcPos.Offset, s.srcPos.Column)
	return ch
}
1048894
func (ics *IterateCloserStruct) Next(key, val SophieReader) error {
	if ics.NextF != nil {
		return ics.NextF(key, val)
	}
	return io.EOF
}
638241
func (r *Reader) Next() (os.FileInfo, error) {
	if r.queue.IsEmpty() {
		return nil, io.EOF
	}

	// We only dequeue the directory when it does not contain more children
	// or when it is empty and there is no children to iterate over.
	item, err := r.queue.Peek()
	if err != nil {
		panic(err)
	}

	f := item.(File)
	if r.sector == 0 {
		r.sector = f.ExtentLocationBE
		_, err := r.image.Seek(int64(r.sector*sectorSize), os.SEEK_SET)
		if err != nil {
			return nil, ErrCorruptedImage(err)
		}

		// Skips . and .. directories
		if err = r.Skip(2); err != nil {
			return nil, ErrCorruptedImage(err)
		}
	}

	var drecord File
	var len byte
	if (r.read % sectorSize) == 0 {
		r.sector++
		_, err := r.image.Seek(int64(r.sector*sectorSize), os.SEEK_SET)
		if err != nil {
			return nil, ErrCorruptedImage(err)
		}
	}

	if len, err = r.unpackDRecord(&drecord); err != nil && err != io.EOF {
		return nil, ErrCorruptedImage(err)
	}
	r.read += uint32(len)

	if err == io.EOF {
		// directory record is empty, sector space wasted, move onto next sector.
		rsize := (sectorSize - (r.read % sectorSize))
		buf := make([]byte, rsize)
		if err := binary.Read(r.image, binary.BigEndian, buf); err != nil {
			return nil, ErrCorruptedImage(err)
		}
		r.read += rsize
	}

	// If there is no more entries in the current directory, dequeue it.
	if r.read >= f.ExtentLengthBE {
		r.read = 0
		r.sector = 0
		r.queue.Dequeue()
	}

	// End of directory listing, drecord is empty so we don't bother
	// to return it and keep iterating to look for the next actual
	// directory or file.
	if drecord.fileID == "" {
		return r.Next()
	}

	parent := f.Name()
	if parent == "\x00" {
		parent = "/"
	}
	drecord.fileID = filepath.Join(parent, drecord.fileID)

	if drecord.IsDir() {
		r.queue.Enqueue(drecord)
	} else {
		drecord.image = r.image
	}

	return &drecord, nil
}
1061325
func (m *macro) next() (rune, error) {
	if m.eof() {
		return 0, fmt.Errorf("unexpected eof for macro (%v)", m.input)
	}
	r, size := utf8.DecodeRuneInString(m.input[m.pos:])
	m.prev = m.pos
	m.pos += size
	return r, nil
}
735728
func (c *C) Next() {
	c.index++
	s := int8(len(c.handlers))
	if c.index < s {
		c.handlers[c.index](c)
	}
}
463921
func (d *decoder) next() {
	// If there's not buffered line
	if d.buffered == "" {
		res := d.scanner.Scan()
		if true != res {
			d.err = d.scanner.Err()
			return
		}
		d.line++
		d.current = d.scanner.Text()
	} else {
		d.current = d.buffered
		d.buffered = ""
	}

	for d.scanner.Scan() {
		d.line++
		line := d.scanner.Text()
		if strings.HasPrefix(line, " ") || strings.HasPrefix(line, "\t") {
			d.current = d.current + line[1:]
		} else {
			// If is not a continuation line, buffer it, for the
			// next call.
			d.buffered = line
			break
		}
	}

	d.err = d.scanner.Err()

	if d.nextFn != nil {
		d.nextFn(d)
	}
}
413247
func (r *tarReader) Next() error {
	header, err := r.reader.Next()
	r.header = header
	return err
}
528786
func (tr *Reader) Next() (*Header, error) {
	if tr.err != nil {
		return nil, tr.err
	}
	hdr, err := tr.next()
	tr.err = err
	return hdr, err
}
429883
func (r *charIter) next() (byte, byte, bool) {
	// we have reached the last string in the index, end
	if r.isEnd() {
		return 0, 0, false
	}

	b := r.seq[r.si][r.i]
	sep := r.sep[r.si]
	r.i++

	// current string index exceeded the last char of the current string
	// move to the next string if it's present
	if r.i >= len(r.seq[r.si]) && r.si < len(r.seq)-1 {
		r.si++
		r.i = 0
	}

	return b, sep, true
}
641136
func (pr *PagingResult) Next() (noMore bool, err error) {
	if !pr.HasNext() {
		noMore = true
		return
	}

	return pr.navigate(&pr.next)
}
1269800
func (i *Int64) Next() int64 {
	i.lock.Lock()
	defer i.lock.Unlock()
	i.increment++
	return i.increment
}
1006381
func (iter *PermutationIterator) Next() []interface{} {
	if !iter.HasNext() {
		return nil
	}

	if iter.res[0] != nil {
		for i := iter.r - 1; i > -1; i-- {
			iter.cycles[i] -= 1
			if iter.cycles[i] == 0 {
				for x := i; x < iter.n-1; x++ {
					v := iter.indices[x]
					iter.indices[x] = iter.indices[x+1]
					iter.indices[x+1] = v
				}
				iter.cycles[i] = iter.n - i
			} else {
				x := iter.indices[i]
				iter.indices[i] = iter.indices[iter.n-iter.cycles[i]]
				iter.indices[iter.n-iter.cycles[i]] = x
				break
			}
		}
	}

	for i := 0; i < iter.r; i++ {
		iter.res[i] = iter.pool[iter.indices[i]]
	}

	iter.iters += 1

	return iter.res
}
723562
func (rows *Rows) Next() bool {
	for {
		rows.token, rows.err = rows.decoder.Token()
		if rows.err == io.EOF {
			rows.err = nil
		}
		if rows.token == nil {
			return false
		}

		switch startElement := rows.token.(type) {
		case xml.StartElement:
			inElement := startElement.Name.Local
			if inElement == "row" {
				return true
			}
		}
	}
}
1268509
func (b *Buffer) next(index int) int {
	index++
	if index == b.cap {
		return 0
	}
	return index
}
120265
func (rItr *reverseIterator) Next() {
	var err error
	rItr.cur, err = rItr.dric.Recv()
	if err != nil {
		panic(fmt.Sprintf("RemoteDB.ReverseIterator.Next error: %v", err))
	}
}
266596
func (ri *readerOffsetsIterator) Next() bool {
	if ri.i >= len(ri.r.offsets) {
		return false
	} else if ri.first {
		ri.first = false
		return true
	}

	ri.i++
	ri.ks = rOIKeyState{}

	for ri.pi < len(ri.r.prefixes) && ri.i >= ri.r.prefixes[ri.pi].total {
		ri.pi++
	}

	return ri.i < len(ri.r.offsets)
}
1303934
func (i *Int32) Next() int32 {
	i.lock.Lock()
	defer i.lock.Unlock()
	i.increment++
	return i.increment
}