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

Function strGmatchIter

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

Source from the content-addressed store, hash-verified

299}
300
301func strGmatchIter(L *LState) int {
302 md := L.CheckUserData(1).Value.(*strMatchData)
303 str := md.str
304 matches := md.matches
305 idx := md.pos
306 md.pos += 1
307 if idx == len(matches) {
308 return 0
309 }
310 L.Push(L.Get(1))
311 match := matches[idx]
312 if match.CaptureLength() == 2 {
313 L.Push(LString(str[match.Capture(0):match.Capture(1)]))
314 return 1
315 }
316
317 for i := 2; i < match.CaptureLength(); i += 2 {
318 if match.IsPosCapture(i) {
319 L.Push(LNumber(match.Capture(i)))
320 } else {
321 L.Push(LString(str[match.Capture(i):match.Capture(i+1)]))
322 }
323 }
324 return match.CaptureLength()/2 - 1
325}
326
327func strGmatch(L *LState) int {
328 str := L.CheckString(1)

Callers

nothing calls this directly

Calls 8

LStringTypeAlias · 0.85
LNumberTypeAlias · 0.85
CheckUserDataMethod · 0.80
CaptureLengthMethod · 0.80
CaptureMethod · 0.80
IsPosCaptureMethod · 0.80
PushMethod · 0.65
GetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…