From 2d257de986208b840bbf814da2be9b7f3e056332 Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Sat, 18 Jul 2009 09:19:04 +0000 Subject: [PATCH] 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 --- src/support/filetools.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/support/filetools.cpp b/src/support/filetools.cpp index ef2b510fbe..3eae80d8a2 100644 --- a/src/support/filetools.cpp +++ b/src/support/filetools.cpp @@ -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; }