diff options
Diffstat (limited to 'vendor/golang.org/x/text/gen.go')
-rw-r--r-- | vendor/golang.org/x/text/gen.go | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/vendor/golang.org/x/text/gen.go b/vendor/golang.org/x/text/gen.go index 79af97e70..4257a1839 100644 --- a/vendor/golang.org/x/text/gen.go +++ b/vendor/golang.org/x/text/gen.go @@ -25,7 +25,9 @@ import ( "sync" "unicode" + "golang.org/x/text/collate" "golang.org/x/text/internal/gen" + "golang.org/x/text/language" ) var ( @@ -72,14 +74,24 @@ func main() { fmt.Printf("Requested Unicode version %s; core unicode version is %s.\n", gen.UnicodeVersion(), unicode.Version) - // TODO: use collate to compare. Simple comparison will work, though, - // until Unicode reaches version 10. To avoid circular dependencies, we - // could use the NumericWeighter without using package collate using a - // trivial Weighter implementation. - if gen.UnicodeVersion() < unicode.Version && !*force { + c := collate.New(language.Und, collate.Numeric) + if c.CompareString(gen.UnicodeVersion(), unicode.Version) < 0 && !*force { os.Exit(2) } updateCore = true + goroot := os.Getenv("GOROOT") + appendToFile( + filepath.Join(goroot, "api", "except.txt"), + fmt.Sprintf("pkg unicode, const Version = %q\n", unicode.Version), + ) + const lines = `pkg unicode, const Version = %q +// TODO: add a new line of the following form for each new script and property. +pkg unicode, var <new script or property> *RangeTable +` + appendToFile( + filepath.Join(goroot, "api", "next.txt"), + fmt.Sprintf(lines, gen.UnicodeVersion()), + ) } var unicode = &dependency{} @@ -132,6 +144,20 @@ func main() { vprintf("SUCCESS\n") } +func appendToFile(file, text string) { + fmt.Println("Augmenting", file) + w, err := os.OpenFile(file, os.O_APPEND|os.O_WRONLY, 0600) + if err != nil { + fmt.Println("Failed to open file:", err) + os.Exit(1) + } + defer w.Close() + if _, err := w.WriteString(text); err != nil { + fmt.Println("Failed to write to file:", err) + os.Exit(1) + } +} + var ( all sync.WaitGroup hasErrors bool @@ -244,7 +270,7 @@ func copyPackage(dirSrc, dirDst, search, replace string) { base := filepath.Base(file) if err != nil || info.IsDir() || !strings.HasSuffix(base, ".go") || - strings.HasSuffix(base, "_test.go") && !strings.HasPrefix(base, "example") || + strings.HasSuffix(base, "_test.go") || // Don't process subdirectories. filepath.Dir(file) != dirSrc { return nil |