summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/pelletier
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2018-01-29 14:17:40 -0800
committerGitHub <noreply@github.com>2018-01-29 14:17:40 -0800
commit961c04cae992eadb42d286d2f85f8a675bdc68c8 (patch)
tree3408f2d06f847e966c53485e2d54c692cdd037c1 /vendor/github.com/pelletier
parent8d66523ba7d9a77129844be476732ebfd5272d64 (diff)
downloadchat-961c04cae992eadb42d286d2f85f8a675bdc68c8.tar.gz
chat-961c04cae992eadb42d286d2f85f8a675bdc68c8.tar.bz2
chat-961c04cae992eadb42d286d2f85f8a675bdc68c8.zip
Upgrading server dependancies (#8154)
Diffstat (limited to 'vendor/github.com/pelletier')
-rw-r--r--vendor/github.com/pelletier/go-toml/.travis.yml4
-rw-r--r--vendor/github.com/pelletier/go-toml/keysparsing.go104
-rw-r--r--vendor/github.com/pelletier/go-toml/keysparsing_test.go13
-rw-r--r--vendor/github.com/pelletier/go-toml/lexer.go42
-rw-r--r--vendor/github.com/pelletier/go-toml/lexer_test.go2
-rw-r--r--vendor/github.com/pelletier/go-toml/marshal.go127
-rw-r--r--vendor/github.com/pelletier/go-toml/parser.go19
-rw-r--r--vendor/github.com/pelletier/go-toml/parser_test.go63
-rwxr-xr-xvendor/github.com/pelletier/go-toml/test.sh1
-rw-r--r--vendor/github.com/pelletier/go-toml/token.go4
-rw-r--r--vendor/github.com/pelletier/go-toml/toml.go27
-rw-r--r--vendor/github.com/pelletier/go-toml/tomltree_write.go4
-rw-r--r--vendor/github.com/pelletier/go-toml/tomltree_write_test.go18
13 files changed, 221 insertions, 207 deletions
diff --git a/vendor/github.com/pelletier/go-toml/.travis.yml b/vendor/github.com/pelletier/go-toml/.travis.yml
index 6e644fdfd..ab2775d7d 100644
--- a/vendor/github.com/pelletier/go-toml/.travis.yml
+++ b/vendor/github.com/pelletier/go-toml/.travis.yml
@@ -1,8 +1,8 @@
sudo: false
language: go
go:
- - 1.8.4
- - 1.9.1
+ - 1.8.5
+ - 1.9.2
- tip
matrix:
allow_failures:
diff --git a/vendor/github.com/pelletier/go-toml/keysparsing.go b/vendor/github.com/pelletier/go-toml/keysparsing.go
index 0da938b03..284db6467 100644
--- a/vendor/github.com/pelletier/go-toml/keysparsing.go
+++ b/vendor/github.com/pelletier/go-toml/keysparsing.go
@@ -6,36 +6,16 @@ import (
"bytes"
"errors"
"fmt"
- "strconv"
"unicode"
)
-var escapeSequenceMap = map[rune]rune{
- 'b': '\b',
- 't': '\t',
- 'n': '\n',
- 'f': '\f',
- 'r': '\r',
- '"': '"',
- '\\': '\\',
-}
-
-type parseKeyState int
-
-const (
- bare parseKeyState = iota
- basic
- literal
- esc
- unicode4
- unicode8
-)
-
+// Convert the bare key group string to an array.
+// The input supports double quotation to allow "." inside the key name,
+// but escape sequences are not supported. Lexers must unescape them beforehand.
func parseKey(key string) ([]string, error) {
groups := []string{}
var buffer bytes.Buffer
- var hex bytes.Buffer
- state := bare
+ inQuotes := false
wasInQuotes := false
ignoreSpace := true
expectDot := false
@@ -47,67 +27,17 @@ func parseKey(key string) ([]string, error) {
}
ignoreSpace = false
}
-
- if state == esc {
- if char == 'u' {
- state = unicode4
- hex.Reset()
- } else if char == 'U' {
- state = unicode8
- hex.Reset()
- } else if newChar, ok := escapeSequenceMap[char]; ok {
- buffer.WriteRune(newChar)
- state = basic
- } else {
- return nil, fmt.Errorf(`invalid escape sequence \%c`, char)
- }
- continue
- }
-
- if state == unicode4 || state == unicode8 {
- if isHexDigit(char) {
- hex.WriteRune(char)
- }
- if (state == unicode4 && hex.Len() == 4) || (state == unicode8 && hex.Len() == 8) {
- if value, err := strconv.ParseInt(hex.String(), 16, 32); err == nil {
- buffer.WriteRune(rune(value))
- } else {
- return nil, err
- }
- state = basic
- }
- continue
- }
-
switch char {
- case '\\':
- if state == basic {
- state = esc
- } else if state == literal {
- buffer.WriteRune(char)
- }
- case '\'':
- if state == bare {
- state = literal
- } else if state == literal {
- groups = append(groups, buffer.String())
- buffer.Reset()
- wasInQuotes = true
- state = bare
- }
- expectDot = false
case '"':
- if state == bare {
- state = basic
- } else if state == basic {
+ if inQuotes {
groups = append(groups, buffer.String())
buffer.Reset()
- state = bare
wasInQuotes = true
}
+ inQuotes = !inQuotes
expectDot = false
case '.':
- if state != bare {
+ if inQuotes {
buffer.WriteRune(char)
} else {
if !wasInQuotes {
@@ -122,31 +52,25 @@ func parseKey(key string) ([]string, error) {
wasInQuotes = false
}
case ' ':
- if state == basic {
+ if inQuotes {
buffer.WriteRune(char)
} else {
expectDot = true
}
default:
- if state == bare {
- if !isValidBareChar(char) {
- return nil, fmt.Errorf("invalid bare character: %c", char)
- } else if expectDot {
- return nil, errors.New("what?")
- }
+ if !inQuotes && !isValidBareChar(char) {
+ return nil, fmt.Errorf("invalid bare character: %c", char)
+ }
+ if !inQuotes && expectDot {
+ return nil, errors.New("what?")
}
buffer.WriteRune(char)
expectDot = false
}
}
-
- // state must be bare at the end
- if state == esc {
- return nil, errors.New("unfinished escape sequence")
- } else if state != bare {
+ if inQuotes {
return nil, errors.New("mismatched quotes")
}
-
if buffer.Len() > 0 {
groups = append(groups, buffer.String())
}
diff --git a/vendor/github.com/pelletier/go-toml/keysparsing_test.go b/vendor/github.com/pelletier/go-toml/keysparsing_test.go
index 7aa4cd64a..84cb82604 100644
--- a/vendor/github.com/pelletier/go-toml/keysparsing_test.go
+++ b/vendor/github.com/pelletier/go-toml/keysparsing_test.go
@@ -50,17 +50,10 @@ func TestBaseKeyPound(t *testing.T) {
func TestQuotedKeys(t *testing.T) {
testResult(t, `hello."foo".bar`, []string{"hello", "foo", "bar"})
testResult(t, `"hello!"`, []string{"hello!"})
- testResult(t, `"hello\tworld"`, []string{"hello\tworld"})
- testResult(t, `"\U0001F914"`, []string{"\U0001F914"})
- testResult(t, `"\u2764"`, []string{"\u2764"})
+ testResult(t, `foo."ba.r".baz`, []string{"foo", "ba.r", "baz"})
- testResult(t, `hello.'foo'.bar`, []string{"hello", "foo", "bar"})
- testResult(t, `'hello!'`, []string{"hello!"})
- testResult(t, `'hello\tworld'`, []string{`hello\tworld`})
-
- testError(t, `"\w"`, `invalid escape sequence \w`)
- testError(t, `"\`, `unfinished escape sequence`)
- testError(t, `"\t`, `mismatched quotes`)
+ // escape sequences must not be converted
+ testResult(t, `"hello\tworld"`, []string{`hello\tworld`})
}
func TestEmptyKey(t *testing.T) {
diff --git a/vendor/github.com/pelletier/go-toml/lexer.go b/vendor/github.com/pelletier/go-toml/lexer.go
index 209665676..d11de4285 100644
--- a/vendor/github.com/pelletier/go-toml/lexer.go
+++ b/vendor/github.com/pelletier/go-toml/lexer.go
@@ -204,6 +204,14 @@ func (l *tomlLexer) lexRvalue() tomlLexStateFn {
return l.lexFalse
}
+ if l.follow("inf") {
+ return l.lexInf
+ }
+
+ if l.follow("nan") {
+ return l.lexNan
+ }
+
if isSpace(next) {
l.skip()
continue
@@ -265,6 +273,18 @@ func (l *tomlLexer) lexFalse() tomlLexStateFn {
return l.lexRvalue
}
+func (l *tomlLexer) lexInf() tomlLexStateFn {
+ l.fastForward(3)
+ l.emit(tokenInf)
+ return l.lexRvalue
+}
+
+func (l *tomlLexer) lexNan() tomlLexStateFn {
+ l.fastForward(3)
+ l.emit(tokenNan)
+ return l.lexRvalue
+}
+
func (l *tomlLexer) lexEqual() tomlLexStateFn {
l.next()
l.emit(tokenEqual)
@@ -277,6 +297,8 @@ func (l *tomlLexer) lexComma() tomlLexStateFn {
return l.lexRvalue
}
+// Parse the key and emits its value without escape sequences.
+// bare keys, basic string keys and literal string keys are supported.
func (l *tomlLexer) lexKey() tomlLexStateFn {
growingString := ""
@@ -287,7 +309,16 @@ func (l *tomlLexer) lexKey() tomlLexStateFn {
if err != nil {
return l.errorf(err.Error())
}
- growingString += `"` + str + `"`
+ growingString += str
+ l.next()
+ continue
+ } else if r == '\'' {
+ l.next()
+ str, err := l.lexLiteralStringAsString(`'`, false)
+ if err != nil {
+ return l.errorf(err.Error())
+ }
+ growingString += str
l.next()
continue
} else if r == '\n' {
@@ -527,6 +558,7 @@ func (l *tomlLexer) lexTableKey() tomlLexStateFn {
return l.lexInsideTableKey
}
+// Parse the key till "]]", but only bare keys are supported
func (l *tomlLexer) lexInsideTableArrayKey() tomlLexStateFn {
for r := l.peek(); r != eof; r = l.peek() {
switch r {
@@ -550,6 +582,7 @@ func (l *tomlLexer) lexInsideTableArrayKey() tomlLexStateFn {
return l.errorf("unclosed table array key")
}
+// Parse the key till "]" but only bare keys are supported
func (l *tomlLexer) lexInsideTableKey() tomlLexStateFn {
for r := l.peek(); r != eof; r = l.peek() {
switch r {
@@ -638,7 +671,14 @@ func (l *tomlLexer) lexNumber() tomlLexStateFn {
if r == '+' || r == '-' {
l.next()
+ if l.follow("inf") {
+ return l.lexInf
+ }
+ if l.follow("nan") {
+ return l.lexNan
+ }
}
+
pointSeen := false
expSeen := false
digitSeen := false
diff --git a/vendor/github.com/pelletier/go-toml/lexer_test.go b/vendor/github.com/pelletier/go-toml/lexer_test.go
index 313b83c5d..cb4913031 100644
--- a/vendor/github.com/pelletier/go-toml/lexer_test.go
+++ b/vendor/github.com/pelletier/go-toml/lexer_test.go
@@ -690,7 +690,7 @@ func TestKeyGroupArray(t *testing.T) {
func TestQuotedKey(t *testing.T) {
testFlow(t, "\"a b\" = 42", []token{
- {Position{1, 1}, tokenKey, "\"a b\""},
+ {Position{1, 1}, tokenKey, "a b"},
{Position{1, 7}, tokenEqual, "="},
{Position{1, 9}, tokenInteger, "42"},
{Position{1, 11}, tokenEOF, ""},
diff --git a/vendor/github.com/pelletier/go-toml/marshal.go b/vendor/github.com/pelletier/go-toml/marshal.go
index 6280225e9..b5a241505 100644
--- a/vendor/github.com/pelletier/go-toml/marshal.go
+++ b/vendor/github.com/pelletier/go-toml/marshal.go
@@ -230,7 +230,7 @@ func (e *Encoder) valueToTree(mtype reflect.Type, mval reflect.Value) (*Tree, er
if err != nil {
return nil, err
}
- tval.Set(opts.name, opts.comment, opts.commented, val)
+ tval.SetWithComment(opts.name, opts.comment, opts.commented, val)
}
}
case reflect.Map:
@@ -245,9 +245,9 @@ func (e *Encoder) valueToTree(mtype reflect.Type, mval reflect.Value) (*Tree, er
if err != nil {
return nil, err
}
- tval.SetPath([]string{keyStr}, "", false, val)
+ tval.SetPath([]string{keyStr}, val)
} else {
- tval.Set(key.String(), "", false, val)
+ tval.Set(key.String(), val)
}
}
}
@@ -486,96 +486,55 @@ func (d *Decoder) valueFromToml(mtype reflect.Type, tval interface{}) (reflect.V
return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to a slice", tval, tval)
default:
switch mtype.Kind() {
- case reflect.Bool:
- val, ok := tval.(bool)
- if !ok {
- return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to bool", tval, tval)
- }
- return reflect.ValueOf(val), nil
- case reflect.Int:
- val, ok := tval.(int64)
- if !ok {
- return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to int", tval, tval)
- }
- return reflect.ValueOf(int(val)), nil
- case reflect.Int8:
- val, ok := tval.(int64)
- if !ok {
- return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to int", tval, tval)
- }
- return reflect.ValueOf(int8(val)), nil
- case reflect.Int16:
- val, ok := tval.(int64)
- if !ok {
- return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to int", tval, tval)
- }
- return reflect.ValueOf(int16(val)), nil
- case reflect.Int32:
- val, ok := tval.(int64)
- if !ok {
- return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to int", tval, tval)
+ case reflect.Bool, reflect.Struct:
+ val := reflect.ValueOf(tval)
+ // if this passes for when mtype is reflect.Struct, tval is a time.Time
+ if !val.Type().ConvertibleTo(mtype) {
+ return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to %v", tval, tval, mtype.String())
}
- return reflect.ValueOf(int32(val)), nil
- case reflect.Int64:
- val, ok := tval.(int64)
- if !ok {
- return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to int", tval, tval)
- }
- return reflect.ValueOf(val), nil
- case reflect.Uint:
- val, ok := tval.(int64)
- if !ok {
- return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to uint", tval, tval)
- }
- return reflect.ValueOf(uint(val)), nil
- case reflect.Uint8:
- val, ok := tval.(int64)
- if !ok {
- return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to uint", tval, tval)
+
+ return val.Convert(mtype), nil
+ case reflect.String:
+ val := reflect.ValueOf(tval)
+ // stupidly, int64 is convertible to string. So special case this.
+ if !val.Type().ConvertibleTo(mtype) || val.Kind() == reflect.Int64 {
+ return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to %v", tval, tval, mtype.String())
}
- return reflect.ValueOf(uint8(val)), nil
- case reflect.Uint16:
- val, ok := tval.(int64)
- if !ok {
- return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to uint", tval, tval)
+
+ return val.Convert(mtype), nil
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ val := reflect.ValueOf(tval)
+ if !val.Type().ConvertibleTo(mtype) {
+ return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to %v", tval, tval, mtype.String())
}
- return reflect.ValueOf(uint16(val)), nil
- case reflect.Uint32:
- val, ok := tval.(int64)
- if !ok {
- return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to uint", tval, tval)
+ if reflect.Indirect(reflect.New(mtype)).OverflowInt(val.Int()) {
+ return reflect.ValueOf(nil), fmt.Errorf("%v(%T) would overflow %v", tval, tval, mtype.String())
}
- return reflect.ValueOf(uint32(val)), nil
- case reflect.Uint64:
- val, ok := tval.(int64)
- if !ok {
- return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to uint", tval, tval)
+
+ return val.Convert(mtype), nil
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+ val := reflect.ValueOf(tval)
+ if !val.Type().ConvertibleTo(mtype) {
+ return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to %v", tval, tval, mtype.String())
}
- return reflect.ValueOf(uint64(val)), nil
- case reflect.Float32:
- val, ok := tval.(float64)
- if !ok {
- return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to float", tval, tval)
+ if val.Int() < 0 {
+ return reflect.ValueOf(nil), fmt.Errorf("%v(%T) is negative so does not fit in %v", tval, tval, mtype.String())
}
- return reflect.ValueOf(float32(val)), nil
- case reflect.Float64:
- val, ok := tval.(float64)
- if !ok {
- return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to float", tval, tval)
+ if reflect.Indirect(reflect.New(mtype)).OverflowUint(uint64(val.Int())) {
+ return reflect.ValueOf(nil), fmt.Errorf("%v(%T) would overflow %v", tval, tval, mtype.String())
}
- return reflect.ValueOf(val), nil
- case reflect.String:
- val, ok := tval.(string)
- if !ok {
- return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to string", tval, tval)
+
+ return val.Convert(mtype), nil
+ case reflect.Float32, reflect.Float64:
+ val := reflect.ValueOf(tval)
+ if !val.Type().ConvertibleTo(mtype) {
+ return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to %v", tval, tval, mtype.String())
}
- return reflect.ValueOf(val), nil
- case reflect.Struct:
- val, ok := tval.(time.Time)
- if !ok {
- return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to time", tval, tval)
+ if reflect.Indirect(reflect.New(mtype)).OverflowFloat(val.Float()) {
+ return reflect.ValueOf(nil), fmt.Errorf("%v(%T) would overflow %v", tval, tval, mtype.String())
}
- return reflect.ValueOf(val), nil
+
+ return val.Convert(mtype), nil
default:
return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to %v(%v)", tval, tval, mtype, mtype.Kind())
}
diff --git a/vendor/github.com/pelletier/go-toml/parser.go b/vendor/github.com/pelletier/go-toml/parser.go
index 0f2ab7a33..2d27599a9 100644
--- a/vendor/github.com/pelletier/go-toml/parser.go
+++ b/vendor/github.com/pelletier/go-toml/parser.go
@@ -5,6 +5,7 @@ package toml
import (
"errors"
"fmt"
+ "math"
"reflect"
"regexp"
"strconv"
@@ -110,7 +111,7 @@ func (p *tomlParser) parseGroupArray() tomlParserStateFn {
newTree := newTree()
newTree.position = startToken.Position
array = append(array, newTree)
- p.tree.SetPath(p.currentTable, "", false, array)
+ p.tree.SetPath(p.currentTable, array)
// remove all keys that were children of this table array
prefix := key.val + "."
@@ -185,10 +186,7 @@ func (p *tomlParser) parseAssign() tomlParserStateFn {
}
// assign value to the found table
- keyVals, err := parseKey(key.val)
- if err != nil {
- p.raiseError(key, "%s", err)
- }
+ keyVals := []string{key.val}
if len(keyVals) != 1 {
p.raiseError(key, "Invalid key")
}
@@ -246,6 +244,13 @@ func (p *tomlParser) parseRvalue() interface{} {
return true
case tokenFalse:
return false
+ case tokenInf:
+ if tok.val[0] == '-' {
+ return math.Inf(-1)
+ }
+ return math.Inf(1)
+ case tokenNan:
+ return math.NaN()
case tokenInteger:
cleanedVal := cleanupNumberToken(tok.val)
var err error
@@ -340,7 +345,7 @@ Loop:
key := p.getToken()
p.assume(tokenEqual)
value := p.parseRvalue()
- tree.Set(key.val, "", false, value)
+ tree.Set(key.val, value)
case tokenComma:
if previous == nil {
p.raiseError(follow, "inline table cannot start with a comma")
@@ -350,7 +355,7 @@ Loop:
}
p.getToken()
default:
- p.raiseError(follow, "unexpected token type in inline table: %s", follow.typ.String())
+ p.raiseError(follow, "unexpected token type in inline table: %s", follow.String())
}
previous = follow
}
diff --git a/vendor/github.com/pelletier/go-toml/parser_test.go b/vendor/github.com/pelletier/go-toml/parser_test.go
index 6c8eec6a3..ca29c442e 100644
--- a/vendor/github.com/pelletier/go-toml/parser_test.go
+++ b/vendor/github.com/pelletier/go-toml/parser_test.go
@@ -2,6 +2,7 @@ package toml
import (
"fmt"
+ "math"
"reflect"
"testing"
"time"
@@ -46,7 +47,7 @@ func assertTree(t *testing.T, tree *Tree, err error, ref map[string]interface{})
func TestCreateSubTree(t *testing.T) {
tree := newTree()
tree.createSubTree([]string{"a", "b", "c"}, Position{})
- tree.Set("a.b.c", "", false, 42)
+ tree.Set("a.b.c", 42)
if tree.Get("a.b.c") != 42 {
t.Fail()
}
@@ -72,6 +73,17 @@ func TestNumberInKey(t *testing.T) {
})
}
+func TestIncorrectKeyExtraSquareBracket(t *testing.T) {
+ _, err := Load(`[a]b]
+zyx = 42`)
+ if err == nil {
+ t.Error("Error should have been returned.")
+ }
+ if err.Error() != "(1, 4): unexpected token" {
+ t.Error("Bad error message:", err.Error())
+ }
+}
+
func TestSimpleNumbers(t *testing.T) {
tree, err := Load("a = +42\nb = -21\nc = +4.2\nd = -2.1")
assertTree(t, tree, err, map[string]interface{}{
@@ -82,6 +94,25 @@ func TestSimpleNumbers(t *testing.T) {
})
}
+func TestSpecialFloats(t *testing.T) {
+ tree, err := Load(`
+normalinf = inf
+plusinf = +inf
+minusinf = -inf
+normalnan = nan
+plusnan = +nan
+minusnan = -nan
+`)
+ assertTree(t, tree, err, map[string]interface{}{
+ "normalinf": math.Inf(1),
+ "plusinf": math.Inf(1),
+ "minusinf": math.Inf(-1),
+ "normalnan": math.NaN(),
+ "plusnan": math.NaN(),
+ "minusnan": math.NaN(),
+ })
+}
+
func TestHexIntegers(t *testing.T) {
tree, err := Load(`a = 0xDEADBEEF`)
assertTree(t, tree, err, map[string]interface{}{"a": int64(3735928559)})
@@ -208,6 +239,36 @@ func TestSpaceKey(t *testing.T) {
})
}
+func TestDoubleQuotedKey(t *testing.T) {
+ tree, err := Load(`
+ "key" = "a"
+ "\t" = "b"
+ "\U0001F914" = "c"
+ "\u2764" = "d"
+ `)
+ assertTree(t, tree, err, map[string]interface{}{
+ "key": "a",
+ "\t": "b",
+ "\U0001F914": "c",
+ "\u2764": "d",
+ })
+}
+
+func TestSingleQuotedKey(t *testing.T) {
+ tree, err := Load(`
+ 'key' = "a"
+ '\t' = "b"
+ '\U0001F914' = "c"
+ '\u2764' = "d"
+ `)
+ assertTree(t, tree, err, map[string]interface{}{
+ `key`: "a",
+ `\t`: "b",
+ `\U0001F914`: "c",
+ `\u2764`: "d",
+ })
+}
+
func TestStringEscapables(t *testing.T) {
tree, err := Load("a = \"a \\n b\"")
assertTree(t, tree, err, map[string]interface{}{
diff --git a/vendor/github.com/pelletier/go-toml/test.sh b/vendor/github.com/pelletier/go-toml/test.sh
index 91a889670..a70a8b022 100755
--- a/vendor/github.com/pelletier/go-toml/test.sh
+++ b/vendor/github.com/pelletier/go-toml/test.sh
@@ -1,6 +1,7 @@
#!/bin/bash
# fail out of the script if anything here fails
set -e
+set -o pipefail
# set the path to the present working directory
export GOPATH=`pwd`
diff --git a/vendor/github.com/pelletier/go-toml/token.go b/vendor/github.com/pelletier/go-toml/token.go
index 5581fe0bc..1a9081346 100644
--- a/vendor/github.com/pelletier/go-toml/token.go
+++ b/vendor/github.com/pelletier/go-toml/token.go
@@ -23,6 +23,8 @@ const (
tokenTrue
tokenFalse
tokenFloat
+ tokenInf
+ tokenNan
tokenEqual
tokenLeftBracket
tokenRightBracket
@@ -55,6 +57,8 @@ var tokenTypeNames = []string{
"True",
"False",
"Float",
+ "Inf",
+ "NaN",
"=",
"[",
"]",
diff --git a/vendor/github.com/pelletier/go-toml/toml.go b/vendor/github.com/pelletier/go-toml/toml.go
index c3e324374..05493a444 100644
--- a/vendor/github.com/pelletier/go-toml/toml.go
+++ b/vendor/github.com/pelletier/go-toml/toml.go
@@ -71,18 +71,15 @@ func (t *Tree) Keys() []string {
}
// Get the value at key in the Tree.
-// Key is a dot-separated path (e.g. a.b.c).
+// Key is a dot-separated path (e.g. a.b.c) without single/double quoted strings.
+// If you need to retrieve non-bare keys, use GetPath.
// Returns nil if the path does not exist in the tree.
// If keys is of length zero, the current tree is returned.
func (t *Tree) Get(key string) interface{} {
if key == "" {
return t
}
- comps, err := parseKey(key)
- if err != nil {
- return nil
- }
- return t.GetPath(comps)
+ return t.GetPath(strings.Split(key, "."))
}
// GetPath returns the element in the tree indicated by 'keys'.
@@ -181,14 +178,26 @@ func (t *Tree) GetDefault(key string, def interface{}) interface{} {
// Set an element in the tree.
// Key is a dot-separated path (e.g. a.b.c).
// Creates all necessary intermediate trees, if needed.
-func (t *Tree) Set(key string, comment string, commented bool, value interface{}) {
- t.SetPath(strings.Split(key, "."), comment, commented, value)
+func (t *Tree) Set(key string, value interface{}) {
+ t.SetWithComment(key, "", false, value)
+}
+
+// SetWithComment is the same as Set, but allows you to provide comment
+// information to the key, that will be reused by Marshal().
+func (t *Tree) SetWithComment(key string, comment string, commented bool, value interface{}) {
+ t.SetPathWithComment(strings.Split(key, "."), comment, commented, value)
}
// SetPath sets an element in the tree.
// Keys is an array of path elements (e.g. {"a","b","c"}).
// Creates all necessary intermediate trees, if needed.
-func (t *Tree) SetPath(keys []string, comment string, commented bool, value interface{}) {
+func (t *Tree) SetPath(keys []string, value interface{}) {
+ t.SetPathWithComment(keys, "", false, value)
+}
+
+// SetPathWithComment is the same as SetPath, but allows you to provide comment
+// information to the key, that will be reused by Marshal().
+func (t *Tree) SetPathWithComment(keys []string, comment string, commented bool, value interface{}) {
subtree := t
for _, intermediateKey := range keys[:len(keys)-1] {
nextTree, exists := subtree.values[intermediateKey]
diff --git a/vendor/github.com/pelletier/go-toml/tomltree_write.go b/vendor/github.com/pelletier/go-toml/tomltree_write.go
index f5ef124f0..d322a9764 100644
--- a/vendor/github.com/pelletier/go-toml/tomltree_write.go
+++ b/vendor/github.com/pelletier/go-toml/tomltree_write.go
@@ -54,9 +54,9 @@ func tomlValueStringRepresentation(v interface{}, indent string, arraysOneElemen
// Ensure a round float does contain a decimal point. Otherwise feeding
// the output back to the parser would convert to an integer.
if math.Trunc(value) == value {
- return strconv.FormatFloat(value, 'f', 1, 32), nil
+ return strings.ToLower(strconv.FormatFloat(value, 'f', 1, 32)), nil
}
- return strconv.FormatFloat(value, 'f', -1, 32), nil
+ return strings.ToLower(strconv.FormatFloat(value, 'f', -1, 32)), nil
case string:
return "\"" + encodeTomlString(value) + "\"", nil
case []byte:
diff --git a/vendor/github.com/pelletier/go-toml/tomltree_write_test.go b/vendor/github.com/pelletier/go-toml/tomltree_write_test.go
index 5ea59bc1a..206203b88 100644
--- a/vendor/github.com/pelletier/go-toml/tomltree_write_test.go
+++ b/vendor/github.com/pelletier/go-toml/tomltree_write_test.go
@@ -309,6 +309,24 @@ func TestTreeWriteToFloat(t *testing.T) {
}
}
+func TestTreeWriteToSpecialFloat(t *testing.T) {
+ expected := `a = +inf
+b = -inf
+c = nan`
+
+ tree, err := Load(expected)
+ if err != nil {
+ t.Fatal(err)
+ }
+ str, err := tree.ToTomlString()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if strings.TrimSpace(str) != strings.TrimSpace(expected) {
+ t.Fatalf("Expected:\n%s\nGot:\n%s", expected, str)
+ }
+}
+
func BenchmarkTreeToTomlString(b *testing.B) {
toml, err := Load(sampleHard)
if err != nil {