Skip to content

Commit

Permalink
add __close support for path.parts()
Browse files Browse the repository at this point in the history
  • Loading branch information
starwing committed Jan 26, 2023
1 parent 38019e4 commit 7d069d6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -1972,7 +1972,7 @@ static int lp_iterparts(lua_State *L) {
static int lp_newpartsiter(lua_State *L) {
lp_Path *p = lua_newuserdata(L, sizeof(lp_Path));
memset(p, 0, sizeof(*p));
if (!luaL_newmetatable(L, LP_PARTS_ITER)) {
if (luaL_newmetatable(L, LP_PARTS_ITER)) {
lua_pushcfunction(L, lp_delparts);
lua_pushvalue(L, -1);
lua_setfield(L, -3, "__gc");
Expand All @@ -1984,7 +1984,9 @@ static int lp_newpartsiter(lua_State *L) {
lua_setuservalue(L, -2);
lua_pushcfunction(L, lp_iterparts);
lua_insert(L, -2);
return 2;
lua_pushnil(L);
lua_pushvalue(L, -2);
return 4;
}

static int lpL_parts(lua_State *L) {
Expand Down

0 comments on commit 7d069d6

Please sign in to comment.