]> git.lyx.org Git - lyx.git/blobdiff - src/support/filetools.cpp
add debug function which prints the callstack to stderr, disabled by default
[lyx.git] / src / support / filetools.cpp
index bc100c090c777e8cd1371947b519930aab5fee02..d31926556dea3b826f83b5fd41a83af1418b5bea 100644 (file)
@@ -21,6 +21,8 @@
 
 #include <config.h>
 
+#include "LyXRC.h"
+
 #include "support/filetools.h"
 
 #include "support/debug.h"
@@ -307,6 +309,21 @@ FileName const i18nLibFileSearch(string const & dir, string const & name,
 }
 
 
+FileName const imageLibFileSearch(string & dir, string const & name,
+                 string const & ext)
+{
+       if (!lyx::lyxrc.icon_set.empty()) {
+               string const imagedir = addPath(dir, lyx::lyxrc.icon_set);
+               FileName const fn = libFileSearch(imagedir, name, ext);
+               if (fn.exists()) {
+                       dir = imagedir;
+                       return fn;
+               }
+       }
+       return libFileSearch(dir, name, ext);
+}
+
+
 string const libScriptSearch(string const & command_in, quote_style style)
 {
        static string const token_scriptpath = "$$s/";
@@ -546,24 +563,15 @@ string const replaceEnvironmentPath(string const & path)
 
        static regex envvar_br_re("(.*)" + envvar_br + "(.*)");
        static regex envvar_re("(.*)" + envvar + "(.*)");
-       smatch what;
-       string result;
-       string remaining = path;
+       string result = path;
        while (1) {
-               regex_match(remaining, what, envvar_br_re);
-               if (!what[0].matched) {
-                       regex_match(remaining, what, envvar_re);
-                       if (!what[0].matched) {
-                               result += remaining;
+               smatch what;
+               if (!regex_match(result, what, envvar_br_re)) {
+                       if (!regex_match(result, what, envvar_re))
                                break;
-                       }
                }
                string env_var = getEnv(what.str(2));
-               if (!env_var.empty())
-                       result += what.str(1) + env_var;
-               else
-                       result += what.str(1) + "$" + what.str(2);
-               remaining = what.str(3);
+               result = what.str(1) + env_var + what.str(3);
        }
        return result;
 }
@@ -997,7 +1005,7 @@ bool prefs2prefs(FileName const & filename, FileName const & tempfile, bool lfun
 
        cmd_ret const ret = runCommand(command_str);
        if (ret.first != 0) {
-               LYXERR0("Could not run bind file conversion script prefs2prefs.py.");
+               LYXERR0("Could not run file conversion script prefs2prefs.py.");
                return false;
        }
        return true;