Minor key/value parsing fixes

This commit is contained in:
Sasha Koshka 2024-04-27 20:16:46 -04:00
parent e3b2244287
commit a5d4cd727b

View File

@ -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 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 }
if locb.Len() > 0 {
loc, err = locale.Parse(locb.String())
if err != nil { return}
}
key = strings.TrimSpace(keyb.String())
val = strings.TrimSpace(valb.String())