update dependencies
This commit is contained in:
parent
fce1b99683
commit
397e9c0842
164 changed files with 5207 additions and 2213 deletions
34
vendor/golang.org/x/text/README.md
generated
vendored
34
vendor/golang.org/x/text/README.md
generated
vendored
|
|
@ -1,7 +1,8 @@
|
|||
# Go Text
|
||||
|
||||
This repository holds supplementary Go libraries for text processing, many involving Unicode.
|
||||
|
||||
|
||||
# Semantic Versioning
|
||||
## Semantic Versioning
|
||||
This repo uses Semantic versioning (http://semver.org/), so
|
||||
1. MAJOR version when you make incompatible API changes,
|
||||
1. MINOR version when you add functionality in a backwards-compatible manner,
|
||||
|
|
@ -18,8 +19,12 @@ So going from 0.1.0 to 0.2.0 is considered to be a major version bump.
|
|||
A major new CLDR version is mapped to a minor version increase in x/text.
|
||||
Any other new CLDR version is mapped to a patch version increase in x/text.
|
||||
|
||||
## Download/Install
|
||||
|
||||
# Contribute
|
||||
The easiest way to install is to run `go get -u golang.org/x/text`. You can
|
||||
also manually git clone the repository to `$GOPATH/src/golang.org/x/text`.
|
||||
|
||||
## Contribute
|
||||
To submit changes to this repository, see http://golang.org/doc/contribute.html.
|
||||
|
||||
To generate the tables in this repository (except for the encoding tables),
|
||||
|
|
@ -40,6 +45,20 @@ from this directory to run all tests. Add the "-tags icu" flag to also run
|
|||
ICU conformance tests (if available). This requires that you have the correct
|
||||
ICU version installed on your system.
|
||||
|
||||
TODO:
|
||||
- updating unversioned source files.
|
||||
|
||||
## Generating Tables
|
||||
|
||||
To generate the tables in this repository (except for the encoding
|
||||
tables), run `go generate` from this directory. By default tables are
|
||||
generated for the Unicode version in core and the CLDR version defined in
|
||||
golang.org/x/text/unicode/cldr.
|
||||
|
||||
Running go generate will as a side effect create a DATA subdirectory in this
|
||||
directory which holds all files that are used as a source for generating the
|
||||
tables. This directory will also serve as a cache.
|
||||
|
||||
## Versions
|
||||
To update a Unicode version run
|
||||
|
||||
|
|
@ -61,3 +80,12 @@ backwards compatibility is not maintained.
|
|||
So updating to a different version may not work.
|
||||
|
||||
The files in DATA/{iana|icu|w3|whatwg} are currently not versioned.
|
||||
|
||||
## Report Issues / Send Patches
|
||||
|
||||
This repository uses Gerrit for code changes. To learn how to submit changes to
|
||||
this repository, see https://golang.org/doc/contribute.html.
|
||||
|
||||
The main issue tracker for the image repository is located at
|
||||
https://github.com/golang/go/issues. Prefix your issue with "x/image:" in the
|
||||
subject line, so it is easy to find.
|
||||
|
|
|
|||
46
vendor/golang.org/x/text/internal/number/decimal.go
generated
vendored
46
vendor/golang.org/x/text/internal/number/decimal.go
generated
vendored
|
|
@ -406,23 +406,35 @@ func (d *Decimal) ConvertFloat(r RoundingContext, x float64, size int) {
|
|||
// By default we get the exact decimal representation.
|
||||
verb := byte('g')
|
||||
prec := -1
|
||||
// Determine rounding, if possible. As the strconv API does not return the
|
||||
// rounding accuracy (exact/rounded up|down), we can only round using
|
||||
// ToNearestEven.
|
||||
// Something like this would work:
|
||||
// AppendDigits(dst []byte, x float64, base, size, prec int) (digits []byte, exp, accuracy int)
|
||||
//
|
||||
// TODO: At this point strconv's rounding is imprecise to the point that it
|
||||
// is not useable for this purpose.
|
||||
// See https://github.com/golang/go/issues/21714
|
||||
// if r.Mode == ToNearestEven {
|
||||
// if n := r.RoundSignificantDigits(); n >= 0 {
|
||||
// prec = n
|
||||
// } else if n = r.RoundFractionDigits(); n >= 0 {
|
||||
// prec = n
|
||||
// verb = 'f'
|
||||
// }
|
||||
// }
|
||||
// As the strconv API does not return the rounding accuracy, we can only
|
||||
// round using ToNearestEven.
|
||||
if r.Mode == ToNearestEven {
|
||||
if n := r.RoundSignificantDigits(); n >= 0 {
|
||||
prec = n
|
||||
} else if n = r.RoundFractionDigits(); n >= 0 {
|
||||
prec = n
|
||||
verb = 'f'
|
||||
}
|
||||
} else {
|
||||
// TODO: At this point strconv's rounding is imprecise to the point that
|
||||
// it is not useable for this purpose.
|
||||
// See https://github.com/golang/go/issues/21714
|
||||
// If rounding is requested, we ask for a large number of digits and
|
||||
// round from there to simulate rounding only once.
|
||||
// Ideally we would have strconv export an AppendDigits that would take
|
||||
// a rounding mode and/or return an accuracy. Something like this would
|
||||
// work:
|
||||
// AppendDigits(dst []byte, x float64, base, size, prec int) (digits []byte, exp, accuracy int)
|
||||
hasPrec := r.RoundSignificantDigits() >= 0
|
||||
hasScale := r.RoundFractionDigits() >= 0
|
||||
if hasPrec || hasScale {
|
||||
// prec is the number of mantissa bits plus some extra for safety.
|
||||
// We need at least the number of mantissa bits as decimals to
|
||||
// accurately represent the floating point without rounding, as each
|
||||
// bit requires one more decimal to represent: 0.5, 0.25, 0.125, ...
|
||||
prec = 60
|
||||
}
|
||||
}
|
||||
|
||||
b := strconv.AppendFloat(d.Digits[:0], abs, verb, prec, size)
|
||||
i := 0
|
||||
|
|
|
|||
39
vendor/golang.org/x/text/internal/number/decimal_test.go
generated
vendored
39
vendor/golang.org/x/text/internal/number/decimal_test.go
generated
vendored
|
|
@ -256,12 +256,10 @@ func TestConvert(t *testing.T) {
|
|||
rc RoundingContext
|
||||
out string
|
||||
}{
|
||||
// TODO: uncommented tests can be restored when convert does its own
|
||||
// rounding.
|
||||
// {-0.001, scale2, "-0.00"}, // not normalized
|
||||
// {0.1234, prec3, "0.123"},
|
||||
// {1234.0, prec3, "1230"},
|
||||
// {1.2345e10, prec3, "12300000000"},
|
||||
{-0.001, scale2, "-0.00"},
|
||||
{0.1234, prec3, "0.123"},
|
||||
{1234.0, prec3, "1230"},
|
||||
{1.2345e10, prec3, "12300000000"},
|
||||
|
||||
{int8(-34), scale2, "-34"},
|
||||
{int16(-234), scale2, "-234"},
|
||||
|
|
@ -273,18 +271,37 @@ func TestConvert(t *testing.T) {
|
|||
{uint32(234), scale2, "234"},
|
||||
{uint64(234), scale2, "234"},
|
||||
{uint(234), scale2, "234"},
|
||||
{-1e9, scale2, "-1000000000"},
|
||||
{0.234, scale2away, "0.234"}, // rounding postponed as not ToNearestEven
|
||||
{-1e9, scale2, "-1000000000.00"},
|
||||
// The following two causes this result to have a lot of digits:
|
||||
// 1) 0.234 cannot be accurately represented as a float64, and
|
||||
// 2) as strconv does not support the rounding AwayFromZero, Convert
|
||||
// leaves the rounding to caller.
|
||||
{0.234, scale2away,
|
||||
"0.2340000000000000135447209004269097931683063507080078125"},
|
||||
|
||||
{0.0249, inc0_05, "0.00"},
|
||||
{0.025, inc0_05, "0.00"},
|
||||
{0.0251, inc0_05, "0.05"},
|
||||
{0.03, inc0_05, "0.05"},
|
||||
{0.025, inc0_05, "0"},
|
||||
{0.075, inc0_05, "0.1"},
|
||||
{0.049, inc0_05, "0.05"},
|
||||
{0.05, inc0_05, "0.05"},
|
||||
{0.051, inc0_05, "0.05"},
|
||||
{0.0749, inc0_05, "0.05"},
|
||||
{0.075, inc0_05, "0.10"},
|
||||
{0.0751, inc0_05, "0.10"},
|
||||
{324, inc50, "300"},
|
||||
{325, inc50, "300"},
|
||||
{326, inc50, "350"},
|
||||
{349, inc50, "350"},
|
||||
{350, inc50, "350"},
|
||||
{351, inc50, "350"},
|
||||
{374, inc50, "350"},
|
||||
{375, inc50, "400"},
|
||||
{376, inc50, "400"},
|
||||
|
||||
// Here the scale is 2, but the digits get shifted left. As we use
|
||||
// AppendFloat to do the rounding an exta 0 gets added.
|
||||
{0.123, roundShift, "0.123"},
|
||||
{0.123, roundShift, "0.1230"},
|
||||
|
||||
{converter(3), scale2, "100"},
|
||||
|
||||
|
|
|
|||
6
vendor/golang.org/x/text/number/number_test.go
generated
vendored
6
vendor/golang.org/x/text/number/number_test.go
generated
vendored
|
|
@ -64,8 +64,8 @@ func TestFormatter(t *testing.T) {
|
|||
want: "0.12",
|
||||
}, {
|
||||
desc: "max fraction overflow",
|
||||
f: Decimal(0.123, MaxFractionDigits(1e6)),
|
||||
want: "0.123",
|
||||
f: Decimal(0.125, MaxFractionDigits(1e6)),
|
||||
want: "0.125",
|
||||
}, {
|
||||
desc: "min integer overflow",
|
||||
f: Decimal(0, MinIntegerDigits(1e6)),
|
||||
|
|
@ -172,7 +172,7 @@ func TestFormatter(t *testing.T) {
|
|||
want: "123.45‰",
|
||||
}, {
|
||||
desc: "percent fraction",
|
||||
f: PerMille(0.12345, Scale(1)),
|
||||
f: PerMille(0.12344, Scale(1)),
|
||||
want: "123.4‰",
|
||||
}}
|
||||
for _, tc := range testCases {
|
||||
|
|
|
|||
4
vendor/golang.org/x/text/secure/precis/doc.go
generated
vendored
4
vendor/golang.org/x/text/secure/precis/doc.go
generated
vendored
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
// Package precis contains types and functions for the preparation,
|
||||
// enforcement, and comparison of internationalized strings ("PRECIS") as
|
||||
// defined in RFC 7564. It also contains several pre-defined profiles for
|
||||
// passwords, nicknames, and usernames as defined in RFC 7613 and RFC 7700.
|
||||
// defined in RFC 8264. It also contains several pre-defined profiles for
|
||||
// passwords, nicknames, and usernames as defined in RFC 8265 and RFC 8266.
|
||||
//
|
||||
// BE ADVISED: This package is under construction and the API may change in
|
||||
// backwards incompatible ways and without notice.
|
||||
|
|
|
|||
17
vendor/golang.org/x/text/secure/precis/enforce_test.go
generated
vendored
17
vendor/golang.org/x/text/secure/precis/enforce_test.go
generated
vendored
|
|
@ -279,13 +279,16 @@ func TestBytes(t *testing.T) {
|
|||
t.Errorf("got %+q (err: %v); want %+q (err: %v)", string(e), err, tc.output, tc.err)
|
||||
}
|
||||
})
|
||||
// Test that calling Bytes with something that doesn't transform returns a
|
||||
// copy.
|
||||
orig := []byte("hello")
|
||||
b, _ := NewFreeform().Bytes(orig)
|
||||
if reflect.ValueOf(b).Pointer() == reflect.ValueOf(orig).Pointer() {
|
||||
t.Error("original and result are the same slice; should be a copy")
|
||||
}
|
||||
|
||||
t.Run("Copy", func(t *testing.T) {
|
||||
// Test that calling Bytes with something that doesn't transform returns a
|
||||
// copy.
|
||||
orig := []byte("hello")
|
||||
b, _ := NewFreeform().Bytes(orig)
|
||||
if reflect.ValueOf(b).Pointer() == reflect.ValueOf(orig).Pointer() {
|
||||
t.Error("original and result are the same slice; should be a copy")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestAppend(t *testing.T) {
|
||||
|
|
|
|||
28
vendor/golang.org/x/text/secure/precis/nickname.go
generated
vendored
28
vendor/golang.org/x/text/secure/precis/nickname.go
generated
vendored
|
|
@ -23,24 +23,26 @@ func (t *nickAdditionalMapping) Reset() {
|
|||
}
|
||||
|
||||
func (t *nickAdditionalMapping) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) {
|
||||
// RFC 7700 §2.1. Rules
|
||||
// RFC 8266 §2.1. Rules
|
||||
//
|
||||
// 2. Additional Mapping Rule: The additional mapping rule consists of
|
||||
// the following sub-rules.
|
||||
// the following sub-rules.
|
||||
//
|
||||
// 1. Any instances of non-ASCII space MUST be mapped to ASCII
|
||||
// space (U+0020); a non-ASCII space is any Unicode code point
|
||||
// having a general category of "Zs", naturally with the
|
||||
// exception of U+0020.
|
||||
// a. Map any instances of non-ASCII space to SPACE (U+0020); a
|
||||
// non-ASCII space is any Unicode code point having a general
|
||||
// category of "Zs", naturally with the exception of SPACE
|
||||
// (U+0020). (The inclusion of only ASCII space prevents
|
||||
// confusion with various non-ASCII space code points, many of
|
||||
// which are difficult to reproduce across different input
|
||||
// methods.)
|
||||
//
|
||||
// 2. Any instances of the ASCII space character at the beginning
|
||||
// or end of a nickname MUST be removed (e.g., "stpeter " is
|
||||
// mapped to "stpeter").
|
||||
// b. Remove any instances of the ASCII space character at the
|
||||
// beginning or end of a nickname (e.g., "stpeter " is mapped to
|
||||
// "stpeter").
|
||||
//
|
||||
// 3. Interior sequences of more than one ASCII space character
|
||||
// MUST be mapped to a single ASCII space character (e.g.,
|
||||
// "St Peter" is mapped to "St Peter").
|
||||
|
||||
// c. Map interior sequences of more than one ASCII space character
|
||||
// to a single ASCII space character (e.g., "St Peter" is
|
||||
// mapped to "St Peter").
|
||||
for nSrc < len(src) {
|
||||
r, size := utf8.DecodeRune(src[nSrc:])
|
||||
if size == 0 { // Incomplete UTF-8 encoding
|
||||
|
|
|
|||
4
vendor/golang.org/x/text/secure/precis/options.go
generated
vendored
4
vendor/golang.org/x/text/secure/precis/options.go
generated
vendored
|
|
@ -28,6 +28,7 @@ type options struct {
|
|||
width transform.SpanningTransformer
|
||||
disallowEmpty bool
|
||||
bidiRule bool
|
||||
repeat bool
|
||||
|
||||
// Comparison options
|
||||
ignorecase bool
|
||||
|
|
@ -78,6 +79,9 @@ var (
|
|||
bidiRule = func(o *options) {
|
||||
o.bidiRule = true
|
||||
}
|
||||
repeat = func(o *options) {
|
||||
o.repeat = true
|
||||
}
|
||||
)
|
||||
|
||||
// TODO: move this logic to package transform
|
||||
|
|
|
|||
116
vendor/golang.org/x/text/secure/precis/profile.go
generated
vendored
116
vendor/golang.org/x/text/secure/precis/profile.go
generated
vendored
|
|
@ -60,26 +60,44 @@ func (p *Profile) NewTransformer() *Transformer {
|
|||
// These transforms are applied in the order defined in
|
||||
// https://tools.ietf.org/html/rfc7564#section-7
|
||||
|
||||
if p.options.foldWidth {
|
||||
ts = append(ts, width.Fold)
|
||||
// RFC 8266 §2.1:
|
||||
//
|
||||
// Implementation experience has shown that applying the rules for the
|
||||
// Nickname profile is not an idempotent procedure for all code points.
|
||||
// Therefore, an implementation SHOULD apply the rules repeatedly until
|
||||
// the output string is stable; if the output string does not stabilize
|
||||
// after reapplying the rules three (3) additional times after the first
|
||||
// application, the implementation SHOULD terminate application of the
|
||||
// rules and reject the input string as invalid.
|
||||
//
|
||||
// There is no known string that will change indefinitely, so repeat 4 times
|
||||
// and rely on the Span method to keep things relatively performant.
|
||||
r := 1
|
||||
if p.options.repeat {
|
||||
r = 4
|
||||
}
|
||||
for ; r > 0; r-- {
|
||||
if p.options.foldWidth {
|
||||
ts = append(ts, width.Fold)
|
||||
}
|
||||
|
||||
for _, f := range p.options.additional {
|
||||
ts = append(ts, f())
|
||||
for _, f := range p.options.additional {
|
||||
ts = append(ts, f())
|
||||
}
|
||||
|
||||
if p.options.cases != nil {
|
||||
ts = append(ts, p.options.cases)
|
||||
}
|
||||
|
||||
ts = append(ts, p.options.norm)
|
||||
|
||||
if p.options.bidiRule {
|
||||
ts = append(ts, bidirule.New())
|
||||
}
|
||||
|
||||
ts = append(ts, &checker{p: p, allowed: p.Allowed()})
|
||||
}
|
||||
|
||||
if p.options.cases != nil {
|
||||
ts = append(ts, p.options.cases)
|
||||
}
|
||||
|
||||
ts = append(ts, p.options.norm)
|
||||
|
||||
if p.options.bidiRule {
|
||||
ts = append(ts, bidirule.New())
|
||||
}
|
||||
|
||||
ts = append(ts, &checker{p: p, allowed: p.Allowed()})
|
||||
|
||||
// TODO: Add the disallow empty rule with a dummy transformer?
|
||||
|
||||
return &Transformer{transform.Chain(ts...)}
|
||||
|
|
@ -162,42 +180,48 @@ func (b *buffers) enforce(p *Profile, src []byte, comparing bool) (str []byte, e
|
|||
}
|
||||
|
||||
// These transforms are applied in the order defined in
|
||||
// https://tools.ietf.org/html/rfc7564#section-7
|
||||
// https://tools.ietf.org/html/rfc8264#section-7
|
||||
|
||||
// TODO: allow different width transforms options.
|
||||
if p.options.foldWidth || (p.options.ignorecase && comparing) {
|
||||
b.apply(foldWidthT)
|
||||
r := 1
|
||||
if p.options.repeat {
|
||||
r = 4
|
||||
}
|
||||
for _, f := range p.options.additional {
|
||||
if err = b.apply(f()); err != nil {
|
||||
for ; r > 0; r-- {
|
||||
// TODO: allow different width transforms options.
|
||||
if p.options.foldWidth || (p.options.ignorecase && comparing) {
|
||||
b.apply(foldWidthT)
|
||||
}
|
||||
for _, f := range p.options.additional {
|
||||
if err = b.apply(f()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if p.options.cases != nil {
|
||||
b.apply(p.options.cases)
|
||||
}
|
||||
if comparing && p.options.ignorecase {
|
||||
b.apply(lowerCaseT)
|
||||
}
|
||||
b.apply(p.norm)
|
||||
if p.options.bidiRule && !bidirule.Valid(b.src) {
|
||||
return nil, bidirule.ErrInvalid
|
||||
}
|
||||
c := checker{p: p}
|
||||
if _, err := c.span(b.src, true); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if p.options.cases != nil {
|
||||
b.apply(p.options.cases)
|
||||
}
|
||||
if comparing && p.options.ignorecase {
|
||||
b.apply(lowerCaseT)
|
||||
}
|
||||
b.apply(p.norm)
|
||||
if p.options.bidiRule && !bidirule.Valid(b.src) {
|
||||
return nil, bidirule.ErrInvalid
|
||||
}
|
||||
c := checker{p: p}
|
||||
if _, err := c.span(b.src, true); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if p.disallow != nil {
|
||||
for i := 0; i < len(b.src); {
|
||||
r, size := utf8.DecodeRune(b.src[i:])
|
||||
if p.disallow.Contains(r) {
|
||||
return nil, errDisallowedRune
|
||||
if p.disallow != nil {
|
||||
for i := 0; i < len(b.src); {
|
||||
r, size := utf8.DecodeRune(b.src[i:])
|
||||
if p.disallow.Contains(r) {
|
||||
return nil, errDisallowedRune
|
||||
}
|
||||
i += size
|
||||
}
|
||||
i += size
|
||||
}
|
||||
}
|
||||
if p.options.disallowEmpty && len(b.src) == 0 {
|
||||
return nil, errEmptyString
|
||||
if p.options.disallowEmpty && len(b.src) == 0 {
|
||||
return nil, errEmptyString
|
||||
}
|
||||
}
|
||||
return b.src, nil
|
||||
}
|
||||
|
|
|
|||
6
vendor/golang.org/x/text/secure/precis/profile_test.go
generated
vendored
6
vendor/golang.org/x/text/secure/precis/profile_test.go
generated
vendored
|
|
@ -103,9 +103,9 @@ var compareTestCases = []struct {
|
|||
|
||||
// After applying the Nickname profile, \u00a8 becomes \u0020\u0308,
|
||||
// however because the nickname profile is not idempotent, applying it again
|
||||
// to \u0020\u0308 results in \u0308. This behavior is "correct", even if it
|
||||
// is unexpected.
|
||||
{"\u00a8", "\u0020\u0308", false},
|
||||
// to \u0020\u0308 results in \u0308.
|
||||
{"\u00a8", "\u0020\u0308", true},
|
||||
{"\u00a8", "\u0308", true},
|
||||
{"\u0020\u0308", "\u0308", true},
|
||||
}},
|
||||
}
|
||||
|
|
|
|||
12
vendor/golang.org/x/text/secure/precis/profiles.go
generated
vendored
12
vendor/golang.org/x/text/secure/precis/profiles.go
generated
vendored
|
|
@ -13,18 +13,17 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
// Implements the Nickname profile specified in RFC 7700.
|
||||
// The nickname profile is not idempotent and may need to be applied multiple
|
||||
// times before being used for comparisons.
|
||||
// Implements the Nickname profile specified in RFC 8266.
|
||||
Nickname *Profile = nickname
|
||||
|
||||
// Implements the UsernameCaseMapped profile specified in RFC 7613.
|
||||
// Implements the UsernameCaseMapped profile specified in RFC 8265.
|
||||
UsernameCaseMapped *Profile = usernameCaseMap
|
||||
|
||||
// Implements the UsernameCasePreserved profile specified in RFC 7613.
|
||||
// Implements the UsernameCasePreserved profile specified in RFC 8265.
|
||||
UsernameCasePreserved *Profile = usernameNoCaseMap
|
||||
|
||||
// Implements the OpaqueString profile defined in RFC 7613 for passwords and other secure labels.
|
||||
// Implements the OpaqueString profile defined in RFC 8265 for passwords and
|
||||
// other secure labels.
|
||||
OpaqueString *Profile = opaquestring
|
||||
)
|
||||
|
||||
|
|
@ -37,6 +36,7 @@ var (
|
|||
IgnoreCase,
|
||||
Norm(norm.NFKC),
|
||||
DisallowEmpty,
|
||||
repeat,
|
||||
),
|
||||
class: freeform,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue