| 648 | |
| 649 | |
| 650 | static int gmatch_aux (lua_State *L) { |
| 651 | MatchState ms; |
| 652 | size_t ls, lp; |
| 653 | const char *s = lua_tolstring(L, lua_upvalueindex(1), &ls); |
| 654 | const char *p = lua_tolstring(L, lua_upvalueindex(2), &lp); |
| 655 | const char *src; |
| 656 | ms.L = L; |
| 657 | ms.matchdepth = MAXCCALLS; |
| 658 | ms.src_init = s; |
| 659 | ms.src_end = s+ls; |
| 660 | ms.p_end = p + lp; |
| 661 | for (src = s + (size_t)lua_tointeger(L, lua_upvalueindex(3)); |
| 662 | src <= ms.src_end; |
| 663 | src++) { |
| 664 | const char *e; |
| 665 | ms.level = 0; |
| 666 | lua_assert(ms.matchdepth == MAXCCALLS); |
| 667 | if ((e = match(&ms, src, p)) != NULL) { |
| 668 | lua_Integer newstart = e-s; |
| 669 | if (e == src) newstart++; /* empty match? go at least one position */ |
| 670 | lua_pushinteger(L, newstart); |
| 671 | lua_replace(L, lua_upvalueindex(3)); |
| 672 | return push_captures(&ms, src, e); |
| 673 | } |
| 674 | } |
| 675 | return 0; /* not found */ |
| 676 | } |
| 677 | |
| 678 | |
| 679 | static int str_gmatch (lua_State *L) { |
nothing calls this directly
no test coverage detected