diff --git a/Gopkg.lock b/Gopkg.lock index 931a3713a..bd67f25ae 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -39,7 +39,7 @@ branch = "master" name = "github.com/cznic/fileutil" packages = ["."] - revision = "2d566d841097e1297dfb576f809cf9eeecbdbc37" + revision = "6a051e75936f623600b67c2b1116b6b6c0ffb936" [[projects]] name = "github.com/cznic/internal" @@ -65,7 +65,7 @@ branch = "master" name = "github.com/cznic/mathutil" packages = ["."] - revision = "09cde8d5df5fd3e1944897ce6d00d83dd5ed3a91" + revision = "5455a562bccba6fed24079339aa97e44ac0de4bb" [[projects]] branch = "master" @@ -102,7 +102,6 @@ version = "v1.3" [[projects]] - branch = "master" name = "github.com/golang/protobuf" packages = [ "proto", @@ -114,7 +113,8 @@ "ptypes/timestamp", "ptypes/wrappers" ] - revision = "1e59b77b52bf8e4b449a57e6f79f21226d571845" + revision = "925541529c1fa6821df4e44ce2723319eb2be768" + version = "v1.0.0" [[projects]] name = "github.com/golang/snappy" diff --git a/Gopkg.toml b/Gopkg.toml index 2be00de46..90d9b6a42 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -116,10 +116,6 @@ ignored = [ name = "github.com/bradfitz/latlong" revision = "b745505085619d2818bc4b32b5a9fcc539e551fd" -[[constraint]] - name = "github.com/cznic/fileutil" - revision = "2d566d841097e1297dfb576f809cf9eeecbdbc37" - [[constraint]] name = "github.com/cznic/internal" revision = "4747030f7cf2f4c0a01512b00cd68734b167ac3b" @@ -128,26 +124,6 @@ ignored = [ name = "github.com/cznic/kv" revision = "892ccf731fb7aa5e9aa300eb24456d1519afcfc7" -[[constraint]] - name = "github.com/cznic/lldb" - revision = "v1.1.0" - -[[constraint]] - name = "github.com/cznic/mathutil" - revision = "09cde8d5df5fd3e1944897ce6d00d83dd5ed3a91" - -[[constraint]] - name = "github.com/cznic/sortutil" - revision = "4c7342852e65c2088c981288f2c5610d10b9f7f4" - -[[constraint]] - name = "github.com/cznic/zappy" - revision = "2533cb5b45cc6c07421468ce262899ddc9d53fb7" - -[[constraint]] - name = "github.com/edsrzf/mmap-go" - revision = "0bce6a6887123b67a60366d2c9fe2dfb74289d2e" - [[constraint]] name = "github.com/fsnotify/fsnotify" revision = "629574ca2a5df945712d3079857300b5e4da0236" @@ -160,10 +136,6 @@ ignored = [ name = "github.com/go-sql-driver/mysql" version = "1.3.0" -[[constraint]] - name = "github.com/golang/protobuf" - revision = "8ee79997227bf9b34611aee7946ae64735e6fd93" - [[constraint]] name = "github.com/golang/snappy" revision = "553a641470496b2327abcac10b36396bd98e45c9" @@ -180,10 +152,6 @@ ignored = [ name = "github.com/gopherjs/jquery" revision = "fbbfc4bbe29a29cb05788b66be44e0ac7f43cac7" -[[constraint]] - name = "github.com/gopherjs/jsbuiltin" - revision = "67703bfb044e3192fbcab025c3aeaeedafad1f2f" - [[constraint]] name = "github.com/kardianos/osext" revision = "29ae4ffbc9a6fe9fb2bc5029050ce6996ea1d3bc" @@ -224,10 +192,6 @@ ignored = [ name = "github.com/nf/cr2" revision = "05d46fef4f2f903240751e25871cd318d001deba" -[[constraint]] - name = "github.com/pkg/errors" - revision = "f15c970de5b76fac0b59abb32d62c17cc7bed265" - [[constraint]] name = "github.com/plaid/plaid-go" revision = "02b6af68061bf89a293eaf15dc6c955ce02dd22b" diff --git a/vendor/github.com/cznic/fileutil/AUTHORS b/vendor/github.com/cznic/fileutil/AUTHORS index 3a5e488b5..08f57abc7 100644 --- a/vendor/github.com/cznic/fileutil/AUTHORS +++ b/vendor/github.com/cznic/fileutil/AUTHORS @@ -12,4 +12,4 @@ CZ.NIC z.s.p.o. Jan Mercl <0xjnml@gmail.com> Linelane GmbH Aaron Bieber - +Pierre-Alain TORET diff --git a/vendor/github.com/cznic/fileutil/CONTRIBUTORS b/vendor/github.com/cznic/fileutil/CONTRIBUTORS index 988a13960..ab57da227 100644 --- a/vendor/github.com/cznic/fileutil/CONTRIBUTORS +++ b/vendor/github.com/cznic/fileutil/CONTRIBUTORS @@ -13,3 +13,4 @@ Jan Mercl <0xjnml@gmail.com> Nick Owens Tamás Gulácsi Aaron Bieber +Pierre-Alain TORET diff --git a/vendor/github.com/cznic/fileutil/fileutil_dragonfly.go b/vendor/github.com/cznic/fileutil/fileutil_dragonfly.go new file mode 100644 index 000000000..932d7614b --- /dev/null +++ b/vendor/github.com/cznic/fileutil/fileutil_dragonfly.go @@ -0,0 +1,29 @@ +// Copyright (c) 2014 The fileutil Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !arm + +package fileutil + +import ( + "io" + "os" +) + +const hasPunchHole = false + +// PunchHole deallocates space inside a file in the byte range starting at +// offset and continuing for len bytes. Unimplemented on DragonFlyBSD. +func PunchHole(f *os.File, off, len int64) error { + return nil +} + +// Fadvise predeclares an access pattern for file data. See also 'man 2 +// posix_fadvise'. Unimplemented on DragonFlyBSD. +func Fadvise(f *os.File, off, len int64, advice FadviseAdvice) error { + return nil +} + +// IsEOF reports whether err is an EOF condition. +func IsEOF(err error) bool { return err == io.EOF } diff --git a/vendor/github.com/cznic/mathutil/int.go b/vendor/github.com/cznic/mathutil/int.go new file mode 100644 index 000000000..ea1c18e69 --- /dev/null +++ b/vendor/github.com/cznic/mathutil/int.go @@ -0,0 +1,155 @@ +// Copyright (c) 2018 The mathutil Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mathutil + +import ( + "fmt" + "math" + "math/big" +) + +var ( + // The maximun Int128 value. + MaxInt128 *big.Int + // The minimun Int128 value. + MinInt128 *big.Int +) + +func init() { + MaxInt128 = big.NewInt(0) + MaxInt128.SetBit(MaxInt128, 127, 1) + MaxInt128.Sub(MaxInt128, _1) + MinInt128 = big.NewInt(0) + MinInt128.Set(MaxInt128) + MinInt128.Add(MinInt128, _1) + MinInt128.Neg(MinInt128) +} + +// Int128 is an 128 bit integer. +type Int128 struct { + Lo int64 // Bits 63..0. + Hi int64 // Bits 127..64. +} + +// Add returns the sum of x and y and a carry indication. +func (x Int128) Add(y Int128) (r Int128, cy bool) { + r.Lo = x.Lo + y.Lo + r.Hi = x.Hi + y.Hi + if uint64(r.Lo) < uint64(x.Lo) { + r.Hi++ + } + return r, (r.Cmp(x) < 0) == (y.Sign() >= 0) +} + +// BigInt returns x in the form of a big.Int. +func (x Int128) BigInt() *big.Int { + r := big.NewInt(x.Hi) + r.Lsh(r, 64) + lo := big.NewInt(0) + lo.SetUint64(uint64(x.Lo)) + return r.Add(r, lo) +} + +// Cmp compares x and y and returns: +// +// -1 if x < y +// 0 if x == y +// +1 if x > y +func (x Int128) Cmp(y Int128) int { + if x.Hi > y.Hi { + return 1 + } + + if x.Hi < y.Hi { + return -1 + } + + if uint64(x.Lo) > uint64(y.Lo) { + return 1 + } + + if uint64(x.Lo) < uint64(y.Lo) { + return -1 + } + + return 0 +} + +// Neg returns -x and an indication that x was not equal to MinInt128. +func (x Int128) Neg() (r Int128, ok bool) { + if x == (Int128{Hi: math.MinInt64}) { + return x, false + } + + x.Lo = ^x.Lo + x.Hi = ^x.Hi + r, _ = x.Add(Int128{Lo: 1}) + return r, true +} + +// SetBigInt sets x to y, returns x and an error, if any. +func (x *Int128) SetBigInt(y *big.Int) (r Int128, err error) { + if y.Cmp(MaxInt128) > 0 { + return *x, fmt.Errorf("%T.SetInt: overflow", x) + } + if y.Cmp(MinInt128) < 0 { + return *x, fmt.Errorf("%T.SetInt: underflow", x) + } + neg := y.Sign() < 0 + var z big.Int + z.Set(y) + if neg { + z.Neg(&z) + } + r.Lo = z.Int64() + z.Rsh(&z, 64) + r.Hi = z.Int64() + if neg { + r, _ = r.Neg() + } + *x = r + return r, nil +} + +// SetInt64 sets x to y and returns x. +func (x *Int128) SetInt64(y int64) (r Int128) { + r.Lo = y + if y >= 0 { + r.Hi = 0 + *x = r + return r + } + + r.Hi = -1 + *x = r + return r +} + +// SetInt64 sets x to y and returns x. +func (x *Int128) SetUint64(y uint64) (r Int128) { + r = Int128{Lo: int64(y)} + *x = r + return r +} + +// Sign returns: +// +// -1 if x < 0 +// 0 if x == 0 +// +1 if x > 0 +func (x Int128) Sign() int { + if x.Hi < 0 { + return -1 + } + + if x.Hi != 0 && x.Lo != 0 { + return 1 + } + + return 0 +} + +// String implements fmt.Stringer() +func (x Int128) String() string { return x.BigInt().String() } diff --git a/vendor/github.com/cznic/mathutil/mathutil.go b/vendor/github.com/cznic/mathutil/mathutil.go index 6c6ea916d..d2c4046a6 100644 --- a/vendor/github.com/cznic/mathutil/mathutil.go +++ b/vendor/github.com/cznic/mathutil/mathutil.go @@ -369,7 +369,7 @@ func AddUint128_64(a, b uint64) (hi uint64, lo uint64) { if lo < a { hi = 1 } - return + return hi, lo } // MulUint128_64 returns the uint128 bit product of uint64 a and b. diff --git a/vendor/github.com/golang/protobuf/proto/discard.go b/vendor/github.com/golang/protobuf/proto/discard.go new file mode 100644 index 000000000..bd0e3bb4c --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/discard.go @@ -0,0 +1,151 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2017 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +import ( + "fmt" + "reflect" + "strings" +) + +// DiscardUnknown recursively discards all unknown fields from this message +// and all embedded messages. +// +// When unmarshaling a message with unrecognized fields, the tags and values +// of such fields are preserved in the Message. This allows a later call to +// marshal to be able to produce a message that continues to have those +// unrecognized fields. To avoid this, DiscardUnknown is used to +// explicitly clear the unknown fields after unmarshaling. +// +// For proto2 messages, the unknown fields of message extensions are only +// discarded from messages that have been accessed via GetExtension. +func DiscardUnknown(m Message) { + discardLegacy(m) +} + +func discardLegacy(m Message) { + v := reflect.ValueOf(m) + if v.Kind() != reflect.Ptr || v.IsNil() { + return + } + v = v.Elem() + if v.Kind() != reflect.Struct { + return + } + t := v.Type() + + for i := 0; i < v.NumField(); i++ { + f := t.Field(i) + if strings.HasPrefix(f.Name, "XXX_") { + continue + } + vf := v.Field(i) + tf := f.Type + + // Unwrap tf to get its most basic type. + var isPointer, isSlice bool + if tf.Kind() == reflect.Slice && tf.Elem().Kind() != reflect.Uint8 { + isSlice = true + tf = tf.Elem() + } + if tf.Kind() == reflect.Ptr { + isPointer = true + tf = tf.Elem() + } + if isPointer && isSlice && tf.Kind() != reflect.Struct { + panic(fmt.Sprintf("%T.%s cannot be a slice of pointers to primitive types", m, f.Name)) + } + + switch tf.Kind() { + case reflect.Struct: + switch { + case !isPointer: + panic(fmt.Sprintf("%T.%s cannot be a direct struct value", m, f.Name)) + case isSlice: // E.g., []*pb.T + for j := 0; j < vf.Len(); j++ { + discardLegacy(vf.Index(j).Interface().(Message)) + } + default: // E.g., *pb.T + discardLegacy(vf.Interface().(Message)) + } + case reflect.Map: + switch { + case isPointer || isSlice: + panic(fmt.Sprintf("%T.%s cannot be a pointer to a map or a slice of map values", m, f.Name)) + default: // E.g., map[K]V + tv := vf.Type().Elem() + if tv.Kind() == reflect.Ptr && tv.Implements(protoMessageType) { // Proto struct (e.g., *T) + for _, key := range vf.MapKeys() { + val := vf.MapIndex(key) + discardLegacy(val.Interface().(Message)) + } + } + } + case reflect.Interface: + // Must be oneof field. + switch { + case isPointer || isSlice: + panic(fmt.Sprintf("%T.%s cannot be a pointer to a interface or a slice of interface values", m, f.Name)) + default: // E.g., test_proto.isCommunique_Union interface + if !vf.IsNil() && f.Tag.Get("protobuf_oneof") != "" { + vf = vf.Elem() // E.g., *test_proto.Communique_Msg + if !vf.IsNil() { + vf = vf.Elem() // E.g., test_proto.Communique_Msg + vf = vf.Field(0) // E.g., Proto struct (e.g., *T) or primitive value + if vf.Kind() == reflect.Ptr { + discardLegacy(vf.Interface().(Message)) + } + } + } + } + } + } + + if vf := v.FieldByName("XXX_unrecognized"); vf.IsValid() { + if vf.Type() != reflect.TypeOf([]byte{}) { + panic("expected XXX_unrecognized to be of type []byte") + } + vf.Set(reflect.ValueOf([]byte(nil))) + } + + // For proto2 messages, only discard unknown fields in message extensions + // that have been accessed via GetExtension. + if em, ok := extendable(m); ok { + // Ignore lock since discardLegacy is not concurrency safe. + emm, _ := em.extensionsRead() + for _, mx := range emm { + if m, ok := mx.value.(Message); ok { + discardLegacy(m) + } + } + } +}