Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
5311d915
Commit
5311d915
authored
Feb 15, 2011
by
Adam Langley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
encoding/line: fix line returned after EOF
Fixes #1509. R=r CC=golang-dev
https://golang.org/cl/4167045
parent
e6ee0d24
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
+26
-0
line.go
src/pkg/encoding/line/line.go
+3
-0
line_test.go
src/pkg/encoding/line/line_test.go
+23
-0
No files found.
src/pkg/encoding/line/line.go
View file @
5311d915
...
@@ -105,6 +105,9 @@ func (l *Reader) ReadLine() (line []byte, isPrefix bool, err os.Error) {
...
@@ -105,6 +105,9 @@ func (l *Reader) ReadLine() (line []byte, isPrefix bool, err os.Error) {
l
.
buf
=
l
.
buf
[
:
oldLen
+
n
]
l
.
buf
=
l
.
buf
[
:
oldLen
+
n
]
if
readErr
!=
nil
{
if
readErr
!=
nil
{
l
.
err
=
readErr
l
.
err
=
readErr
if
len
(
l
.
buf
)
==
0
{
return
nil
,
false
,
readErr
}
}
}
}
}
panic
(
"unreachable"
)
panic
(
"unreachable"
)
...
...
src/pkg/encoding/line/line_test.go
View file @
5311d915
...
@@ -7,6 +7,7 @@ package line
...
@@ -7,6 +7,7 @@ package line
import
(
import
(
"bytes"
"bytes"
"io"
"io"
"io/ioutil"
"os"
"os"
"testing"
"testing"
)
)
...
@@ -108,3 +109,25 @@ func TestReadAfterLines(t *testing.T) {
...
@@ -108,3 +109,25 @@ func TestReadAfterLines(t *testing.T) {
t
.
Errorf
(
"bad result for Read: got %q; expected %q"
,
outbuf
.
String
(),
restData
)
t
.
Errorf
(
"bad result for Read: got %q; expected %q"
,
outbuf
.
String
(),
restData
)
}
}
}
}
func
TestReadEmptyBuffer
(
t
*
testing
.
T
)
{
l
:=
NewReader
(
bytes
.
NewBuffer
(
nil
),
10
)
line
,
isPrefix
,
err
:=
l
.
ReadLine
()
if
err
!=
os
.
EOF
{
t
.
Errorf
(
"expected EOF from ReadLine, got '%s' %t %s"
,
line
,
isPrefix
,
err
)
}
}
func
TestLinesAfterRead
(
t
*
testing
.
T
)
{
l
:=
NewReader
(
bytes
.
NewBuffer
([]
byte
(
"foo"
)),
10
)
_
,
err
:=
ioutil
.
ReadAll
(
l
)
if
err
!=
nil
{
t
.
Error
(
err
)
return
}
line
,
isPrefix
,
err
:=
l
.
ReadLine
()
if
err
!=
os
.
EOF
{
t
.
Errorf
(
"expected EOF from ReadLine, got '%s' %t %s"
,
line
,
isPrefix
,
err
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment