Sha256: db499ff94fdfabf656639225228255546ac04aa38b01509e8636920cb4aefee3

Contents?: true

Size: 1.82 KB

Versions: 23

Compression:

Stored size: 1.82 KB

Contents

// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.

// 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 idna

// appendMapping appends the mapping for the respective rune. isMapped must be
// true. A mapping is a categorization of a rune as defined in UTS #46.
func (c info) appendMapping(b []byte, s string) []byte {
	index := int(c >> indexShift)
	if c&xorBit == 0 {
		s := mappings[index:]
		return append(b, s[1:s[0]+1]...)
	}
	b = append(b, s...)
	if c&inlineXOR == inlineXOR {
		// TODO: support and handle two-byte inline masks
		b[len(b)-1] ^= byte(index)
	} else {
		for p := len(b) - int(xorData[index]); p < len(b); p++ {
			index++
			b[p] ^= xorData[index]
		}
	}
	return b
}

// Sparse block handling code.

type valueRange struct {
	value  uint16 // header: value:stride
	lo, hi byte   // header: lo:n
}

type sparseBlocks struct {
	values []valueRange
	offset []uint16
}

var idnaSparse = sparseBlocks{
	values: idnaSparseValues[:],
	offset: idnaSparseOffset[:],
}

// Don't use newIdnaTrie to avoid unconditional linking in of the table.
var trie = &idnaTrie{}

// lookup determines the type of block n and looks up the value for b.
// For n < t.cutoff, the block is a simple lookup table. Otherwise, the block
// is a list of ranges with an accompanying value. Given a matching range r,
// the value for b is by r.value + (b - r.lo) * stride.
func (t *sparseBlocks) lookup(n uint32, b byte) uint16 {
	offset := t.offset[n]
	header := t.values[offset]
	lo := offset + 1
	hi := lo + uint16(header.lo)
	for lo < hi {
		m := lo + (hi-lo)/2
		r := t.values[m]
		if r.lo <= b && b <= r.hi {
			return r.value + uint16(b-r.lo)*header.value
		}
		if b < r.lo {
			hi = m
		} else {
			lo = m + 1
		}
	}
	return 0
}

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
ruby_snowflake_client-1.3.7 ext/vendor/golang.org/x/net/idna/trie.go
ruby_snowflake_client-1.3.6 ext/vendor/golang.org/x/net/idna/trie.go
ruby_snowflake_client-1.3.5 ext/vendor/golang.org/x/net/idna/trie.go
ruby_snowflake_client-1.3.4 ext/vendor/golang.org/x/net/idna/trie.go
ruby_snowflake_client-1.3.4.pre.debug ext/vendor/golang.org/x/net/idna/trie.go
ruby_snowflake_client-1.3.3.pre.debug ext/vendor/golang.org/x/net/idna/trie.go
ruby_snowflake_client-1.3.2 ext/vendor/golang.org/x/net/idna/trie.go
ruby_snowflake_client-1.3.1 ext/vendor/golang.org/x/net/idna/trie.go
ruby_snowflake_client-1.3.0 ext/vendor/golang.org/x/net/idna/trie.go
ruby_snowflake_client-1.2.1 ext/vendor/golang.org/x/net/idna/trie.go
ruby_snowflake_client-1.2.0 ext/vendor/golang.org/x/net/idna/trie.go
ruby_snowflake_client-1.1.1 ext/vendor/golang.org/x/net/idna/trie.go
ruby_snowflake_client-1.1.0 ext/vendor/golang.org/x/net/idna/trie.go
ruby_snowflake_client-1.0.2 ext/vendor/golang.org/x/net/idna/trie.go
ruby_snowflake_client-1.0.1 ext/vendor/golang.org/x/net/idna/trie.go
ruby_snowflake_client-1.0.0 ext/vendor/golang.org/x/net/idna/trie.go
ires-1.3.0 ext/vendor/golang.org/x/net/idna/trie.go
ires-1.1.0 ext/vendor/golang.org/x/net/idna/trie.go
ires-1.0.0 ext/vendor/golang.org/x/net/idna/trie.go
ires-0.3.1 ext/vendor/golang.org/x/net/idna/trie.go