Skip to content

Commit

Permalink
Fixed incorrect handling of whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
vaughan0 committed Jan 18, 2013
1 parent e0d5b09 commit 52d8819
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ini.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

var (
sectionRegex = regexp.MustCompile(`^\[(.*)\]$`)
assignRegex = regexp.MustCompile(`([^=]+)\s*=\s*(.*)$`)
assignRegex = regexp.MustCompile(`([^=]+)=(.*)$`)
)

// ErrSyntax is returned when there is a syntax error in an INI file.
Expand Down Expand Up @@ -103,9 +103,11 @@ func parseFile(in *bufio.Reader, file File) (err error) {

if groups := assignRegex.FindStringSubmatch(line); groups != nil {
key, val := groups[1], groups[2]
key, val = strings.TrimSpace(key), strings.TrimSpace(val)
section[key] = val
} else if groups := sectionRegex.FindStringSubmatch(line); groups != nil {
section = file.Section(groups[1])
name := strings.TrimSpace(groups[1])
section = file.Section(name)
} else {
return ErrSyntax{lineNum, line}
}
Expand Down

0 comments on commit 52d8819

Please sign in to comment.