mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-28 05:09:58 +00:00
Add db-connect, a SQL over HTTPS server
This commit is contained in:
31
vendor/github.com/kshvakov/clickhouse/word_matcher.go
generated
vendored
Normal file
31
vendor/github.com/kshvakov/clickhouse/word_matcher.go
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
package clickhouse
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
// wordMatcher is a simple automata to match a single word (case insensitive)
|
||||
type wordMatcher struct {
|
||||
word []rune
|
||||
position uint8
|
||||
}
|
||||
|
||||
// newMatcher returns matcher for word needle
|
||||
func newMatcher(needle string) *wordMatcher {
|
||||
return &wordMatcher{word: []rune(strings.ToUpper(needle)),
|
||||
position: 0}
|
||||
}
|
||||
|
||||
func (m *wordMatcher) matchRune(r rune) bool {
|
||||
if m.word[m.position] == unicode.ToUpper(r) {
|
||||
if m.position == uint8(len(m.word)-1) {
|
||||
m.position = 0
|
||||
return true
|
||||
}
|
||||
m.position++
|
||||
} else {
|
||||
m.position = 0
|
||||
}
|
||||
return false
|
||||
}
|
Reference in New Issue
Block a user