From: Steinar H. Gunderson Date: Mon, 26 Feb 2018 23:58:20 +0000 (+0100) Subject: Fix an issue where you could not give an absolute path to a theme. X-Git-Tag: 1.7.0~6 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=2a04862ca30d70897a28a9462a91532713926838;p=nageru Fix an issue where you could not give an absolute path to a theme. --- diff --git a/theme.cpp b/theme.cpp index bb0bcaf..572efb1 100644 --- a/theme.cpp +++ b/theme.cpp @@ -1041,8 +1041,21 @@ Theme::Theme(const string &filename, const vector &search_dirs, Resource lua_settop(L, 0); vector errors; bool success = false; - for (size_t i = 0; i < search_dirs.size(); ++i) { - string path = search_dirs[i] + "/" + filename; + + vector real_search_dirs; + if (!filename.empty() && filename[0] == '/') { + real_search_dirs.push_back(""); + } else { + real_search_dirs = search_dirs; + } + + for (const string &dir : real_search_dirs) { + string path; + if (dir.empty()) { + path = filename; + } else { + path = dir + "/" + filename; + } int err = luaL_loadfile(L, path.c_str()); if (err == 0) { // Success; actually call the code.