diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2020-04-21 19:38:05 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2020-04-22 11:30:28 -0300 |
| commit | 842505b6a33d0b0e2445568ea42f2adbf3c4eb77 (patch) | |
| tree | 87cb50d1f184ee7cb9ffc9d2ce973e3bb5b19fea /src | |
| parent | 3e879ffba1b66ede11a038ba46d55475a51e538b (diff) | |
| download | luafilesystem-842505b6a33d0b0e2445568ea42f2adbf3c4eb77.tar.gz luafilesystem-842505b6a33d0b0e2445568ea42f2adbf3c4eb77.tar.bz2 luafilesystem-842505b6a33d0b0e2445568ea42f2adbf3c4eb77.zip | |
Lua 5.4: use __close to close dir if you break the iterator
Diffstat (limited to 'src')
| -rw-r--r-- | src/lfs.c | 11 |
1 files changed, 11 insertions, 0 deletions
| @@ -725,7 +725,13 @@ static int dir_iter_factory(lua_State * L) | |||
| 725 | if (d->dir == NULL) | 725 | if (d->dir == NULL) |
| 726 | luaL_error(L, "cannot open %s: %s", path, strerror(errno)); | 726 | luaL_error(L, "cannot open %s: %s", path, strerror(errno)); |
| 727 | #endif | 727 | #endif |
| 728 | #if LUA_VERSION_NUM >= 504 | ||
| 729 | lua_pushnil(L); | ||
| 730 | lua_pushvalue(L, -2); | ||
| 731 | return 4; | ||
| 732 | #else | ||
| 728 | return 2; | 733 | return 2; |
| 734 | #endif | ||
| 729 | } | 735 | } |
| 730 | 736 | ||
| 731 | 737 | ||
| @@ -747,6 +753,11 @@ static int dir_create_meta(lua_State * L) | |||
| 747 | lua_setfield(L, -2, "__index"); | 753 | lua_setfield(L, -2, "__index"); |
| 748 | lua_pushcfunction(L, dir_close); | 754 | lua_pushcfunction(L, dir_close); |
| 749 | lua_setfield(L, -2, "__gc"); | 755 | lua_setfield(L, -2, "__gc"); |
| 756 | |||
| 757 | #if LUA_VERSION_NUM >= 504 | ||
| 758 | lua_pushcfunction(L, dir_close); | ||
| 759 | lua_setfield(L, -2, "__close"); | ||
| 760 | #endif | ||
| 750 | return 1; | 761 | return 1; |
| 751 | } | 762 | } |
| 752 | 763 | ||
