mirror of
https://github.com/ksherlock/mpw.git
synced 2024-11-21 09:30:55 +00:00
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:
parent
abe8b9236b
commit
fed6e9b172
@ -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;
|
||||
|
||||
|
@ -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...
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user