use bufio.Reader instead of io.Reader

This commit is contained in:
Brian Picciano 2014-10-14 20:39:20 -04:00
parent b8c09a905b
commit 3dc2842e2e
3 changed files with 5 additions and 5 deletions

View File

@ -2,7 +2,6 @@ package parse
import (
"bufio"
"io"
"strconv"
"github.com/mediocregopher/ginger/types"
@ -19,11 +18,10 @@ import (
// double-quote has already been read off. Ginger strings are wrapped with " and
// are allowed to have newlines literal in them. In all other respects they are
// the same as go strings.
func ReadString(r io.Reader) (types.Str, error) {
buf := bufio.NewReader(r)
func ReadString(r *bufio.Reader) (types.Str, error) {
str := types.Str("\"")
for {
piece, err := buf.ReadBytes('"')
piece, err := r.ReadBytes('"')
if err != nil {
return "", err
}

Binary file not shown.

View File

@ -2,6 +2,7 @@ package parse
import (
"bytes"
"bufio"
. "testing"
"github.com/mediocregopher/ginger/types"
@ -18,8 +19,9 @@ func TestReadString(t *T) {
for input, output := range m {
buf := bytes.NewBufferString(input)
buf.ReadByte()
buf2 := bufio.NewReader(buf)
parseOut, err := ReadString(buf)
parseOut, err := ReadString(buf2)
if err != nil {
t.Fatal(err)
}