Skip to content

Commit 1dc4167

Browse files
committed
fix StringReader.__init__ initialization of buf and pos
1 parent 71f910d commit 1dc4167

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

‎go/type.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,10 @@ func NewStringReader(lines []string) *StringReader{
180180
func (self*StringReader) __init__(lines []string){
181181
size:=0
182182
for_, l:=rangelines{
183-
size+=len(l)
183+
size+=len(l)+1// +1 for EOL
184184
}
185185
self.buf=make([]string, 0, size)
186-
self.pos=make([]pos, 0, size)
186+
self.pos=make([]pos, 0, size+1) // +1 for EOF
187187
varlnum=0
188188
forlnum<len(lines){
189189
varcol=0

0 commit comments

Comments
(0)