Browse Source

Removed firstIndex and replaced with strings.IndexAny

master
stephen 12 years ago
parent
commit
bd314801c3
  1. 11
      conf.go
  2. 4
      read.go

11
conf.go

@ -160,17 +160,6 @@ func NewConfigFile() *ConfigFile { @@ -160,17 +160,6 @@ func NewConfigFile() *ConfigFile {
return c
}
func firstIndex(s string, delim []byte) int {
for i := 0; i < len(s); i++ {
for j := 0; j < len(delim); j++ {
if s[i] == delim[j] {
return i
}
}
}
return -1
}
type GetError struct {
Reason int
ValueType string

4
read.go

@ -84,10 +84,10 @@ func (c *ConfigFile) Read(reader io.Reader) (err os.Error) { @@ -84,10 +84,10 @@ func (c *ConfigFile) Read(reader io.Reader) (err os.Error) {
return ReadError{BlankSection, l}
default: // other alternatives
i := firstIndex(l, []byte{'=', ':'})
i := strings.IndexAny(l, "=:")
switch {
case i > 0: // option and value
i := firstIndex(l, []byte{'=', ':'})
i := strings.IndexAny(l, "=:")
option = strings.TrimSpace(l[0:i])
value := strings.TrimSpace(stripComments(l[i+1:]))
c.AddOption(section, option, value)

Loading…
Cancel
Save