Minor key/value parsing fixes
This commit is contained in:
parent
e3b2244287
commit
a5d4cd727b
@ -14,6 +14,7 @@ package keyValue
|
||||
import "io"
|
||||
import "fmt"
|
||||
import "bufio"
|
||||
import "errors"
|
||||
import "strings"
|
||||
import "strconv"
|
||||
import "unicode"
|
||||
@ -65,7 +66,9 @@ func Parse (reader io.Reader) (File, error) {
|
||||
var specifiedValues map[string] struct { }
|
||||
for {
|
||||
line, err := buffer.ReadString('\n')
|
||||
if err != nil { return nil, err }
|
||||
if errors.Is(err, io.EOF) { return file, nil }
|
||||
if err != nil { return nil, err }
|
||||
|
||||
line = strings.TrimSpace(line)
|
||||
|
||||
switch {
|
||||
@ -167,8 +170,10 @@ func parseEntry (line string) (key, val string, loc locale.Locale, err error) {
|
||||
}
|
||||
if state != getVal { err = ErrInvalidEntry; return }
|
||||
|
||||
loc, err = locale.Parse(locb.String())
|
||||
if err != nil { return}
|
||||
if locb.Len() > 0 {
|
||||
loc, err = locale.Parse(locb.String())
|
||||
if err != nil { return}
|
||||
}
|
||||
key = strings.TrimSpace(keyb.String())
|
||||
val = strings.TrimSpace(valb.String())
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user