X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=theme.cpp;fp=theme.cpp;h=572efb18f3b27a9c75a764f794268104fd7bf275;hb=2a04862ca30d70897a28a9462a91532713926838;hp=bb0bcaf8eeb16102baf7d152e25b4485449564a6;hpb=f3dbafe3251a6613433debfdde48dc814f5423a1;p=nageru 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.