Browse Source

Fixed bug 1

master
Stephen Weinberg 12 years ago
parent
commit
75568b8038
  1. 3
      conf_test.go
  2. 13
      read.go

3
conf_test.go

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

13
read.go

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

Loading…
Cancel
Save