| 687 | |
| 688 | |
| 689 | static int gmatch (lua_State *L) { |
| 690 | size_t ls, lp; |
| 691 | const char *s = luaL_checklstring(L, 1, &ls); |
| 692 | const char *p = luaL_checklstring(L, 2, &lp); |
| 693 | GMatchState *gm; |
| 694 | lua_settop(L, 2); /* keep them on closure to avoid being collected */ |
| 695 | gm = (GMatchState *)lua_newuserdata(L, sizeof(GMatchState)); |
| 696 | prepstate(&gm->ms, L, s, ls, p, lp); |
| 697 | gm->src = s; gm->p = p; gm->lastmatch = NULL; |
| 698 | lua_pushcclosure(L, gmatch_aux, 3); |
| 699 | return 1; |
| 700 | } |
| 701 | |
| 702 | |
| 703 | static void add_s (MatchState *ms, luaL_Buffer *b, const char *s, |
nothing calls this directly
no test coverage detected