From 7c921d8c916dce2cc06a1f885198e8f1dca58622 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 25 Jul 2020 13:02:35 -0400 Subject: [PATCH] Lua listdir_recursive: allow nil to be used for default arguments https://github.com/DFHack/dfhack/pull/1609#issuecomment-663803777 --- library/LuaApi.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp index 5b731ecc7..25843875d 100644 --- a/library/LuaApi.cpp +++ b/library/LuaApi.cpp @@ -2404,10 +2404,10 @@ static int filesystem_listdir_recursive(lua_State *L) luaL_checktype(L,1,LUA_TSTRING); std::string dir=lua_tostring(L,1); int depth = 10; - if (lua_gettop(L) >= 2) + if (lua_gettop(L) >= 2 && !lua_isnil(L, 2)) depth = luaL_checkint(L, 2); bool include_prefix = true; - if (lua_gettop(L) >= 3) + if (lua_gettop(L) >= 3 && !lua_isnil(L, 3)) include_prefix = lua_toboolean(L, 3); std::map files; int err = DFHack::Filesystem::listdir_recursive(dir, files, depth, include_prefix);