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
e439345d
Commit
e439345d
authored
Sep 24, 2010
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bufio.UnreadRune: fix bug at EOF
Fixes #1132. R=rsc CC=golang-dev
https://golang.org/cl/2215045
parent
099d7b4d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
0 deletions
+15
-0
bufio.go
src/pkg/bufio/bufio.go
+1
-0
bufio_test.go
src/pkg/bufio/bufio_test.go
+14
-0
No files found.
src/pkg/bufio/bufio.go
View file @
e439345d
...
...
@@ -207,6 +207,7 @@ func (b *Reader) ReadRune() (rune int, size int, err os.Error) {
for
b
.
r
+
utf8
.
UTFMax
>
b
.
w
&&
!
utf8
.
FullRune
(
b
.
buf
[
b
.
r
:
b
.
w
])
&&
b
.
err
==
nil
{
b
.
fill
()
}
b
.
lastRuneSize
=
-
1
if
b
.
r
==
b
.
w
{
return
0
,
0
,
b
.
err
}
...
...
src/pkg/bufio/bufio_test.go
View file @
e439345d
...
...
@@ -319,6 +319,20 @@ func TestUnreadRuneError(t *testing.T) {
}
}
func
TestUnreadRuneAtEOF
(
t
*
testing
.
T
)
{
// UnreadRune/ReadRune should error at EOF (was a bug; used to panic)
r
:=
NewReader
(
strings
.
NewReader
(
"x"
))
r
.
ReadRune
()
r
.
ReadRune
()
r
.
UnreadRune
()
_
,
_
,
err
:=
r
.
ReadRune
()
if
err
==
nil
{
t
.
Error
(
"expected error at EOF"
)
}
else
if
err
!=
os
.
EOF
{
t
.
Error
(
"expected EOF; got"
,
err
)
}
}
func
TestReadWriteRune
(
t
*
testing
.
T
)
{
const
NRune
=
1000
byteBuf
:=
new
(
bytes
.
Buffer
)
...
...
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