diff --git a/icon-theme/icon-theme.go b/icon-theme/icon-theme.go index 6915316..220b0af 100644 --- a/icon-theme/icon-theme.go +++ b/icon-theme/icon-theme.go @@ -186,9 +186,9 @@ func parseThemeIndex (reader io.Reader) (theme Theme, parents []string, err erro // Inherits (optional) if entry, ok := iconThemeGroup["Inherits"]; ok { - parents, err = keyValue.ParseMultipleComma ( + parents, err = keyValue.ParseMultiple ( keyValue.ParseString, - entry.Value) + entry.Value, ',') if !ok { return Theme { }, nil, err } } @@ -220,7 +220,7 @@ func parseThemeIndex (reader io.Reader) (theme Theme, parents []string, err erro } func parseDirectories (listEntry keyValue.Entry, file keyValue.File) ([]Directory, error) { - names, err := keyValue.ParseMultipleComma(keyValue.ParseString, listEntry.Value) + names, err := keyValue.ParseMultiple(keyValue.ParseString, listEntry.Value, ',') if err != nil { return nil, err } directories := make([]Directory, len(names)) for index, name := range names { @@ -523,7 +523,7 @@ func parseIconData (path string) (Icon, error) { // EmbeddedTextRectangle (optional) if entry, ok := iconDataGroup["EmbeddedTextRectangle"]; ok { - embeddedTextRectangle, err := keyValue.ParseMultipleComma(keyValue.ParseInteger, entry.Value) + embeddedTextRectangle, err := keyValue.ParseMultiple(keyValue.ParseInteger, entry.Value, ',') if len(embeddedTextRectangle) == 4 { icon.EmbeddedTextRectangle = image.Rect ( embeddedTextRectangle[0], diff --git a/key-value/key-value.go b/key-value/key-value.go index 1f8975a..3234b9a 100644 --- a/key-value/key-value.go +++ b/key-value/key-value.go @@ -345,22 +345,11 @@ func ParseNumeric (value string) (float64, error) { } // ParseMultiple parses multiple of a value type. Any value parsing function can -// be specified. The multiple values should be separated by a semicolon and the -// input string may be optionally terminated by a semicolon. Trailing empty -// strings must always be terminated with a semicolon. Semicolons in these -// values need to be escaped using \;. -func ParseMultiple[T any] (parser func (string) (T, error), value string) ([]T, error) { - return parseMultiple(parser, value, ';') -} - -// ParseMultipleComma is like ParseMultiple, but uses a comma as a separator -// instead of a semicolon. This is used to parse icon theme files because the -// freedesktop people haven't yet learned the word "consistency". -func ParseMultipleComma[T any] (parser func (string) (T, error), value string) ([]T, error) { - return parseMultiple(parser, value, ',') -} - -func parseMultiple[T any] (parser func (string) (T, error), value string, sep rune) ([]T, error) { +// be specified. The multiple values should be separated by a separator and the +// input string may be optionally terminated by a separator. Trailing empty +// strings must always be terminated with a separator. Separators in these +// values need to be escaped using \. +func ParseMultiple[T any] (parser func (string) (T, error), value string, sep rune) ([]T, error) { values := []T { } builder := strings.Builder { }