"templates");
}
+ // init LyXDir environment variable
+ string const lyx_dir = package().lyx_dir().absFileName();
+ LYXERR(Debug::INIT, "Setting LyXDir... to \"" << lyx_dir << "\"");
+ if (!setEnv("LyXDir", lyx_dir))
+ LYXERR(Debug::INIT, "\t... failed!");
+
//
// Read configuration files
//
prependEnvPath("PATH", package().binary_dir().absFileName());
#endif
if (!lyxrc.path_prefix.empty())
- prependEnvPath("PATH", lyxrc.path_prefix);
+ prependEnvPath("PATH", replaceEnvironmentPath(lyxrc.path_prefix));
// Check that user LyX directory is ok.
if (queryUserLyXDir(package().explicit_user_support()))
os::windows_style_tex_paths(lyxrc.windows_style_tex_paths);
if (!lyxrc.path_prefix.empty())
- prependEnvPath("PATH", lyxrc.path_prefix);
+ prependEnvPath("PATH", replaceEnvironmentPath(lyxrc.path_prefix));
FileName const document_path(lyxrc.document_path);
if (document_path.exists() && document_path.isDirectory())
FileName const abs_binary = abs_path_from_binary_name(command_line_arg0);
binary_dir_ = FileName(onlyPath(abs_binary.absFileName()));
+ // the LyX package directory
+ lyx_dir_ = FileName(addPath(binary_dir_.absFileName(), "../"));
+ lyx_dir_ = FileName(lyx_dir_.realPath());
+
// Is LyX being run in-place from the build tree?
buildDirs(abs_binary, top_build_dir_location,
build_support_dir_, system_support_dir_);
*/
FileName const & lyx_binary() const { return lyx_binary_; }
+ /** The absolute path to the LyX package directory.
+ * This is one level up from the binary dir.
+ */
+ FileName const & lyx_dir() const { return lyx_dir_; }
+
/** The top of the LyX source code tree.
*/
static FileName const & top_srcdir();
private:
FileName binary_dir_;
FileName lyx_binary_;
+ FileName lyx_dir_;
FileName system_support_dir_;
FileName build_support_dir_;
FileName user_support_dir_;
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);
+ regex_match(result, what, envvar_br_re);
if (!what[0].matched) {
- regex_match(remaining, what, envvar_re);
+ regex_match(result, what, envvar_re);
if (!what[0].matched) {
- result += remaining;
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;
}