2015-03-18 16:59:14 +00:00
|
|
|
package fzf
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
2015-03-22 08:19:30 +00:00
|
|
|
"unicode/utf8"
|
2016-09-28 15:54:27 +00:00
|
|
|
|
2016-10-24 00:44:56 +00:00
|
|
|
"github.com/junegunn/fzf/src/tui"
|
2015-03-18 16:59:14 +00:00
|
|
|
)
|
|
|
|
|
2015-03-22 07:05:54 +00:00
|
|
|
type ansiOffset struct {
|
2015-03-18 16:59:14 +00:00
|
|
|
offset [2]int32
|
|
|
|
color ansiState
|
|
|
|
}
|
|
|
|
|
|
|
|
type ansiState struct {
|
2016-10-24 00:44:56 +00:00
|
|
|
fg tui.Color
|
|
|
|
bg tui.Color
|
|
|
|
attr tui.Attr
|
2020-11-24 16:40:30 +00:00
|
|
|
lbg tui.Color
|
2015-03-18 16:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *ansiState) colored() bool {
|
2020-11-24 16:40:30 +00:00
|
|
|
return s.fg != -1 || s.bg != -1 || s.attr > 0 || s.lbg >= 0
|
2015-03-18 16:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *ansiState) equals(t *ansiState) bool {
|
|
|
|
if t == nil {
|
|
|
|
return !s.colored()
|
|
|
|
}
|
2020-11-24 16:40:30 +00:00
|
|
|
return s.fg == t.fg && s.bg == t.bg && s.attr == t.attr && s.lbg == t.lbg
|
2015-03-18 16:59:14 +00:00
|
|
|
}
|
|
|
|
|
2019-03-06 10:05:05 +00:00
|
|
|
func (s *ansiState) ToString() string {
|
|
|
|
if !s.colored() {
|
2019-03-07 01:47:09 +00:00
|
|
|
return ""
|
2019-03-06 10:05:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ret := ""
|
|
|
|
if s.attr&tui.Bold > 0 {
|
|
|
|
ret += "1;"
|
|
|
|
}
|
|
|
|
if s.attr&tui.Dim > 0 {
|
|
|
|
ret += "2;"
|
|
|
|
}
|
|
|
|
if s.attr&tui.Italic > 0 {
|
|
|
|
ret += "3;"
|
|
|
|
}
|
|
|
|
if s.attr&tui.Underline > 0 {
|
|
|
|
ret += "4;"
|
|
|
|
}
|
|
|
|
if s.attr&tui.Blink > 0 {
|
|
|
|
ret += "5;"
|
|
|
|
}
|
|
|
|
if s.attr&tui.Reverse > 0 {
|
|
|
|
ret += "7;"
|
|
|
|
}
|
|
|
|
ret += toAnsiString(s.fg, 30) + toAnsiString(s.bg, 40)
|
|
|
|
|
|
|
|
return "\x1b[" + strings.TrimSuffix(ret, ";") + "m"
|
|
|
|
}
|
|
|
|
|
|
|
|
func toAnsiString(color tui.Color, offset int) string {
|
|
|
|
col := int(color)
|
|
|
|
ret := ""
|
|
|
|
if col == -1 {
|
|
|
|
ret += strconv.Itoa(offset + 9)
|
|
|
|
} else if col < 8 {
|
|
|
|
ret += strconv.Itoa(offset + col)
|
|
|
|
} else if col < 16 {
|
|
|
|
ret += strconv.Itoa(offset - 30 + 90 + col - 8)
|
|
|
|
} else if col < 256 {
|
2019-03-06 17:00:31 +00:00
|
|
|
ret += strconv.Itoa(offset+8) + ";5;" + strconv.Itoa(col)
|
2019-03-06 10:05:05 +00:00
|
|
|
} else if col >= (1 << 24) {
|
2019-03-06 17:00:31 +00:00
|
|
|
r := strconv.Itoa((col >> 16) & 0xff)
|
|
|
|
g := strconv.Itoa((col >> 8) & 0xff)
|
|
|
|
b := strconv.Itoa(col & 0xff)
|
|
|
|
ret += strconv.Itoa(offset+8) + ";2;" + r + ";" + g + ";" + b
|
2019-03-06 10:05:05 +00:00
|
|
|
}
|
|
|
|
return ret + ";"
|
|
|
|
}
|
|
|
|
|
2021-03-11 10:34:50 +00:00
|
|
|
func isPrint(c uint8) bool {
|
|
|
|
return '\x20' <= c && c <= '\x7e'
|
2017-07-19 12:49:41 +00:00
|
|
|
}
|
|
|
|
|
2021-03-11 10:34:50 +00:00
|
|
|
func matchOperatingSystemCommand(s string) int {
|
2022-08-12 13:18:10 +00:00
|
|
|
// `\x1b][0-9][;:][[:print:]]+(?:\x1b\\\\|\x07)`
|
2021-03-11 10:34:50 +00:00
|
|
|
// ^ match starting here
|
|
|
|
//
|
|
|
|
i := 5 // prefix matched in nextAnsiEscapeSequence()
|
|
|
|
for ; i < len(s) && isPrint(s[i]); i++ {
|
|
|
|
}
|
|
|
|
if i < len(s) {
|
|
|
|
if s[i] == '\x07' {
|
|
|
|
return i + 1
|
|
|
|
}
|
|
|
|
if s[i] == '\x1b' && i < len(s)-1 && s[i+1] == '\\' {
|
|
|
|
return i + 2
|
2017-07-19 12:49:41 +00:00
|
|
|
}
|
2021-03-11 10:34:50 +00:00
|
|
|
}
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
|
|
|
func matchControlSequence(s string) int {
|
2022-08-12 13:18:10 +00:00
|
|
|
// `\x1b[\\[()][0-9;:?]*[a-zA-Z@]`
|
|
|
|
// ^ match starting here
|
2021-03-11 10:34:50 +00:00
|
|
|
//
|
|
|
|
i := 2 // prefix matched in nextAnsiEscapeSequence()
|
2022-08-25 05:02:08 +00:00
|
|
|
for ; i < len(s); i++ {
|
2021-03-11 10:34:50 +00:00
|
|
|
c := s[i]
|
2022-08-25 05:02:08 +00:00
|
|
|
switch c {
|
|
|
|
case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ';', ':', '?':
|
|
|
|
// ok
|
|
|
|
default:
|
|
|
|
if 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z' || c == '@' {
|
|
|
|
return i + 1
|
|
|
|
}
|
|
|
|
return -1
|
2017-07-19 12:49:41 +00:00
|
|
|
}
|
|
|
|
}
|
2021-03-11 10:34:50 +00:00
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
|
|
|
func isCtrlSeqStart(c uint8) bool {
|
2022-08-25 05:02:08 +00:00
|
|
|
switch c {
|
|
|
|
case '\\', '[', '(', ')':
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
2021-03-11 10:34:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// nextAnsiEscapeSequence returns the ANSI escape sequence and is equivalent to
|
|
|
|
// calling FindStringIndex() on the below regex (which was originally used):
|
|
|
|
//
|
2022-08-12 13:18:10 +00:00
|
|
|
// "(?:\x1b[\\[()][0-9;:?]*[a-zA-Z@]|\x1b][0-9][;:][[:print:]]+(?:\x1b\\\\|\x07)|\x1b.|[\x0e\x0f]|.\x08)"
|
2021-03-11 10:34:50 +00:00
|
|
|
func nextAnsiEscapeSequence(s string) (int, int) {
|
|
|
|
// fast check for ANSI escape sequences
|
|
|
|
i := 0
|
|
|
|
for ; i < len(s); i++ {
|
|
|
|
switch s[i] {
|
|
|
|
case '\x0e', '\x0f', '\x1b', '\x08':
|
|
|
|
// We ignore the fact that '\x08' cannot be the first char
|
|
|
|
// in the string and be an escape sequence for the sake of
|
|
|
|
// speed and simplicity.
|
|
|
|
goto Loop
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1, -1
|
|
|
|
|
|
|
|
Loop:
|
|
|
|
for ; i < len(s); i++ {
|
|
|
|
switch s[i] {
|
|
|
|
case '\x08':
|
|
|
|
// backtrack to match: `.\x08`
|
|
|
|
if i > 0 && s[i-1] != '\n' {
|
|
|
|
if s[i-1] < utf8.RuneSelf {
|
|
|
|
return i - 1, i + 1
|
|
|
|
}
|
|
|
|
_, n := utf8.DecodeLastRuneInString(s[:i])
|
|
|
|
return i - n, i + 1
|
|
|
|
}
|
|
|
|
case '\x1b':
|
2022-08-12 13:18:10 +00:00
|
|
|
// match: `\x1b[\\[()][0-9;:?]*[a-zA-Z@]`
|
2021-03-11 10:34:50 +00:00
|
|
|
if i+2 < len(s) && isCtrlSeqStart(s[i+1]) {
|
|
|
|
if j := matchControlSequence(s[i:]); j != -1 {
|
|
|
|
return i, i + j
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-12 13:18:10 +00:00
|
|
|
// match: `\x1b][0-9][;:][[:print:]]+(?:\x1b\\\\|\x07)`
|
2021-03-11 10:34:50 +00:00
|
|
|
if i+5 < len(s) && s[i+1] == ']' && isNumeric(s[i+2]) &&
|
2022-08-12 13:18:10 +00:00
|
|
|
(s[i+3] == ';' || s[i+3] == ':') && isPrint(s[i+4]) {
|
2021-03-11 10:34:50 +00:00
|
|
|
|
|
|
|
if j := matchOperatingSystemCommand(s[i:]); j != -1 {
|
|
|
|
return i, i + j
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// match: `\x1b.`
|
|
|
|
if i+1 < len(s) && s[i+1] != '\n' {
|
|
|
|
if s[i+1] < utf8.RuneSelf {
|
|
|
|
return i, i + 2
|
|
|
|
}
|
|
|
|
_, n := utf8.DecodeRuneInString(s[i+1:])
|
|
|
|
return i, i + n + 1
|
|
|
|
}
|
|
|
|
case '\x0e', '\x0f':
|
|
|
|
// match: `[\x0e\x0f]`
|
|
|
|
return i, i + 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1, -1
|
2015-03-18 16:59:14 +00:00
|
|
|
}
|
|
|
|
|
2016-08-18 17:39:32 +00:00
|
|
|
func extractColor(str string, state *ansiState, proc func(string, *ansiState) bool) (string, *[]ansiOffset, *ansiState) {
|
2021-03-11 10:34:50 +00:00
|
|
|
// We append to a stack allocated variable that we'll
|
|
|
|
// later copy and return, to save on allocations.
|
|
|
|
offsets := make([]ansiOffset, 0, 32)
|
2015-07-22 05:19:45 +00:00
|
|
|
|
|
|
|
if state != nil {
|
|
|
|
offsets = append(offsets, ansiOffset{[2]int32{0, 0}, *state})
|
|
|
|
}
|
2015-03-18 16:59:14 +00:00
|
|
|
|
2021-03-11 10:34:50 +00:00
|
|
|
var (
|
|
|
|
pstate *ansiState // lazily allocated
|
|
|
|
output strings.Builder
|
|
|
|
prevIdx int
|
|
|
|
runeCount int
|
|
|
|
)
|
2017-07-19 12:49:41 +00:00
|
|
|
for idx := 0; idx < len(str); {
|
|
|
|
// Make sure that we found an ANSI code
|
2021-03-11 10:34:50 +00:00
|
|
|
start, end := nextAnsiEscapeSequence(str[idx:])
|
|
|
|
if start == -1 {
|
|
|
|
break
|
2017-07-19 12:49:41 +00:00
|
|
|
}
|
2021-03-11 10:34:50 +00:00
|
|
|
start += idx
|
|
|
|
idx += end
|
2017-07-19 12:49:41 +00:00
|
|
|
|
|
|
|
// Check if we should continue
|
2021-03-11 10:34:50 +00:00
|
|
|
prev := str[prevIdx:start]
|
2016-06-14 12:52:47 +00:00
|
|
|
if proc != nil && !proc(prev, state) {
|
2016-07-15 14:24:14 +00:00
|
|
|
return "", nil, nil
|
2016-06-14 12:52:47 +00:00
|
|
|
}
|
2021-03-11 10:34:50 +00:00
|
|
|
prevIdx = idx
|
2015-03-18 16:59:14 +00:00
|
|
|
|
2021-03-11 10:34:50 +00:00
|
|
|
if len(prev) != 0 {
|
|
|
|
runeCount += utf8.RuneCountInString(prev)
|
|
|
|
// Grow the buffer size to the maximum possible length (string length
|
|
|
|
// containing ansi codes) to avoid repetitive allocation
|
|
|
|
if output.Cap() == 0 {
|
|
|
|
output.Grow(len(str))
|
|
|
|
}
|
|
|
|
output.WriteString(prev)
|
|
|
|
}
|
2017-07-19 12:49:41 +00:00
|
|
|
|
2021-03-11 10:34:50 +00:00
|
|
|
newState := interpretCode(str[start:idx], state)
|
2015-03-18 16:59:14 +00:00
|
|
|
if !newState.equals(state) {
|
|
|
|
if state != nil {
|
|
|
|
// Update last offset
|
2017-07-19 12:49:41 +00:00
|
|
|
(&offsets[len(offsets)-1]).offset[1] = int32(runeCount)
|
2015-03-18 16:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if newState.colored() {
|
|
|
|
// Append new offset
|
2021-03-11 10:34:50 +00:00
|
|
|
if pstate == nil {
|
|
|
|
pstate = &ansiState{}
|
|
|
|
}
|
|
|
|
*pstate = newState
|
|
|
|
state = pstate
|
|
|
|
offsets = append(offsets, ansiOffset{
|
|
|
|
[2]int32{int32(runeCount), int32(runeCount)},
|
|
|
|
newState,
|
|
|
|
})
|
2015-03-18 16:59:14 +00:00
|
|
|
} else {
|
|
|
|
// Discard state
|
|
|
|
state = nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-17 18:04:11 +00:00
|
|
|
var rest string
|
|
|
|
var trimmed string
|
|
|
|
if prevIdx == 0 {
|
|
|
|
// No ANSI code found
|
|
|
|
rest = str
|
|
|
|
trimmed = str
|
|
|
|
} else {
|
|
|
|
rest = str[prevIdx:]
|
2015-03-18 16:59:14 +00:00
|
|
|
output.WriteString(rest)
|
2017-08-17 18:04:11 +00:00
|
|
|
trimmed = output.String()
|
|
|
|
}
|
2016-06-14 12:52:47 +00:00
|
|
|
if proc != nil {
|
|
|
|
proc(rest, state)
|
|
|
|
}
|
2021-03-11 10:34:50 +00:00
|
|
|
if len(offsets) > 0 {
|
|
|
|
if len(rest) > 0 && state != nil {
|
|
|
|
// Update last offset
|
|
|
|
runeCount += utf8.RuneCountInString(rest)
|
|
|
|
(&offsets[len(offsets)-1]).offset[1] = int32(runeCount)
|
|
|
|
}
|
|
|
|
// Return a copy of the offsets slice
|
|
|
|
a := make([]ansiOffset, len(offsets))
|
|
|
|
copy(a, offsets)
|
|
|
|
return trimmed, &a, state
|
2016-08-18 17:39:32 +00:00
|
|
|
}
|
2021-03-11 10:34:50 +00:00
|
|
|
return trimmed, nil, state
|
|
|
|
}
|
|
|
|
|
2022-08-12 13:18:10 +00:00
|
|
|
func parseAnsiCode(s string, delimiter byte) (int, byte, string) {
|
2021-03-11 10:34:50 +00:00
|
|
|
var remaining string
|
2022-08-12 13:18:10 +00:00
|
|
|
i := -1
|
|
|
|
if delimiter == 0 {
|
|
|
|
// Faster than strings.IndexAny(";:")
|
|
|
|
i = strings.IndexByte(s, ';')
|
|
|
|
if i < 0 {
|
|
|
|
i = strings.IndexByte(s, ':')
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
i = strings.IndexByte(s, delimiter)
|
|
|
|
}
|
|
|
|
if i >= 0 {
|
|
|
|
delimiter = s[i]
|
2021-03-11 10:34:50 +00:00
|
|
|
remaining = s[i+1:]
|
|
|
|
s = s[:i]
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(s) > 0 {
|
|
|
|
// Inlined version of strconv.Atoi() that only handles positive
|
|
|
|
// integers and does not allocate on error.
|
|
|
|
code := 0
|
|
|
|
for _, ch := range []byte(s) {
|
|
|
|
ch -= '0'
|
|
|
|
if ch > 9 {
|
2022-08-12 13:18:10 +00:00
|
|
|
return -1, delimiter, remaining
|
2021-03-11 10:34:50 +00:00
|
|
|
}
|
|
|
|
code = code*10 + int(ch)
|
|
|
|
}
|
2022-08-12 13:18:10 +00:00
|
|
|
return code, delimiter, remaining
|
2021-03-11 10:34:50 +00:00
|
|
|
}
|
|
|
|
|
2022-08-12 13:18:10 +00:00
|
|
|
return -1, delimiter, remaining
|
2015-03-18 16:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-03-11 10:34:50 +00:00
|
|
|
func interpretCode(ansiCode string, prevState *ansiState) ansiState {
|
|
|
|
var state ansiState
|
2015-03-18 16:59:14 +00:00
|
|
|
if prevState == nil {
|
2021-03-11 10:34:50 +00:00
|
|
|
state = ansiState{-1, -1, 0, -1}
|
2015-03-18 16:59:14 +00:00
|
|
|
} else {
|
2021-03-11 10:34:50 +00:00
|
|
|
state = ansiState{prevState.fg, prevState.bg, prevState.attr, prevState.lbg}
|
2015-03-18 16:59:14 +00:00
|
|
|
}
|
2016-11-13 17:13:16 +00:00
|
|
|
if ansiCode[0] != '\x1b' || ansiCode[1] != '[' || ansiCode[len(ansiCode)-1] != 'm' {
|
2021-03-11 10:34:50 +00:00
|
|
|
if prevState != nil && strings.HasSuffix(ansiCode, "0K") {
|
2020-11-24 16:40:30 +00:00
|
|
|
state.lbg = prevState.bg
|
|
|
|
}
|
2015-03-27 03:35:06 +00:00
|
|
|
return state
|
|
|
|
}
|
2015-03-18 16:59:14 +00:00
|
|
|
|
2021-03-11 10:34:50 +00:00
|
|
|
if len(ansiCode) <= 3 {
|
2015-03-18 16:59:14 +00:00
|
|
|
state.fg = -1
|
|
|
|
state.bg = -1
|
2016-09-28 15:54:27 +00:00
|
|
|
state.attr = 0
|
2021-03-11 10:34:50 +00:00
|
|
|
return state
|
2015-03-18 16:59:14 +00:00
|
|
|
}
|
|
|
|
ansiCode = ansiCode[2 : len(ansiCode)-1]
|
2021-03-11 10:34:50 +00:00
|
|
|
|
|
|
|
state256 := 0
|
|
|
|
ptr := &state.fg
|
|
|
|
|
2022-08-12 13:18:10 +00:00
|
|
|
var delimiter byte = 0
|
2021-03-11 10:34:50 +00:00
|
|
|
for len(ansiCode) != 0 {
|
|
|
|
var num int
|
2022-08-12 13:18:10 +00:00
|
|
|
if num, delimiter, ansiCode = parseAnsiCode(ansiCode, delimiter); num != -1 {
|
2015-03-18 16:59:14 +00:00
|
|
|
switch state256 {
|
|
|
|
case 0:
|
|
|
|
switch num {
|
|
|
|
case 38:
|
|
|
|
ptr = &state.fg
|
|
|
|
state256++
|
|
|
|
case 48:
|
|
|
|
ptr = &state.bg
|
|
|
|
state256++
|
|
|
|
case 39:
|
|
|
|
state.fg = -1
|
|
|
|
case 49:
|
|
|
|
state.bg = -1
|
|
|
|
case 1:
|
2016-11-23 15:13:10 +00:00
|
|
|
state.attr = state.attr | tui.Bold
|
2016-09-28 15:54:27 +00:00
|
|
|
case 2:
|
2016-11-23 15:13:10 +00:00
|
|
|
state.attr = state.attr | tui.Dim
|
|
|
|
case 3:
|
|
|
|
state.attr = state.attr | tui.Italic
|
2016-09-28 15:54:27 +00:00
|
|
|
case 4:
|
2016-11-23 15:13:10 +00:00
|
|
|
state.attr = state.attr | tui.Underline
|
2016-09-28 15:54:27 +00:00
|
|
|
case 5:
|
2016-11-23 15:13:10 +00:00
|
|
|
state.attr = state.attr | tui.Blink
|
2016-09-28 15:54:27 +00:00
|
|
|
case 7:
|
2016-11-23 15:13:10 +00:00
|
|
|
state.attr = state.attr | tui.Reverse
|
2020-02-17 15:45:24 +00:00
|
|
|
case 23: // tput rmso
|
|
|
|
state.attr = state.attr &^ tui.Italic
|
|
|
|
case 24: // tput rmul
|
|
|
|
state.attr = state.attr &^ tui.Underline
|
2015-03-18 16:59:14 +00:00
|
|
|
case 0:
|
2021-03-11 10:34:50 +00:00
|
|
|
state.fg = -1
|
|
|
|
state.bg = -1
|
|
|
|
state.attr = 0
|
|
|
|
state256 = 0
|
2015-03-18 16:59:14 +00:00
|
|
|
default:
|
|
|
|
if num >= 30 && num <= 37 {
|
2016-10-24 00:44:56 +00:00
|
|
|
state.fg = tui.Color(num - 30)
|
2015-03-18 16:59:14 +00:00
|
|
|
} else if num >= 40 && num <= 47 {
|
2016-10-24 00:44:56 +00:00
|
|
|
state.bg = tui.Color(num - 40)
|
2016-09-25 09:11:35 +00:00
|
|
|
} else if num >= 90 && num <= 97 {
|
2016-10-24 00:44:56 +00:00
|
|
|
state.fg = tui.Color(num - 90 + 8)
|
2016-09-25 09:11:35 +00:00
|
|
|
} else if num >= 100 && num <= 107 {
|
2016-10-24 00:44:56 +00:00
|
|
|
state.bg = tui.Color(num - 100 + 8)
|
2015-03-18 16:59:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
case 1:
|
|
|
|
switch num {
|
2016-11-25 15:36:38 +00:00
|
|
|
case 2:
|
|
|
|
state256 = 10 // MAGIC
|
2015-03-18 16:59:14 +00:00
|
|
|
case 5:
|
|
|
|
state256++
|
|
|
|
default:
|
|
|
|
state256 = 0
|
|
|
|
}
|
|
|
|
case 2:
|
2016-10-24 00:44:56 +00:00
|
|
|
*ptr = tui.Color(num)
|
2015-03-18 16:59:14 +00:00
|
|
|
state256 = 0
|
2016-11-25 15:36:38 +00:00
|
|
|
case 10:
|
|
|
|
*ptr = tui.Color(1<<24) | tui.Color(num<<16)
|
|
|
|
state256++
|
|
|
|
case 11:
|
|
|
|
*ptr = *ptr | tui.Color(num<<8)
|
|
|
|
state256++
|
|
|
|
case 12:
|
|
|
|
*ptr = *ptr | tui.Color(num)
|
|
|
|
state256 = 0
|
2015-03-18 16:59:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-03-11 10:34:50 +00:00
|
|
|
|
2016-11-25 15:36:38 +00:00
|
|
|
if state256 > 0 {
|
|
|
|
*ptr = -1
|
|
|
|
}
|
2015-03-18 16:59:14 +00:00
|
|
|
return state
|
|
|
|
}
|