| 1 | // Copyright 2014 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | package casesscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/ |
| 6 | |
| 7 | import "golang.org/x/text/transformscip-go gomod golang.org/x/text . `golang.org/x/text/transform`/" |
| 8 | |
| 9 | // A context is used for iterating over source bytes, fetching case info and |
| 10 | // writing to a destination buffer. |
| 11 | // |
| 12 | // Casing operations may need more than one rune of context to decide how a rune |
| 13 | // should be cased. Casing implementations should call checkpoint on context |
| 14 | // whenever it is known to be safe to return the runes processed so far. |
| 15 | // |
| 16 | // It is recommended for implementations to not allow for more than 30 case |
| 17 | // ignorables as lookahead (analogous to the limit in norm) and to use state if |
| 18 | // unbounded lookahead is needed for cased runes. |
| 19 | type contextscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context# struct { |
| 20 | dstscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#dst., srcscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#src. []byte |
| 21 | atEOFscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#atEOF. bool |
| 22 | |
| 23 | pDstscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#pDst. int // pDst points past the last written rune in dst. |
| 24 | pSrcscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#pSrc. int // pSrc points to the start of the currently scanned rune. |
| 25 | |
| 26 | // checkpoints safe to return in Transform, where nDst <= pDst and nSrc <= pSrc. |
| 27 | nDstscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#nDst., nSrcscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#nSrc. int |
| 28 | errscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#err. error |
| 29 | |
| 30 | szscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#sz. int // size of current rune |
| 31 | infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info. infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/info# // case information of currently scanned rune |
| 32 | |
| 33 | // State preserved across calls to Transform. |
| 34 | isMidWordscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#isMidWord. bool // false if next cased letter needs to be title-cased. |
| 35 | } |
| 36 | |
| 37 | func (c *contextscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#) Resetscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#Reset().() { |
| 38 | c.isMidWordscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#isMidWord. = false |
| 39 | } |
| 40 | |
| 41 | // ret returns the return values for the Transform method. It checks whether |
| 42 | // there were insufficient bytes in src to complete and introduces an error |
| 43 | // accordingly, if necessary. |
| 44 | func (c *contextscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#) retscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#ret().() (nDst, nSrc int, err error) { |
| 45 | if c.errscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#err. != nil || c.nSrcscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#nSrc. == len(c.srcscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#src.) { |
| 46 | return c.nDstscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#nDst., c.nSrcscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#nSrc., c.errscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#err. |
| 47 | } |
| 48 | // This point is only reached by mappers if there was no short destination |
| 49 | // buffer. This means that the source buffer was exhausted and that c.sz was |
| 50 | // set to 0 by next. |
| 51 | if c.atEOFscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#atEOF. && c.pSrcscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#pSrc. == len(c.srcscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#src.) { |
| 52 | return c.pDstscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#pDst., c.pSrcscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#pSrc., nil |
| 53 | } |
| 54 | return c.nDstscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#nDst., c.nSrcscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#nSrc., transformscip-go gomod golang.org/x/text . `golang.org/x/text/transform`/.ErrShortSrcscip-go gomod golang.org/x/text . `golang.org/x/text/transform`/ErrShortSrc. |
| 55 | } |
| 56 | |
| 57 | // retSpan returns the return values for the Span method. It checks whether |
| 58 | // there were insufficient bytes in src to complete and introduces an error |
| 59 | // accordingly, if necessary. |
| 60 | func (c *contextscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#) retSpanscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#retSpan().() (n int, err error) { |
| 61 | _, nSrc, err := c.retscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#ret().() |
| 62 | return nSrc, err |
| 63 | } |
| 64 | |
| 65 | // checkpoint sets the return value buffer points for Transform to the current |
| 66 | // positions. |
| 67 | func (c *contextscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#) checkpointscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#checkpoint().() { |
| 68 | if c.errscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#err. == nil { |
| 69 | c.nDstscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#nDst., c.nSrcscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#nSrc. = c.pDstscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#pDst., c.pSrcscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#pSrc.+c.szscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#sz. |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | // unreadRune causes the last rune read by next to be reread on the next |
| 74 | // invocation of next. Only one unreadRune may be called after a call to next. |
| 75 | func (c *contextscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#) unreadRunescip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#unreadRune().() { |
| 76 | c.szscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#sz. = 0 |
| 77 | } |
| 78 | |
| 79 | func (c *contextscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#) nextscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#next().() bool { |
| 80 | c.pSrcscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#pSrc. += c.szscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#sz. |
| 81 | if c.pSrcscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#pSrc. == len(c.srcscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#src.) || c.errscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#err. != nil { |
| 82 | c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info., c.szscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#sz. = 0, 0 |
| 83 | return false |
| 84 | } |
| 85 | v, sz := triescip-go gomod golang.org/x/text . `golang.org/x/text/cases`/trie..lookupscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/caseTrie#lookup().(c.srcscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#src.[c.pSrcscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#pSrc.:]) |
| 86 | c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info., c.szscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#sz. = infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/info#(v), sz |
| 87 | if c.szscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#sz. == 0 { |
| 88 | if c.atEOFscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#atEOF. { |
| 89 | // A zero size means we have an incomplete rune. If we are atEOF, |
| 90 | // this means it is an illegal rune, which we will consume one |
| 91 | // byte at a time. |
| 92 | c.szscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#sz. = 1 |
| 93 | } else { |
| 94 | c.errscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#err. = transformscip-go gomod golang.org/x/text . `golang.org/x/text/transform`/.ErrShortSrcscip-go gomod golang.org/x/text . `golang.org/x/text/transform`/ErrShortSrc. |
| 95 | return false |
| 96 | } |
| 97 | } |
| 98 | return true |
| 99 | } |
| 100 | |
| 101 | // writeBytes adds bytes to dst. |
| 102 | func (c *contextscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#) writeBytesscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#writeBytes().(b []byte) bool { |
| 103 | if len(c.dstscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#dst.)-c.pDstscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#pDst. < len(b) { |
| 104 | c.errscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#err. = transformscip-go gomod golang.org/x/text . `golang.org/x/text/transform`/.ErrShortDstscip-go gomod golang.org/x/text . `golang.org/x/text/transform`/ErrShortDst. |
| 105 | return false |
| 106 | } |
| 107 | // This loop is faster than using copy. |
| 108 | for _, ch := range b { |
| 109 | c.dstscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#dst.[c.pDstscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#pDst.] = ch |
| 110 | c.pDstscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#pDst.++ |
| 111 | } |
| 112 | return true |
| 113 | } |
| 114 | |
| 115 | // writeString writes the given string to dst. |
| 116 | func (c *contextscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#) writeStringscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#writeString().(s string) bool { |
| 117 | if len(c.dstscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#dst.)-c.pDstscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#pDst. < len(s) { |
| 118 | c.errscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#err. = transformscip-go gomod golang.org/x/text . `golang.org/x/text/transform`/.ErrShortDstscip-go gomod golang.org/x/text . `golang.org/x/text/transform`/ErrShortDst. |
| 119 | return false |
| 120 | } |
| 121 | // This loop is faster than using copy. |
| 122 | for i := 0; i < len(s); i++ { |
| 123 | c.dstscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#dst.[c.pDstscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#pDst.] = s[i] |
| 124 | c.pDstscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#pDst.++ |
| 125 | } |
| 126 | return true |
| 127 | } |
| 128 | |
| 129 | // copy writes the current rune to dst. |
| 130 | func (c *contextscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#) copyscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#copy().() bool { |
| 131 | return c.writeBytesscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#writeBytes().(c.srcscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#src.[c.pSrcscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#pSrc. : c.pSrcscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#pSrc.+c.szscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#sz.]) |
| 132 | } |
| 133 | |
| 134 | // copyXOR copies the current rune to dst and modifies it by applying the XOR |
| 135 | // pattern of the case info. It is the responsibility of the caller to ensure |
| 136 | // that this is a rune with a XOR pattern defined. |
| 137 | func (c *contextscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#) copyXORscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#copyXOR().() bool { |
| 138 | if !c.copyscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#copy().() { |
| 139 | return false |
| 140 | } |
| 141 | if c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info.&xorIndexBitscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/xorIndexBit. == 0 { |
| 142 | // Fast path for 6-bit XOR pattern, which covers most cases. |
| 143 | c.dstscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#dst.[c.pDstscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#pDst.-1] ^= byte(c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info. >> xorShiftscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/xorShift.) |
| 144 | } else { |
| 145 | // Interpret XOR bits as an index. |
| 146 | // TODO: test performance for unrolling this loop. Verify that we have |
| 147 | // at least two bytes and at most three. |
| 148 | idx := c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info. >> xorShiftscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/xorShift. |
| 149 | for p := c.pDstscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#pDst. - 1; ; p-- { |
| 150 | c.dstscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#dst.[p] ^= xorDatascip-go gomod golang.org/x/text . `golang.org/x/text/cases`/xorData.[idx] |
| 151 | idx-- |
| 152 | if xorDatascip-go gomod golang.org/x/text . `golang.org/x/text/cases`/xorData.[idx] == 0 { |
| 153 | break |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | return true |
| 158 | } |
| 159 | |
| 160 | // hasPrefix returns true if src[pSrc:] starts with the given string. |
| 161 | func (c *contextscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#) hasPrefixscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#hasPrefix().(s string) bool { |
| 162 | b := c.srcscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#src.[c.pSrcscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#pSrc.:] |
| 163 | if len(b) < len(s) { |
| 164 | return false |
| 165 | } |
| 166 | for i, c := range b[:len(s)] { |
| 167 | if c != s[i] { |
| 168 | return false |
| 169 | } |
| 170 | } |
| 171 | return true |
| 172 | } |
| 173 | |
| 174 | // caseType returns an info with only the case bits, normalized to either |
| 175 | // cLower, cUpper, cTitle or cUncased. |
| 176 | func (c *contextscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#) caseTypescip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#caseType().() infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/info# { |
| 177 | cm := c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info. & 0x7 |
| 178 | if cm < 4 { |
| 179 | return cm |
| 180 | } |
| 181 | if cm >= cXORCasescip-go gomod golang.org/x/text . `golang.org/x/text/cases`/cXORCase. { |
| 182 | // xor the last bit of the rune with the case type bits. |
| 183 | b := c.srcscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#src.[c.pSrcscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#pSrc.+c.szscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#sz.-1] |
| 184 | return infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/info#(b&1) ^ cm&0x3 |
| 185 | } |
| 186 | if cm == cIgnorableCasedscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/cIgnorableCased. { |
| 187 | return cLowerscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/cLower. |
| 188 | } |
| 189 | return cUncasedscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/cUncased. |
| 190 | } |
| 191 | |
| 192 | // lower writes the lowercase version of the current rune to dst. |
| 193 | func lowerscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/lower().(c *contextscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#) bool { |
| 194 | ct := c.caseTypescip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#caseType().() |
| 195 | if c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info.&hasMappingMaskscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/hasMappingMask. == 0 || ct == cLowerscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/cLower. { |
| 196 | return c.copyscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#copy().() |
| 197 | } |
| 198 | if c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info.&exceptionBitscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/exceptionBit. == 0 { |
| 199 | return c.copyXORscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#copyXOR().() |
| 200 | } |
| 201 | e := exceptionsscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/exceptions.[c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info.>>exceptionShiftscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/exceptionShift.:] |
| 202 | offset := 2 + e[0]&lengthMaskscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/lengthMask. // size of header + fold string |
| 203 | if nLower := (e[1] >> lengthBitsscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/lengthBits.) & lengthMaskscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/lengthMask.; nLower != noChangescip-go gomod golang.org/x/text . `golang.org/x/text/cases`/noChange. { |
| 204 | return c.writeStringscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#writeString().(e[offset : offset+nLower]) |
| 205 | } |
| 206 | return c.copyscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#copy().() |
| 207 | } |
| 208 | |
| 209 | func isLowerscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/isLower().(c *contextscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#) bool { |
| 210 | ct := c.caseTypescip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#caseType().() |
| 211 | if c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info.&hasMappingMaskscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/hasMappingMask. == 0 || ct == cLowerscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/cLower. { |
| 212 | return true |
| 213 | } |
| 214 | if c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info.&exceptionBitscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/exceptionBit. == 0 { |
| 215 | c.errscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#err. = transformscip-go gomod golang.org/x/text . `golang.org/x/text/transform`/.ErrEndOfSpanscip-go gomod golang.org/x/text . `golang.org/x/text/transform`/ErrEndOfSpan. |
| 216 | return false |
| 217 | } |
| 218 | e := exceptionsscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/exceptions.[c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info.>>exceptionShiftscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/exceptionShift.:] |
| 219 | if nLower := (e[1] >> lengthBitsscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/lengthBits.) & lengthMaskscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/lengthMask.; nLower != noChangescip-go gomod golang.org/x/text . `golang.org/x/text/cases`/noChange. { |
| 220 | c.errscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#err. = transformscip-go gomod golang.org/x/text . `golang.org/x/text/transform`/.ErrEndOfSpanscip-go gomod golang.org/x/text . `golang.org/x/text/transform`/ErrEndOfSpan. |
| 221 | return false |
| 222 | } |
| 223 | return true |
| 224 | } |
| 225 | |
| 226 | // upper writes the uppercase version of the current rune to dst. |
| 227 | func upperscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/upper().(c *contextscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#) bool { |
| 228 | ct := c.caseTypescip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#caseType().() |
| 229 | if c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info.&hasMappingMaskscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/hasMappingMask. == 0 || ct == cUpperscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/cUpper. { |
| 230 | return c.copyscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#copy().() |
| 231 | } |
| 232 | if c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info.&exceptionBitscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/exceptionBit. == 0 { |
| 233 | return c.copyXORscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#copyXOR().() |
| 234 | } |
| 235 | e := exceptionsscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/exceptions.[c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info.>>exceptionShiftscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/exceptionShift.:] |
| 236 | offset := 2 + e[0]&lengthMaskscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/lengthMask. // size of header + fold string |
| 237 | // Get length of first special case mapping. |
| 238 | n := (e[1] >> lengthBitsscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/lengthBits.) & lengthMaskscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/lengthMask. |
| 239 | if ct == cTitlescip-go gomod golang.org/x/text . `golang.org/x/text/cases`/cTitle. { |
| 240 | // The first special case mapping is for lower. Set n to the second. |
| 241 | if n == noChangescip-go gomod golang.org/x/text . `golang.org/x/text/cases`/noChange. { |
| 242 | n = 0 |
| 243 | } |
| 244 | n, e = e[1]&lengthMaskscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/lengthMask., e[n:] |
| 245 | } |
| 246 | if n != noChangescip-go gomod golang.org/x/text . `golang.org/x/text/cases`/noChange. { |
| 247 | return c.writeStringscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#writeString().(e[offset : offset+n]) |
| 248 | } |
| 249 | return c.copyscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#copy().() |
| 250 | } |
| 251 | |
| 252 | // isUpper writes the isUppercase version of the current rune to dst. |
| 253 | func isUpperscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/isUpper().(c *contextscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#) bool { |
| 254 | ct := c.caseTypescip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#caseType().() |
| 255 | if c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info.&hasMappingMaskscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/hasMappingMask. == 0 || ct == cUpperscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/cUpper. { |
| 256 | return true |
| 257 | } |
| 258 | if c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info.&exceptionBitscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/exceptionBit. == 0 { |
| 259 | c.errscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#err. = transformscip-go gomod golang.org/x/text . `golang.org/x/text/transform`/.ErrEndOfSpanscip-go gomod golang.org/x/text . `golang.org/x/text/transform`/ErrEndOfSpan. |
| 260 | return false |
| 261 | } |
| 262 | e := exceptionsscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/exceptions.[c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info.>>exceptionShiftscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/exceptionShift.:] |
| 263 | // Get length of first special case mapping. |
| 264 | n := (e[1] >> lengthBitsscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/lengthBits.) & lengthMaskscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/lengthMask. |
| 265 | if ct == cTitlescip-go gomod golang.org/x/text . `golang.org/x/text/cases`/cTitle. { |
| 266 | n = e[1] & lengthMaskscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/lengthMask. |
| 267 | } |
| 268 | if n != noChangescip-go gomod golang.org/x/text . `golang.org/x/text/cases`/noChange. { |
| 269 | c.errscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#err. = transformscip-go gomod golang.org/x/text . `golang.org/x/text/transform`/.ErrEndOfSpanscip-go gomod golang.org/x/text . `golang.org/x/text/transform`/ErrEndOfSpan. |
| 270 | return false |
| 271 | } |
| 272 | return true |
| 273 | } |
| 274 | |
| 275 | // title writes the title case version of the current rune to dst. |
| 276 | func titlescip-go gomod golang.org/x/text . `golang.org/x/text/cases`/title().(c *contextscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#) bool { |
| 277 | ct := c.caseTypescip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#caseType().() |
| 278 | if c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info.&hasMappingMaskscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/hasMappingMask. == 0 || ct == cTitlescip-go gomod golang.org/x/text . `golang.org/x/text/cases`/cTitle. { |
| 279 | return c.copyscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#copy().() |
| 280 | } |
| 281 | if c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info.&exceptionBitscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/exceptionBit. == 0 { |
| 282 | if ct == cLowerscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/cLower. { |
| 283 | return c.copyXORscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#copyXOR().() |
| 284 | } |
| 285 | return c.copyscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#copy().() |
| 286 | } |
| 287 | // Get the exception data. |
| 288 | e := exceptionsscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/exceptions.[c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info.>>exceptionShiftscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/exceptionShift.:] |
| 289 | offset := 2 + e[0]&lengthMaskscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/lengthMask. // size of header + fold string |
| 290 | |
| 291 | nFirst := (e[1] >> lengthBitsscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/lengthBits.) & lengthMaskscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/lengthMask. |
| 292 | if nTitle := e[1] & lengthMaskscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/lengthMask.; nTitle != noChangescip-go gomod golang.org/x/text . `golang.org/x/text/cases`/noChange. { |
| 293 | if nFirst != noChangescip-go gomod golang.org/x/text . `golang.org/x/text/cases`/noChange. { |
| 294 | e = e[nFirst:] |
| 295 | } |
| 296 | return c.writeStringscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#writeString().(e[offset : offset+nTitle]) |
| 297 | } |
| 298 | if ct == cLowerscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/cLower. && nFirst != noChangescip-go gomod golang.org/x/text . `golang.org/x/text/cases`/noChange. { |
| 299 | // Use the uppercase version instead. |
| 300 | return c.writeStringscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#writeString().(e[offset : offset+nFirst]) |
| 301 | } |
| 302 | // Already in correct case. |
| 303 | return c.copyscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#copy().() |
| 304 | } |
| 305 | |
| 306 | // isTitle reports whether the current rune is in title case. |
| 307 | func isTitlescip-go gomod golang.org/x/text . `golang.org/x/text/cases`/isTitle().(c *contextscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#) bool { |
| 308 | ct := c.caseTypescip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#caseType().() |
| 309 | if c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info.&hasMappingMaskscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/hasMappingMask. == 0 || ct == cTitlescip-go gomod golang.org/x/text . `golang.org/x/text/cases`/cTitle. { |
| 310 | return true |
| 311 | } |
| 312 | if c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info.&exceptionBitscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/exceptionBit. == 0 { |
| 313 | if ct == cLowerscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/cLower. { |
| 314 | c.errscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#err. = transformscip-go gomod golang.org/x/text . `golang.org/x/text/transform`/.ErrEndOfSpanscip-go gomod golang.org/x/text . `golang.org/x/text/transform`/ErrEndOfSpan. |
| 315 | return false |
| 316 | } |
| 317 | return true |
| 318 | } |
| 319 | // Get the exception data. |
| 320 | e := exceptionsscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/exceptions.[c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info.>>exceptionShiftscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/exceptionShift.:] |
| 321 | if nTitle := e[1] & lengthMaskscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/lengthMask.; nTitle != noChangescip-go gomod golang.org/x/text . `golang.org/x/text/cases`/noChange. { |
| 322 | c.errscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#err. = transformscip-go gomod golang.org/x/text . `golang.org/x/text/transform`/.ErrEndOfSpanscip-go gomod golang.org/x/text . `golang.org/x/text/transform`/ErrEndOfSpan. |
| 323 | return false |
| 324 | } |
| 325 | nFirst := (e[1] >> lengthBitsscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/lengthBits.) & lengthMaskscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/lengthMask. |
| 326 | if ct == cLowerscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/cLower. && nFirst != noChangescip-go gomod golang.org/x/text . `golang.org/x/text/cases`/noChange. { |
| 327 | c.errscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#err. = transformscip-go gomod golang.org/x/text . `golang.org/x/text/transform`/.ErrEndOfSpanscip-go gomod golang.org/x/text . `golang.org/x/text/transform`/ErrEndOfSpan. |
| 328 | return false |
| 329 | } |
| 330 | return true |
| 331 | } |
| 332 | |
| 333 | // foldFull writes the foldFull version of the current rune to dst. |
| 334 | func foldFullscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/foldFull().(c *contextscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#) bool { |
| 335 | if c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info.&hasMappingMaskscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/hasMappingMask. == 0 { |
| 336 | return c.copyscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#copy().() |
| 337 | } |
| 338 | ct := c.caseTypescip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#caseType().() |
| 339 | if c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info.&exceptionBitscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/exceptionBit. == 0 { |
| 340 | if ct != cLowerscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/cLower. || c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info.&inverseFoldBitscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/inverseFoldBit. != 0 { |
| 341 | return c.copyXORscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#copyXOR().() |
| 342 | } |
| 343 | return c.copyscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#copy().() |
| 344 | } |
| 345 | e := exceptionsscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/exceptions.[c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info.>>exceptionShiftscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/exceptionShift.:] |
| 346 | n := e[0] & lengthMaskscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/lengthMask. |
| 347 | if n == 0 { |
| 348 | if ct == cLowerscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/cLower. { |
| 349 | return c.copyscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#copy().() |
| 350 | } |
| 351 | n = (e[1] >> lengthBitsscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/lengthBits.) & lengthMaskscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/lengthMask. |
| 352 | } |
| 353 | return c.writeStringscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#writeString().(e[2 : 2+n]) |
| 354 | } |
| 355 | |
| 356 | // isFoldFull reports whether the current run is mapped to foldFull |
| 357 | func isFoldFullscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/isFoldFull().(c *contextscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#) bool { |
| 358 | if c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info.&hasMappingMaskscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/hasMappingMask. == 0 { |
| 359 | return true |
| 360 | } |
| 361 | ct := c.caseTypescip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#caseType().() |
| 362 | if c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info.&exceptionBitscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/exceptionBit. == 0 { |
| 363 | if ct != cLowerscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/cLower. || c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info.&inverseFoldBitscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/inverseFoldBit. != 0 { |
| 364 | c.errscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#err. = transformscip-go gomod golang.org/x/text . `golang.org/x/text/transform`/.ErrEndOfSpanscip-go gomod golang.org/x/text . `golang.org/x/text/transform`/ErrEndOfSpan. |
| 365 | return false |
| 366 | } |
| 367 | return true |
| 368 | } |
| 369 | e := exceptionsscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/exceptions.[c.infoscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#info.>>exceptionShiftscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/exceptionShift.:] |
| 370 | n := e[0] & lengthMaskscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/lengthMask. |
| 371 | if n == 0 && ct == cLowerscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/cLower. { |
| 372 | return true |
| 373 | } |
| 374 | c.errscip-go gomod golang.org/x/text . `golang.org/x/text/cases`/context#err. = transformscip-go gomod golang.org/x/text . `golang.org/x/text/transform`/.ErrEndOfSpanscip-go gomod golang.org/x/text . `golang.org/x/text/transform`/ErrEndOfSpan. |
| 375 | return false |
| 376 | } |