MCPcopy Index your code
hub / github.com/yuin/gopher-lua / strByte

Function strByte

stringlib.go:43–73  ·  view source on GitHub ↗
(L *LState)

Source from the content-addressed store, hash-verified

41}
42
43func strByte(L *LState) int {
44 str := L.CheckString(1)
45 start := L.OptInt(2, 1) - 1
46 end := L.OptInt(3, -1)
47 l := len(str)
48 if start < 0 {
49 start = l + start + 1
50 }
51 if end < 0 {
52 end = l + end + 1
53 }
54
55 if L.GetTop() == 2 {
56 if start < 0 || start >= l {
57 return 0
58 }
59 L.Push(LNumber(str[start]))
60 return 1
61 }
62
63 start = intMax(start, 0)
64 end = intMin(end, l)
65 if end < 0 || end <= start || start >= l {
66 return 0
67 }
68
69 for i := start; i < end; i++ {
70 L.Push(LNumber(str[i]))
71 }
72 return end - start
73}
74
75func strChar(L *LState) int {
76 top := L.GetTop()

Callers

nothing calls this directly

Calls 7

LNumberTypeAlias · 0.85
intMaxFunction · 0.85
intMinFunction · 0.85
CheckStringMethod · 0.80
OptIntMethod · 0.80
PushMethod · 0.65
GetTopMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…