]> git.sesse.net Git - nageru/commitdiff
Fix an issue where you could not give an absolute path to a theme.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 26 Feb 2018 23:58:20 +0000 (00:58 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 26 Feb 2018 23:58:20 +0000 (00:58 +0100)
theme.cpp

index bb0bcaf8eeb16102baf7d152e25b4485449564a6..572efb18f3b27a9c75a764f794268104fd7bf275 100644 (file)
--- a/theme.cpp
+++ b/theme.cpp
@@ -1041,8 +1041,21 @@ Theme::Theme(const string &filename, const vector<string> &search_dirs, Resource
        lua_settop(L, 0);
        vector<string> errors;
        bool success = false;
-       for (size_t i = 0; i < search_dirs.size(); ++i) {
-               string path = search_dirs[i] + "/" + filename;
+
+       vector<string> 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.