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

Function strGsub

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

Source from the content-addressed store, hash-verified

146}
147
148func strGsub(L *LState) int {
149 str := L.CheckString(1)
150 pat := L.CheckString(2)
151 L.CheckTypes(3, LTString, LTTable, LTFunction)
152 repl := L.CheckAny(3)
153 limit := L.OptInt(4, -1)
154
155 mds, err := pm.Find(pat, unsafeFastStringToReadOnlyBytes(str), 0, limit)
156 if err != nil {
157 L.RaiseError(err.Error())
158 }
159 if len(mds) == 0 {
160 L.SetTop(1)
161 L.Push(LNumber(0))
162 return 2
163 }
164 switch lv := repl.(type) {
165 case LString:
166 L.Push(LString(strGsubStr(L, str, string(lv), mds)))
167 case *LTable:
168 L.Push(LString(strGsubTable(L, str, lv, mds)))
169 case *LFunction:
170 L.Push(LString(strGsubFunc(L, str, lv, mds)))
171 }
172 L.Push(LNumber(len(mds)))
173 return 2
174}
175
176type replaceInfo struct {
177 Indicies []int

Callers

nothing calls this directly

Calls 15

FindFunction · 0.92
LNumberTypeAlias · 0.85
LStringTypeAlias · 0.85
strGsubStrFunction · 0.85
strGsubTableFunction · 0.85
strGsubFuncFunction · 0.85
CheckStringMethod · 0.80
CheckTypesMethod · 0.80
CheckAnyMethod · 0.80
OptIntMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…