Fixed bug in Document.LoadStream() function.
This commit is contained in:
		
							parent
							
								
									15ec07ab1a
								
							
						
					
					
						commit
						d0d1c2f9f5
					
				
					 2 changed files with 5 additions and 13 deletions
				
			
		
							
								
								
									
										3
									
								
								makefile
									
										
									
									
									
								
							
							
						
						
									
										3
									
								
								makefile
									
										
									
									
									
								
							| 
						 | 
					@ -7,6 +7,5 @@ test:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
clean:
 | 
					clean:
 | 
				
			||||||
	make -C xmlx clean
 | 
						make -C xmlx clean
 | 
				
			||||||
 | 
					 | 
				
			||||||
format:
 | 
					 | 
				
			||||||
	gofmt -w .
 | 
						gofmt -w .
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,7 +30,6 @@ package xmlx
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import "os"
 | 
					import "os"
 | 
				
			||||||
import "io"
 | 
					import "io"
 | 
				
			||||||
import "bytes"
 | 
					 | 
				
			||||||
import "io/ioutil"
 | 
					import "io/ioutil"
 | 
				
			||||||
import "path"
 | 
					import "path"
 | 
				
			||||||
import "strings"
 | 
					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) {
 | 
					func (this *Document) LoadStream(r io.Reader) (err os.Error) {
 | 
				
			||||||
	var buf bytes.Buffer
 | 
						var b []byte
 | 
				
			||||||
	s := make([]byte, 1024)
 | 
						if b, err = ioutil.ReadAll(r); err != nil {
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
	for {
 | 
					 | 
				
			||||||
		if _, err = r.Read(s); err != nil {
 | 
					 | 
				
			||||||
			break
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		buf.Write(s)
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						return this.LoadString(string(b))
 | 
				
			||||||
	return this.LoadString(buf.String())
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// *****************************************************************************
 | 
					// *****************************************************************************
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue