Checking in vendor folder for ease of using go get.
This commit is contained in:
parent
7a1251853b
commit
cdb4b5a1d0
3554 changed files with 1270116 additions and 0 deletions
59
vendor/golang.org/x/text/unicode/runenames/bits.go
generated
vendored
Normal file
59
vendor/golang.org/x/text/unicode/runenames/bits.go
generated
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
||||
|
||||
package runenames
|
||||
|
||||
// This file contains code common to gen.go and the package code.
|
||||
|
||||
// The mapping from rune to string (i.e. offset and length in the data string)
|
||||
// is encoded as a two level table. The first level maps from contiguous rune
|
||||
// ranges [runeOffset, runeOffset+runeLength) to entries. Entries are either
|
||||
// direct (for repeated names such as "<CJK Ideograph>") or indirect (for runs
|
||||
// of unique names such as "SPACE", "EXCLAMATION MARK", "QUOTATION MARK", ...).
|
||||
//
|
||||
// Each first level table element is 64 bits. The runeOffset (21 bits) and
|
||||
// runeLength (16 bits) take the 37 high bits. The entry takes the 27 low bits,
|
||||
// with directness encoded in the least significant bit.
|
||||
//
|
||||
// A direct entry encodes a dataOffset (18 bits) and dataLength (8 bits) in the
|
||||
// data string. 18 bits is too short to encode the entire data string's length,
|
||||
// but the data string's contents are arranged so that all of the few direct
|
||||
// entries' offsets come before all of the many indirect entries' offsets.
|
||||
//
|
||||
// An indirect entry encodes a dataBase (10 bits) and a table1Offset (16 bits).
|
||||
// The table1Offset is the start of a range in the second level table. The
|
||||
// length of that range is the same as the runeLength.
|
||||
//
|
||||
// Each second level table element is 16 bits, an index into data, relative to
|
||||
// a bias equal to (dataBase << dataBaseUnit). That (bias + index) is the
|
||||
// (dataOffset + dataLength) in the data string. The dataOffset is implied by
|
||||
// the previous table element (with the same implicit bias).
|
||||
|
||||
const (
|
||||
bitsRuneOffset = 21
|
||||
bitsRuneLength = 16
|
||||
bitsDataOffset = 18
|
||||
bitsDataLength = 8
|
||||
bitsDirect = 1
|
||||
|
||||
bitsDataBase = 10
|
||||
bitsTable1Offset = 16
|
||||
|
||||
shiftRuneOffset = 0 + bitsDirect + bitsDataLength + bitsDataOffset + bitsRuneLength
|
||||
shiftRuneLength = 0 + bitsDirect + bitsDataLength + bitsDataOffset
|
||||
shiftDataOffset = 0 + bitsDirect + bitsDataLength
|
||||
shiftDataLength = 0 + bitsDirect
|
||||
shiftDirect = 0
|
||||
|
||||
shiftDataBase = 0 + bitsDirect + bitsTable1Offset
|
||||
shiftTable1Offset = 0 + bitsDirect
|
||||
|
||||
maskRuneLength = 1<<bitsRuneLength - 1
|
||||
maskDataOffset = 1<<bitsDataOffset - 1
|
||||
maskDataLength = 1<<bitsDataLength - 1
|
||||
maskDirect = 1<<bitsDirect - 1
|
||||
|
||||
maskDataBase = 1<<bitsDataBase - 1
|
||||
maskTable1Offset = 1<<bitsTable1Offset - 1
|
||||
|
||||
dataBaseUnit = 10
|
||||
)
|
118
vendor/golang.org/x/text/unicode/runenames/example_test.go
generated
vendored
Normal file
118
vendor/golang.org/x/text/unicode/runenames/example_test.go
generated
vendored
Normal file
|
@ -0,0 +1,118 @@
|
|||
// Copyright 2016 The Go 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 runenames_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"golang.org/x/text/unicode/runenames"
|
||||
)
|
||||
|
||||
func Example() {
|
||||
runes := []rune{
|
||||
-1,
|
||||
'\U00000000',
|
||||
'\U0000001f',
|
||||
'\U00000020',
|
||||
'\U00000021',
|
||||
'\U00000041',
|
||||
'\U0000007e',
|
||||
'\U0000007f',
|
||||
'\U00000080',
|
||||
'\U000000e0',
|
||||
|
||||
'\U0000037f',
|
||||
'\U00000380',
|
||||
'\U00000381',
|
||||
'\U00000382',
|
||||
'\U00000383',
|
||||
'\U00000384',
|
||||
'\U00000385',
|
||||
'\U00000386',
|
||||
'\U000007c0',
|
||||
|
||||
'\U00002603',
|
||||
'\U000033ff',
|
||||
'\U00003400',
|
||||
'\U00003401',
|
||||
'\U00003402',
|
||||
'\U00004dc0',
|
||||
|
||||
'\U00009fd5',
|
||||
'\U00009fd6',
|
||||
'\U00009fff',
|
||||
'\U0000a000',
|
||||
0xdc00, // '\U0000dc00' (Low Surrogate) is an invalid Go literal.
|
||||
'\U0000f800',
|
||||
'\U0000fffc',
|
||||
'\U0000fffd',
|
||||
'\U0000fffe',
|
||||
'\U0000ffff',
|
||||
|
||||
'\U00010000',
|
||||
'\U0001f574',
|
||||
'\U0002fa1d',
|
||||
'\U0002fa1e',
|
||||
'\U000e0100',
|
||||
'\U000e01ef',
|
||||
'\U000e01f0',
|
||||
'\U00100000',
|
||||
'\U0010fffd',
|
||||
'\U0010fffe',
|
||||
'\U0010ffff',
|
||||
}
|
||||
|
||||
for _, r := range runes {
|
||||
fmt.Printf("%08x %q\n", r, runenames.Name(r))
|
||||
}
|
||||
|
||||
// Output:
|
||||
// -0000001 ""
|
||||
// 00000000 "<control>"
|
||||
// 0000001f "<control>"
|
||||
// 00000020 "SPACE"
|
||||
// 00000021 "EXCLAMATION MARK"
|
||||
// 00000041 "LATIN CAPITAL LETTER A"
|
||||
// 0000007e "TILDE"
|
||||
// 0000007f "<control>"
|
||||
// 00000080 "<control>"
|
||||
// 000000e0 "LATIN SMALL LETTER A WITH GRAVE"
|
||||
// 0000037f "GREEK CAPITAL LETTER YOT"
|
||||
// 00000380 ""
|
||||
// 00000381 ""
|
||||
// 00000382 ""
|
||||
// 00000383 ""
|
||||
// 00000384 "GREEK TONOS"
|
||||
// 00000385 "GREEK DIALYTIKA TONOS"
|
||||
// 00000386 "GREEK CAPITAL LETTER ALPHA WITH TONOS"
|
||||
// 000007c0 "NKO DIGIT ZERO"
|
||||
// 00002603 "SNOWMAN"
|
||||
// 000033ff "SQUARE GAL"
|
||||
// 00003400 "<CJK Ideograph Extension A>"
|
||||
// 00003401 "<CJK Ideograph Extension A>"
|
||||
// 00003402 "<CJK Ideograph Extension A>"
|
||||
// 00004dc0 "HEXAGRAM FOR THE CREATIVE HEAVEN"
|
||||
// 00009fd5 "<CJK Ideograph>"
|
||||
// 00009fd6 ""
|
||||
// 00009fff ""
|
||||
// 0000a000 "YI SYLLABLE IT"
|
||||
// 0000dc00 "<Low Surrogate>"
|
||||
// 0000f800 "<Private Use>"
|
||||
// 0000fffc "OBJECT REPLACEMENT CHARACTER"
|
||||
// 0000fffd "REPLACEMENT CHARACTER"
|
||||
// 0000fffe ""
|
||||
// 0000ffff ""
|
||||
// 00010000 "LINEAR B SYLLABLE B008 A"
|
||||
// 0001f574 "MAN IN BUSINESS SUIT LEVITATING"
|
||||
// 0002fa1d "CJK COMPATIBILITY IDEOGRAPH-2FA1D"
|
||||
// 0002fa1e ""
|
||||
// 000e0100 "VARIATION SELECTOR-17"
|
||||
// 000e01ef "VARIATION SELECTOR-256"
|
||||
// 000e01f0 ""
|
||||
// 00100000 "<Plane 16 Private Use>"
|
||||
// 0010fffd "<Plane 16 Private Use>"
|
||||
// 0010fffe ""
|
||||
// 0010ffff ""
|
||||
}
|
195
vendor/golang.org/x/text/unicode/runenames/gen.go
generated
vendored
Normal file
195
vendor/golang.org/x/text/unicode/runenames/gen.go
generated
vendored
Normal file
|
@ -0,0 +1,195 @@
|
|||
// Copyright 2016 The Go 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 ignore
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
"golang.org/x/text/internal/gen"
|
||||
"golang.org/x/text/internal/ucd"
|
||||
)
|
||||
|
||||
// snippet is a slice of data; data is the concatenation of all of the names.
|
||||
type snippet struct {
|
||||
offset int
|
||||
length int
|
||||
s string
|
||||
}
|
||||
|
||||
func makeTable0EntryDirect(rOffset, rLength, dOffset, dLength int) uint64 {
|
||||
if rOffset >= 1<<bitsRuneOffset {
|
||||
log.Fatalf("makeTable0EntryDirect: rOffset %d is too large", rOffset)
|
||||
}
|
||||
if rLength >= 1<<bitsRuneLength {
|
||||
log.Fatalf("makeTable0EntryDirect: rLength %d is too large", rLength)
|
||||
}
|
||||
if dOffset >= 1<<bitsDataOffset {
|
||||
log.Fatalf("makeTable0EntryDirect: dOffset %d is too large", dOffset)
|
||||
}
|
||||
if dLength >= 1<<bitsRuneLength {
|
||||
log.Fatalf("makeTable0EntryDirect: dLength %d is too large", dLength)
|
||||
}
|
||||
return uint64(rOffset)<<shiftRuneOffset |
|
||||
uint64(rLength)<<shiftRuneLength |
|
||||
uint64(dOffset)<<shiftDataOffset |
|
||||
uint64(dLength)<<shiftDataLength |
|
||||
1 // Direct bit.
|
||||
}
|
||||
|
||||
func makeTable0EntryIndirect(rOffset, rLength, dBase, t1Offset int) uint64 {
|
||||
if rOffset >= 1<<bitsRuneOffset {
|
||||
log.Fatalf("makeTable0EntryIndirect: rOffset %d is too large", rOffset)
|
||||
}
|
||||
if rLength >= 1<<bitsRuneLength {
|
||||
log.Fatalf("makeTable0EntryIndirect: rLength %d is too large", rLength)
|
||||
}
|
||||
if dBase >= 1<<bitsDataBase {
|
||||
log.Fatalf("makeTable0EntryIndirect: dBase %d is too large", dBase)
|
||||
}
|
||||
if t1Offset >= 1<<bitsTable1Offset {
|
||||
log.Fatalf("makeTable0EntryIndirect: t1Offset %d is too large", t1Offset)
|
||||
}
|
||||
return uint64(rOffset)<<shiftRuneOffset |
|
||||
uint64(rLength)<<shiftRuneLength |
|
||||
uint64(dBase)<<shiftDataBase |
|
||||
uint64(t1Offset)<<shiftTable1Offset |
|
||||
0 // Direct bit.
|
||||
}
|
||||
|
||||
func makeTable1Entry(x int) uint16 {
|
||||
if x < 0 || 0xffff < x {
|
||||
log.Fatalf("makeTable1Entry: entry %d is out of range", x)
|
||||
}
|
||||
return uint16(x)
|
||||
}
|
||||
|
||||
var (
|
||||
data []byte
|
||||
snippets = make([]snippet, 1+unicode.MaxRune)
|
||||
)
|
||||
|
||||
func main() {
|
||||
gen.Init()
|
||||
|
||||
names, counts := parse()
|
||||
appendRepeatNames(names, counts)
|
||||
appendUniqueNames(names, counts)
|
||||
|
||||
table0, table1 := makeTables()
|
||||
|
||||
gen.Repackage("gen_bits.go", "bits.go", "runenames")
|
||||
|
||||
w := gen.NewCodeWriter()
|
||||
w.WriteVar("table0", table0)
|
||||
w.WriteVar("table1", table1)
|
||||
w.WriteConst("data", string(data))
|
||||
w.WriteGoFile("tables.go", "runenames")
|
||||
}
|
||||
|
||||
func parse() (names []string, counts map[string]int) {
|
||||
names = make([]string, 1+unicode.MaxRune)
|
||||
counts = map[string]int{}
|
||||
ucd.Parse(gen.OpenUCDFile("UnicodeData.txt"), func(p *ucd.Parser) {
|
||||
r, s := p.Rune(0), p.String(ucd.Name)
|
||||
if s == "" {
|
||||
return
|
||||
}
|
||||
if s[0] == '<' {
|
||||
const first = ", First>"
|
||||
if i := strings.Index(s, first); i >= 0 {
|
||||
s = s[:i] + ">"
|
||||
}
|
||||
}
|
||||
names[r] = s
|
||||
counts[s]++
|
||||
})
|
||||
return names, counts
|
||||
}
|
||||
|
||||
func appendRepeatNames(names []string, counts map[string]int) {
|
||||
alreadySeen := map[string]snippet{}
|
||||
for r, s := range names {
|
||||
if s == "" || counts[s] == 1 {
|
||||
continue
|
||||
}
|
||||
if s[0] != '<' {
|
||||
log.Fatalf("Repeated name %q does not start with a '<'", s)
|
||||
}
|
||||
|
||||
if z, ok := alreadySeen[s]; ok {
|
||||
snippets[r] = z
|
||||
continue
|
||||
}
|
||||
|
||||
z := snippet{
|
||||
offset: len(data),
|
||||
length: len(s),
|
||||
s: s,
|
||||
}
|
||||
data = append(data, s...)
|
||||
snippets[r] = z
|
||||
alreadySeen[s] = z
|
||||
}
|
||||
}
|
||||
|
||||
func appendUniqueNames(names []string, counts map[string]int) {
|
||||
for r, s := range names {
|
||||
if s == "" || counts[s] != 1 {
|
||||
continue
|
||||
}
|
||||
if s[0] == '<' {
|
||||
log.Fatalf("Unique name %q starts with a '<'", s)
|
||||
}
|
||||
|
||||
z := snippet{
|
||||
offset: len(data),
|
||||
length: len(s),
|
||||
s: s,
|
||||
}
|
||||
data = append(data, s...)
|
||||
snippets[r] = z
|
||||
}
|
||||
}
|
||||
|
||||
func makeTables() (table0 []uint64, table1 []uint16) {
|
||||
for i := 0; i < len(snippets); {
|
||||
zi := snippets[i]
|
||||
if zi == (snippet{}) {
|
||||
i++
|
||||
continue
|
||||
}
|
||||
|
||||
// Look for repeat names. If we have one, we only need a table0 entry.
|
||||
j := i + 1
|
||||
for ; j < len(snippets) && zi == snippets[j]; j++ {
|
||||
}
|
||||
if j > i+1 {
|
||||
table0 = append(table0, makeTable0EntryDirect(i, j-i, zi.offset, zi.length))
|
||||
i = j
|
||||
continue
|
||||
}
|
||||
|
||||
// Otherwise, we have a run of unique names. We need one table0 entry
|
||||
// and two or more table1 entries.
|
||||
base := zi.offset &^ (1<<dataBaseUnit - 1)
|
||||
t1Offset := len(table1) + 1
|
||||
table1 = append(table1, makeTable1Entry(zi.offset-base))
|
||||
table1 = append(table1, makeTable1Entry(zi.offset+zi.length-base))
|
||||
for ; j < len(snippets) && snippets[j] != (snippet{}); j++ {
|
||||
zj := snippets[j]
|
||||
if data[zj.offset] == '<' {
|
||||
break
|
||||
}
|
||||
table1 = append(table1, makeTable1Entry(zj.offset+zj.length-base))
|
||||
}
|
||||
table0 = append(table0, makeTable0EntryIndirect(i, j-i, base>>dataBaseUnit, t1Offset))
|
||||
i = j
|
||||
}
|
||||
return table0, table1
|
||||
}
|
63
vendor/golang.org/x/text/unicode/runenames/gen_bits.go
generated
vendored
Normal file
63
vendor/golang.org/x/text/unicode/runenames/gen_bits.go
generated
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
// Copyright 2016 The Go 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 ignore
|
||||
|
||||
package main
|
||||
|
||||
// This file contains code common to gen.go and the package code.
|
||||
|
||||
// The mapping from rune to string (i.e. offset and length in the data string)
|
||||
// is encoded as a two level table. The first level maps from contiguous rune
|
||||
// ranges [runeOffset, runeOffset+runeLength) to entries. Entries are either
|
||||
// direct (for repeated names such as "<CJK Ideograph>") or indirect (for runs
|
||||
// of unique names such as "SPACE", "EXCLAMATION MARK", "QUOTATION MARK", ...).
|
||||
//
|
||||
// Each first level table element is 64 bits. The runeOffset (21 bits) and
|
||||
// runeLength (16 bits) take the 37 high bits. The entry takes the 27 low bits,
|
||||
// with directness encoded in the least significant bit.
|
||||
//
|
||||
// A direct entry encodes a dataOffset (18 bits) and dataLength (8 bits) in the
|
||||
// data string. 18 bits is too short to encode the entire data string's length,
|
||||
// but the data string's contents are arranged so that all of the few direct
|
||||
// entries' offsets come before all of the many indirect entries' offsets.
|
||||
//
|
||||
// An indirect entry encodes a dataBase (10 bits) and a table1Offset (16 bits).
|
||||
// The table1Offset is the start of a range in the second level table. The
|
||||
// length of that range is the same as the runeLength.
|
||||
//
|
||||
// Each second level table element is 16 bits, an index into data, relative to
|
||||
// a bias equal to (dataBase << dataBaseUnit). That (bias + index) is the
|
||||
// (dataOffset + dataLength) in the data string. The dataOffset is implied by
|
||||
// the previous table element (with the same implicit bias).
|
||||
|
||||
const (
|
||||
bitsRuneOffset = 21
|
||||
bitsRuneLength = 16
|
||||
bitsDataOffset = 18
|
||||
bitsDataLength = 8
|
||||
bitsDirect = 1
|
||||
|
||||
bitsDataBase = 10
|
||||
bitsTable1Offset = 16
|
||||
|
||||
shiftRuneOffset = 0 + bitsDirect + bitsDataLength + bitsDataOffset + bitsRuneLength
|
||||
shiftRuneLength = 0 + bitsDirect + bitsDataLength + bitsDataOffset
|
||||
shiftDataOffset = 0 + bitsDirect + bitsDataLength
|
||||
shiftDataLength = 0 + bitsDirect
|
||||
shiftDirect = 0
|
||||
|
||||
shiftDataBase = 0 + bitsDirect + bitsTable1Offset
|
||||
shiftTable1Offset = 0 + bitsDirect
|
||||
|
||||
maskRuneLength = 1<<bitsRuneLength - 1
|
||||
maskDataOffset = 1<<bitsDataOffset - 1
|
||||
maskDataLength = 1<<bitsDataLength - 1
|
||||
maskDirect = 1<<bitsDirect - 1
|
||||
|
||||
maskDataBase = 1<<bitsDataBase - 1
|
||||
maskTable1Offset = 1<<bitsTable1Offset - 1
|
||||
|
||||
dataBaseUnit = 10
|
||||
)
|
48
vendor/golang.org/x/text/unicode/runenames/runenames.go
generated
vendored
Normal file
48
vendor/golang.org/x/text/unicode/runenames/runenames.go
generated
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:generate go run gen.go gen_bits.go
|
||||
|
||||
// Package runenames provides rune names from the Unicode Character Database.
|
||||
// For example, the name for '\u0100' is "LATIN CAPITAL LETTER A WITH MACRON".
|
||||
//
|
||||
// See http://www.unicode.org/Public/UCD/latest/ucd/UnicodeData.txt
|
||||
package runenames
|
||||
|
||||
import (
|
||||
"sort"
|
||||
)
|
||||
|
||||
// Name returns the name for r.
|
||||
func Name(r rune) string {
|
||||
i := sort.Search(len(table0), func(j int) bool {
|
||||
e := table0[j]
|
||||
rOffset := rune(e >> shiftRuneOffset)
|
||||
return r < rOffset
|
||||
})
|
||||
if i == 0 {
|
||||
return ""
|
||||
}
|
||||
|
||||
e := table0[i-1]
|
||||
rOffset := rune(e >> shiftRuneOffset)
|
||||
rLength := rune(e>>shiftRuneLength) & maskRuneLength
|
||||
if r >= rOffset+rLength {
|
||||
return ""
|
||||
}
|
||||
|
||||
if (e>>shiftDirect)&maskDirect != 0 {
|
||||
o := int(e>>shiftDataOffset) & maskDataOffset
|
||||
n := int(e>>shiftDataLength) & maskDataLength
|
||||
return data[o : o+n]
|
||||
}
|
||||
|
||||
base := uint32(e>>shiftDataBase) & maskDataBase
|
||||
base <<= dataBaseUnit
|
||||
j := rune(e>>shiftTable1Offset) & maskTable1Offset
|
||||
j += r - rOffset
|
||||
d0 := base + uint32(table1[j-1]) // dataOffset
|
||||
d1 := base + uint32(table1[j-0]) // dataOffset + dataLength
|
||||
return data[d0:d1]
|
||||
}
|
46
vendor/golang.org/x/text/unicode/runenames/runenames_test.go
generated
vendored
Normal file
46
vendor/golang.org/x/text/unicode/runenames/runenames_test.go
generated
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
// Copyright 2016 The Go 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 runenames
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
"unicode"
|
||||
|
||||
"golang.org/x/text/internal/gen"
|
||||
"golang.org/x/text/internal/testtext"
|
||||
"golang.org/x/text/internal/ucd"
|
||||
)
|
||||
|
||||
func TestName(t *testing.T) {
|
||||
testtext.SkipIfNotLong(t)
|
||||
|
||||
wants := make([]string, 1+unicode.MaxRune)
|
||||
ucd.Parse(gen.OpenUCDFile("UnicodeData.txt"), func(p *ucd.Parser) {
|
||||
r, s := p.Rune(0), p.String(ucd.Name)
|
||||
if s == "" {
|
||||
return
|
||||
}
|
||||
if s[0] == '<' {
|
||||
const first = ", First>"
|
||||
if i := strings.Index(s, first); i >= 0 {
|
||||
s = s[:i] + ">"
|
||||
}
|
||||
}
|
||||
wants[r] = s
|
||||
})
|
||||
|
||||
nErrors := 0
|
||||
for r, want := range wants {
|
||||
got := Name(rune(r))
|
||||
if got != want {
|
||||
t.Errorf("r=%#08x: got %q, want %q", r, got, want)
|
||||
nErrors++
|
||||
if nErrors == 100 {
|
||||
t.Fatal("too many errors")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
15514
vendor/golang.org/x/text/unicode/runenames/tables.go
generated
vendored
Normal file
15514
vendor/golang.org/x/text/unicode/runenames/tables.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue