Fixed bug in Document.LoadStream() function.

This commit is contained in:
jim teeuwen 2010-12-19 20:45:57 +01:00
parent 15ec07ab1a
commit d0d1c2f9f5
2 changed files with 5 additions and 13 deletions

View File

@ -7,6 +7,5 @@ test:
clean:
make -C xmlx clean
format:
gofmt -w .

View File

@ -30,7 +30,6 @@ package xmlx
import "os"
import "io"
import "bytes"
import "io/ioutil"
import "path"
import "strings"
@ -182,17 +181,11 @@ func (this *Document) LoadUri(uri string) (err os.Error) {
}
func (this *Document) LoadStream(r io.Reader) (err os.Error) {
var buf bytes.Buffer
s := make([]byte, 1024)
for {
if _, err = r.Read(s); err != nil {
break
var b []byte
if b, err = ioutil.ReadAll(r); err != nil {
return
}
buf.Write(s)
}
return this.LoadString(buf.String())
return this.LoadString(string(b))
}
// *****************************************************************************