branch: Fix bug #4177: Lyx fails to open files with a $ character in their name.

see r29587.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@30662 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2009-07-18 09:19:04 +00:00
parent aca24efb10
commit 2d257de986

View File

@ -523,16 +523,23 @@ string const replaceEnvironmentPath(string const & path)
static boost::regex envvar_br_re("(.*)" + envvar_br + "(.*)");
static boost::regex envvar_re("(.*)" + envvar + "(.*)");
boost::smatch what;
string result = path;
string result;
string remaining = path;
while (1) {
regex_match(result, what, envvar_br_re);
regex_match(remaining, what, envvar_br_re);
if (!what[0].matched) {
regex_match(result, what, envvar_re);
if (!what[0].matched)
regex_match(remaining, what, envvar_re);
if (!what[0].matched) {
result += remaining;
break;
}
}
result = what.str(1) + getEnv(what.str(2)) + what.str(3);
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);
}
return result;
}