(L *LState)
| 351 | } |
| 352 | |
| 353 | func strMatch(L *LState) int { |
| 354 | str := L.CheckString(1) |
| 355 | pattern := L.CheckString(2) |
| 356 | offset := L.OptInt(3, 1) |
| 357 | l := len(str) |
| 358 | if offset < 0 { |
| 359 | offset = l + offset + 1 |
| 360 | } |
| 361 | offset-- |
| 362 | if offset < 0 { |
| 363 | offset = 0 |
| 364 | } |
| 365 | |
| 366 | mds, err := pm.Find(pattern, unsafeFastStringToReadOnlyBytes(str), offset, 1) |
| 367 | if err != nil { |
| 368 | L.RaiseError(err.Error()) |
| 369 | } |
| 370 | if len(mds) == 0 { |
| 371 | L.Push(LNil) |
| 372 | return 0 |
| 373 | } |
| 374 | md := mds[0] |
| 375 | nsubs := md.CaptureLength() / 2 |
| 376 | switch nsubs { |
| 377 | case 1: |
| 378 | L.Push(LString(str[md.Capture(0):md.Capture(1)])) |
| 379 | return 1 |
| 380 | default: |
| 381 | for i := 2; i < md.CaptureLength(); i += 2 { |
| 382 | if md.IsPosCapture(i) { |
| 383 | L.Push(LNumber(md.Capture(i))) |
| 384 | } else { |
| 385 | L.Push(LString(str[md.Capture(i):md.Capture(i+1)])) |
| 386 | } |
| 387 | } |
| 388 | return nsubs - 1 |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | func strRep(L *LState) int { |
| 393 | str := L.CheckString(1) |
nothing calls this directly
no test coverage detected
searching dependent graphs…