don't expand $[a-z]+ in filenames. This was preventing lcc from working properly as it created temporary files named $defout$, etc.

This commit is contained in:
Kelvin Sherlock 2014-12-04 16:42:49 -05:00
parent abe8b9236b
commit fed6e9b172
3 changed files with 14 additions and 8 deletions

View File

@ -34,7 +34,7 @@ namespace MPW
{
extern std::unordered_map<std::string, std::string> Environment;
std::string ExpandVariables(const std::string &s);
std::string ExpandVariables(const std::string &s, bool pathname = false);
}
namespace {
@ -102,11 +102,17 @@ namespace {
};
# backwards compatibility.
# lcc generates temporary files named $xxx$
# so don't replace in pathnames.
'$' [A-Za-z0-9_]+ {
std::string name(ts + 1, te);
auto iter = Environment.find(name);
if (iter != Environment.end())
rv.append(iter->second);
if (pathname) {
rv.append(ts, te);
} else {
std::string name(ts + 1, te);
auto iter = Environment.find(name);
if (iter != Environment.end())
rv.append(iter->second);
}
};
any {
@ -215,7 +221,7 @@ namespace MPW {
return iter->second;
}
std::string ExpandVariables(const std::string &s)
std::string ExpandVariables(const std::string &s, bool pathname)
{
if (s.find_first_of("{$") == s.npos) return s;

View File

@ -97,7 +97,7 @@ namespace MPW {
std::string RootDirPathForFile(const std::string &file);
std::string GetEnv(const std::string &);
std::string ExpandVariables(const std::string &s);
std::string ExpandVariables(const std::string &s, bool pathname = false);
// should add argc/argv/envp...

View File

@ -127,7 +127,7 @@ namespace ToolBox
#ifndef TESTING
if (path.find_first_of("${") != path.npos)
{
path = MPW::ExpandVariables(path);
path = MPW::ExpandVariables(path, true);
}
#endif