Fixed bug 1

This commit is contained in:
Stephen Weinberg 2010-03-31 15:39:10 -04:00
parent 272452f813
commit 75568b8038
2 changed files with 9 additions and 7 deletions

View File

@ -15,8 +15,7 @@ active = false
[service-1] [service-1]
port = 443 port = 443
url = http://%(host)s/something url = http://%(host)s/something`
`
type stringtest struct { type stringtest struct {
section string section string

13
read.go
View File

@ -48,13 +48,11 @@ func (c *ConfigFile) Read(reader io.Reader) (err os.Error) {
var section, option string; var section, option string;
section = "default" section = "default"
for { for {
l, err := buf.ReadString('\n'); // parse line-by-line l, buferr := buf.ReadString('\n'); // parse line-by-line
if err == os.EOF { if buferr != nil && buferr != os.EOF {
break
} else if err != nil {
return err return err
} }
l = strings.TrimSpace(l); l = strings.TrimSpace(l);
// switch written for readability (not performance) // switch written for readability (not performance)
switch { switch {
@ -96,6 +94,11 @@ func (c *ConfigFile) Read(reader io.Reader) (err os.Error) {
return ReadError{CouldNotParse, l} return ReadError{CouldNotParse, l}
} }
} }
// Reached end of file
if buferr == os.EOF {
break
}
} }
return nil; return nil;
} }