Skip to content

Commit

Permalink
Parse files with no final newline characters properly
Browse files Browse the repository at this point in the history
  • Loading branch information
vaughan0 committed Sep 18, 2013
1 parent 97be005 commit bf71521
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 4 additions & 3 deletions ini.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,14 @@ func (f File) LoadFile(file string) (err error) {
func parseFile(in *bufio.Reader, file File) (err error) {
section := file.Section("")
lineNum := 0
for {
for done := false; !done; {
var line string
if line, err = in.ReadString('\n'); err != nil {
if err == io.EOF {
break
done = true
} else {
return
}
return
}
lineNum++
line = strings.TrimSpace(line)
Expand Down
3 changes: 1 addition & 2 deletions ini_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ func TestLoad(t *testing.T) {
multiple = equals = signs
[bar]
this = that
`
this = that`

file, err := Load(strings.NewReader(src))
if err != nil {
Expand Down

0 comments on commit bf71521

Please sign in to comment.