MCPcopy Index your code
hub / github.com/Shopify/go-lua / findHelper

Function findHelper

string.go:20–41  ·  view source on GitHub ↗
(l *State, isFind bool)

Source from the content-addressed store, hash-verified

18}
19
20func findHelper(l *State, isFind bool) int {
21 s, p := CheckString(l, 1), CheckString(l, 2)
22 init := relativePosition(OptInteger(l, 3, 1), len(s))
23 if init < 1 {
24 init = 1
25 } else if init > len(s)+1 {
26 l.PushNil()
27 return 1
28 }
29 isPlain := l.TypeOf(4) == TypeNone || l.ToBoolean(4)
30 if isFind && (isPlain || !strings.ContainsAny(p, "^$*+?.([%-")) {
31 if start := strings.Index(s[init-1:], p); start >= 0 {
32 l.PushInteger(start + init)
33 l.PushInteger(start + init + len(p) - 1)
34 return 2
35 }
36 } else {
37 l.assert(false) // TODO implement pattern matching
38 }
39 l.PushNil()
40 return 1
41}
42
43func scanFormat(l *State, fs string) string {
44 i := 0

Callers 1

string.goFile · 0.85

Calls 8

CheckStringFunction · 0.85
relativePositionFunction · 0.85
OptIntegerFunction · 0.85
PushNilMethod · 0.80
TypeOfMethod · 0.80
ToBooleanMethod · 0.80
PushIntegerMethod · 0.80
assertMethod · 0.45

Tested by

no test coverage detected