aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/net/idna/trieval.go
diff options
context:
space:
mode:
authorLibravatar Rutger Broekhoff2023-12-29 21:31:53 +0100
committerLibravatar Rutger Broekhoff2023-12-29 21:31:53 +0100
commit404aeae4545d2426c089a5f8d5e82dae56f5212b (patch)
tree2d84e00af272b39fc04f3795ae06bc48970e57b5 /vendor/golang.org/x/net/idna/trieval.go
parent209d8b0187ed025dec9ac149ebcced3462877bff (diff)
downloadgitolfs3-404aeae4545d2426c089a5f8d5e82dae56f5212b.tar.gz
gitolfs3-404aeae4545d2426c089a5f8d5e82dae56f5212b.zip
Make Nix builds work
Diffstat (limited to 'vendor/golang.org/x/net/idna/trieval.go')
-rw-r--r--vendor/golang.org/x/net/idna/trieval.go119
1 files changed, 119 insertions, 0 deletions
diff --git a/vendor/golang.org/x/net/idna/trieval.go b/vendor/golang.org/x/net/idna/trieval.go
new file mode 100644
index 0000000..9c070a4
--- /dev/null
+++ b/vendor/golang.org/x/net/idna/trieval.go
@@ -0,0 +1,119 @@
1// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
2
3package idna
4
5// This file contains definitions for interpreting the trie value of the idna
6// trie generated by "go run gen*.go". It is shared by both the generator
7// program and the resultant package. Sharing is achieved by the generator
8// copying gen_trieval.go to trieval.go and changing what's above this comment.
9
10// info holds information from the IDNA mapping table for a single rune. It is
11// the value returned by a trie lookup. In most cases, all information fits in
12// a 16-bit value. For mappings, this value may contain an index into a slice
13// with the mapped string. Such mappings can consist of the actual mapped value
14// or an XOR pattern to be applied to the bytes of the UTF8 encoding of the
15// input rune. This technique is used by the cases packages and reduces the
16// table size significantly.
17//
18// The per-rune values have the following format:
19//
20// if mapped {
21// if inlinedXOR {
22// 15..13 inline XOR marker
23// 12..11 unused
24// 10..3 inline XOR mask
25// } else {
26// 15..3 index into xor or mapping table
27// }
28// } else {
29// 15..14 unused
30// 13 mayNeedNorm
31// 12..11 attributes
32// 10..8 joining type
33// 7..3 category type
34// }
35// 2 use xor pattern
36// 1..0 mapped category
37//
38// See the definitions below for a more detailed description of the various
39// bits.
40type info uint16
41
42const (
43 catSmallMask = 0x3
44 catBigMask = 0xF8
45 indexShift = 3
46 xorBit = 0x4 // interpret the index as an xor pattern
47 inlineXOR = 0xE000 // These bits are set if the XOR pattern is inlined.
48
49 joinShift = 8
50 joinMask = 0x07
51
52 // Attributes
53 attributesMask = 0x1800
54 viramaModifier = 0x1800
55 modifier = 0x1000
56 rtl = 0x0800
57
58 mayNeedNorm = 0x2000
59)
60
61// A category corresponds to a category defined in the IDNA mapping table.
62type category uint16
63
64const (
65 unknown category = 0 // not currently defined in unicode.
66 mapped category = 1
67 disallowedSTD3Mapped category = 2
68 deviation category = 3
69)
70
71const (
72 valid category = 0x08
73 validNV8 category = 0x18
74 validXV8 category = 0x28
75 disallowed category = 0x40
76 disallowedSTD3Valid category = 0x80
77 ignored category = 0xC0
78)
79
80// join types and additional rune information
81const (
82 joiningL = (iota + 1)
83 joiningD
84 joiningT
85 joiningR
86
87 //the following types are derived during processing
88 joinZWJ
89 joinZWNJ
90 joinVirama
91 numJoinTypes
92)
93
94func (c info) isMapped() bool {
95 return c&0x3 != 0
96}
97
98func (c info) category() category {
99 small := c & catSmallMask
100 if small != 0 {
101 return category(small)
102 }
103 return category(c & catBigMask)
104}
105
106func (c info) joinType() info {
107 if c.isMapped() {
108 return 0
109 }
110 return (c >> joinShift) & joinMask
111}
112
113func (c info) isModifier() bool {
114 return c&(modifier|catSmallMask) == modifier
115}
116
117func (c info) isViramaModifier() bool {
118 return c&(attributesMask|catSmallMask) == viramaModifier
119}