Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
4dfc7f0f
Commit
4dfc7f0f
authored
Sep 16, 2008
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix / work around bugs in bufio test
R=r DELTA=11 (8 added, 0 deleted, 3 changed) OCL=15405 CL=15405
parent
85f8d450
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
3 deletions
+11
-3
src/lib/bufio.go
src/lib/bufio.go
+10
-2
test/bufiolib.go
test/bufiolib.go
+1
-1
No files found.
src/lib/bufio.go
View file @
4dfc7f0f
...
...
@@ -291,18 +291,26 @@ func (b *BufRead) ReadLineBytes(delim byte) (line *[]byte, err *os.Error) {
return
buf
,
err
}
// BUG(bugs/bug102.go): string(empty bytes array) throws error
func
ToString
(
p
*
[]
byte
)
string
{
if
len
(
p
)
==
0
{
return
""
}
return
string
(
p
)
}
// Read until the first occurrence of delim in the input,
// returning a new string containing the line.
// If savedelim, keep delim in the result; otherwise chop it off.
func
(
b
*
BufRead
)
ReadLineString
(
delim
byte
,
savedelim
bool
)
(
line
string
,
err
*
os
.
Error
)
{
bytes
,
e
:=
b
.
ReadLineBytes
(
delim
)
if
e
!=
nil
{
return
s
tring
(
bytes
),
e
return
ToS
tring
(
bytes
),
e
}
if
!
savedelim
{
bytes
=
bytes
[
0
:
len
(
bytes
)
-
1
]
}
return
s
tring
(
bytes
),
nil
return
ToS
tring
(
bytes
),
nil
}
...
...
test/bufiolib.go
View file @
4dfc7f0f
...
...
@@ -121,7 +121,7 @@ var readmakers = []*(p *[]byte) io.Read {
func
ReadLines
(
b
*
bufio
.
BufRead
)
string
{
s
:=
""
for
{
s1
,
e
:=
b
.
ReadLineString
(
'\n'
,
fals
e
)
s1
,
e
:=
b
.
ReadLineString
(
'\n'
,
tru
e
)
if
e
==
bufio
.
EndOfFile
{
break
}
...
...
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