From 2fa7c464f019f67c5c0494aaf5ac0f5ecc1ee7a7 Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Tue, 16 Jan 2018 12:03:31 -0500 Subject: Updated dependencies and added avct/uasurfer (#8089) * Updated dependencies and added avct/uasurfer * Added uasurfer to NOTICE.txt --- vendor/golang.org/x/text/internal/gen/code.go | 24 ++++++++-- vendor/golang.org/x/text/internal/gen/gen.go | 64 ++++++++++++++++++++++++--- 2 files changed, 79 insertions(+), 9 deletions(-) (limited to 'vendor/golang.org/x/text/internal/gen') diff --git a/vendor/golang.org/x/text/internal/gen/code.go b/vendor/golang.org/x/text/internal/gen/code.go index d7031b694..0389509f2 100644 --- a/vendor/golang.org/x/text/internal/gen/code.go +++ b/vendor/golang.org/x/text/internal/gen/code.go @@ -55,18 +55,36 @@ func (w *CodeWriter) WriteGoFile(filename, pkg string) { log.Fatalf("Could not create file %s: %v", filename, err) } defer f.Close() - if _, err = w.WriteGo(f, pkg); err != nil { + if _, err = w.WriteGo(f, pkg, ""); err != nil { + log.Fatalf("Error writing file %s: %v", filename, err) + } +} + +// WriteVersionedGoFile appends the buffer with the total size of all created +// structures and writes it as a Go file to the the given file with the given +// package name and build tags for the current Unicode version, +func (w *CodeWriter) WriteVersionedGoFile(filename, pkg string) { + tags := buildTags() + if tags != "" { + filename = insertVersion(filename, UnicodeVersion()) + } + f, err := os.Create(filename) + if err != nil { + log.Fatalf("Could not create file %s: %v", filename, err) + } + defer f.Close() + if _, err = w.WriteGo(f, pkg, tags); err != nil { log.Fatalf("Error writing file %s: %v", filename, err) } } // WriteGo appends the buffer with the total size of all created structures and // writes it as a Go file to the the given writer with the given package name. -func (w *CodeWriter) WriteGo(out io.Writer, pkg string) (n int, err error) { +func (w *CodeWriter) WriteGo(out io.Writer, pkg, tags string) (n int, err error) { sz := w.Size w.WriteComment("Total table size %d bytes (%dKiB); checksum: %X\n", sz, sz/1024, w.Hash.Sum32()) defer w.buf.Reset() - return WriteGo(out, pkg, w.buf.Bytes()) + return WriteGo(out, pkg, tags, w.buf.Bytes()) } func (w *CodeWriter) printf(f string, x ...interface{}) { diff --git a/vendor/golang.org/x/text/internal/gen/gen.go b/vendor/golang.org/x/text/internal/gen/gen.go index 2acb0355a..4c3f76068 100644 --- a/vendor/golang.org/x/text/internal/gen/gen.go +++ b/vendor/golang.org/x/text/internal/gen/gen.go @@ -31,6 +31,7 @@ import ( "os" "path" "path/filepath" + "strings" "sync" "unicode" @@ -69,8 +70,6 @@ func Init() { const header = `// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. -package %s - ` // UnicodeVersion reports the requested Unicode version. @@ -78,11 +77,33 @@ func UnicodeVersion() string { return *unicodeVersion } -// UnicodeVersion reports the requested CLDR version. +// CLDRVersion reports the requested CLDR version. func CLDRVersion() string { return *cldrVersion } +var tags = []struct{ version, buildTags string }{ + {"10.0.0", "go1.10"}, + {"", "!go1.10"}, +} + +// buildTags reports the build tags used for the current Unicode version. +func buildTags() string { + v := UnicodeVersion() + for _, x := range tags { + // We should do a numeric comparison, but including the collate package + // would create an import cycle. We approximate it by assuming that + // longer version strings are later. + if len(x.version) <= len(v) { + return x.buildTags + } + if len(x.version) == len(v) && x.version <= v { + return x.buildTags + } + } + return tags[0].buildTags +} + // IsLocal reports whether data files are available locally. func IsLocal() bool { dir, err := localReadmeFile() @@ -243,15 +264,46 @@ func WriteGoFile(filename, pkg string, b []byte) { log.Fatalf("Could not create file %s: %v", filename, err) } defer w.Close() - if _, err = WriteGo(w, pkg, b); err != nil { + if _, err = WriteGo(w, pkg, "", b); err != nil { + log.Fatalf("Error writing file %s: %v", filename, err) + } +} + +func insertVersion(filename, version string) string { + suffix := ".go" + if strings.HasSuffix(filename, "_test.go") { + suffix = "_test.go" + } + return fmt.Sprint(filename[:len(filename)-len(suffix)], version, suffix) +} + +// WriteVersionedGoFile prepends a standard file comment, adds build tags to +// version the file for the current Unicode version, and package statement to +// the given bytes, applies gofmt, and writes them to a file with the given +// name. It will call log.Fatal if there are any errors. +func WriteVersionedGoFile(filename, pkg string, b []byte) { + tags := buildTags() + if tags != "" { + filename = insertVersion(filename, UnicodeVersion()) + } + w, err := os.Create(filename) + if err != nil { + log.Fatalf("Could not create file %s: %v", filename, err) + } + defer w.Close() + if _, err = WriteGo(w, pkg, tags, b); err != nil { log.Fatalf("Error writing file %s: %v", filename, err) } } // WriteGo prepends a standard file comment and package statement to the given // bytes, applies gofmt, and writes them to w. -func WriteGo(w io.Writer, pkg string, b []byte) (n int, err error) { - src := []byte(fmt.Sprintf(header, pkg)) +func WriteGo(w io.Writer, pkg, tags string, b []byte) (n int, err error) { + src := []byte(header) + if tags != "" { + src = append(src, fmt.Sprintf("// +build %s\n\n", tags)...) + } + src = append(src, fmt.Sprintf("package %s\n\n", pkg)...) src = append(src, b...) formatted, err := format.Source(src) if err != nil { -- cgit v1.2.3-1-g7c22