From baf7141d1dd0f99d561a2197a909c66dd389809d Mon Sep 17 00:00:00 2001 From: Niall Sheridan Date: Sat, 8 Oct 2016 16:02:50 -0500 Subject: Update dependencies --- vendor/github.com/pelletier/go-toml/keysparsing.go | 16 ++++++- vendor/github.com/pelletier/go-toml/toml.go | 3 -- .../pelletier/go-toml/tomltree_conversions.go | 54 +++++++++++++++++++++- 3 files changed, 67 insertions(+), 6 deletions(-) (limited to 'vendor/github.com/pelletier/go-toml') diff --git a/vendor/github.com/pelletier/go-toml/keysparsing.go b/vendor/github.com/pelletier/go-toml/keysparsing.go index 4deed81..b67664f 100644 --- a/vendor/github.com/pelletier/go-toml/keysparsing.go +++ b/vendor/github.com/pelletier/go-toml/keysparsing.go @@ -12,6 +12,7 @@ func parseKey(key string) ([]string, error) { groups := []string{} var buffer bytes.Buffer inQuotes := false + wasInQuotes := false escapeNext := false ignoreSpace := true expectDot := false @@ -33,16 +34,27 @@ func parseKey(key string) ([]string, error) { escapeNext = true continue case '"': + if inQuotes { + groups = append(groups, buffer.String()) + buffer.Reset() + wasInQuotes = true + } inQuotes = !inQuotes expectDot = false case '.': if inQuotes { buffer.WriteRune(char) } else { - groups = append(groups, buffer.String()) - buffer.Reset() + if !wasInQuotes { + if buffer.Len() == 0 { + return nil, fmt.Errorf("empty key group") + } + groups = append(groups, buffer.String()) + buffer.Reset() + } ignoreSpace = true expectDot = false + wasInQuotes = false } case ' ': if inQuotes { diff --git a/vendor/github.com/pelletier/go-toml/toml.go b/vendor/github.com/pelletier/go-toml/toml.go index c0e1ad2..ad23fe8 100644 --- a/vendor/github.com/pelletier/go-toml/toml.go +++ b/vendor/github.com/pelletier/go-toml/toml.go @@ -222,9 +222,6 @@ func (t *TomlTree) SetPath(keys []string, value interface{}) { func (t *TomlTree) createSubTree(keys []string, pos Position) error { subtree := t for _, intermediateKey := range keys { - if intermediateKey == "" { - return fmt.Errorf("empty intermediate table") - } nextTree, exists := subtree.values[intermediateKey] if !exists { tree := newTomlTree() diff --git a/vendor/github.com/pelletier/go-toml/tomltree_conversions.go b/vendor/github.com/pelletier/go-toml/tomltree_conversions.go index c9c6f95..bf9321b 100644 --- a/vendor/github.com/pelletier/go-toml/tomltree_conversions.go +++ b/vendor/github.com/pelletier/go-toml/tomltree_conversions.go @@ -45,8 +45,28 @@ func encodeTomlString(value string) string { func toTomlValue(item interface{}, indent int) string { tab := strings.Repeat(" ", indent) switch value := item.(type) { + case int: + return tab + strconv.FormatInt(int64(value), 10) + case int8: + return tab + strconv.FormatInt(int64(value), 10) + case int16: + return tab + strconv.FormatInt(int64(value), 10) + case int32: + return tab + strconv.FormatInt(int64(value), 10) case int64: return tab + strconv.FormatInt(value, 10) + case uint: + return tab + strconv.FormatUint(uint64(value), 10) + case uint8: + return tab + strconv.FormatUint(uint64(value), 10) + case uint16: + return tab + strconv.FormatUint(uint64(value), 10) + case uint32: + return tab + strconv.FormatUint(uint64(value), 10) + case uint64: + return tab + strconv.FormatUint(value, 10) + case float32: + return tab + strconv.FormatFloat(float64(value), 'f', -1, 32) case float64: return tab + strconv.FormatFloat(value, 'f', -1, 64) case string: @@ -64,8 +84,10 @@ func toTomlValue(item interface{}, indent int) string { result += toTomlValue(item, indent+2) + ",\n" } return result + tab + "]" + case nil: + return "" default: - panic(fmt.Sprintf("unsupported value type: %v", value)) + panic(fmt.Sprintf("unsupported value type %T: %v", value, value)) } } @@ -96,6 +118,20 @@ func (t *TomlTree) toToml(indent, keyspace string) string { case map[string]interface{}: sub := TreeFromMap(node) + if len(sub.Keys()) > 0 { + result += fmt.Sprintf("\n%s[%s]\n", indent, combinedKey) + } + result += sub.toToml(indent+" ", combinedKey) + case map[string]string: + sub := TreeFromMap(convertMapStringString(node)) + + if len(sub.Keys()) > 0 { + result += fmt.Sprintf("\n%s[%s]\n", indent, combinedKey) + } + result += sub.toToml(indent+" ", combinedKey) + case map[interface{}]interface{}: + sub := TreeFromMap(convertMapInterfaceInterface(node)) + if len(sub.Keys()) > 0 { result += fmt.Sprintf("\n%s[%s]\n", indent, combinedKey) } @@ -109,6 +145,22 @@ func (t *TomlTree) toToml(indent, keyspace string) string { return result } +func convertMapStringString(in map[string]string) map[string]interface{} { + result := make(map[string]interface{}, len(in)) + for k, v := range in { + result[k] = v + } + return result +} + +func convertMapInterfaceInterface(in map[interface{}]interface{}) map[string]interface{} { + result := make(map[string]interface{}, len(in)) + for k, v := range in { + result[k.(string)] = v + } + return result +} + // ToString is an alias for String func (t *TomlTree) ToString() string { return t.String() -- cgit v1.2.3