1
// Copyright 2013 ChaiShushan <chaishushan{AT}gmail.com>. All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
12
type lineReader struct {
17
func newLineReader(data string) *lineReader {
18
data = strings.Replace(data, "\r", "", -1)
19
lines := strings.Split(data, "\n")
20
return &lineReader{lines: lines}
23
func (r *lineReader) skipBlankLine() error {
24
for ; r.pos < len(r.lines); r.pos++ {
25
if strings.TrimSpace(r.lines[r.pos]) != "" {
29
if r.pos >= len(r.lines) {
35
func (r *lineReader) currentPos() int {
39
func (r *lineReader) currentLine() (s string, pos int, err error) {
40
if r.pos >= len(r.lines) {
44
s, pos = r.lines[r.pos], r.pos
48
func (r *lineReader) readLine() (s string, pos int, err error) {
49
if r.pos >= len(r.lines) {
53
s, pos = r.lines[r.pos], r.pos
58
func (r *lineReader) unreadLine() {