mirror of
https://github.com/ksherlock/mpw.git
synced 2025-01-21 15:30:12 +00:00
Smarter handling of : after a variable.
Since :: is equivalent to .. in Unix, {$PathVariable}: would expand unexpectedly if PathVariable had a trailing : (which it usually does) -- i.e., some:path:: == /some/path/.. = /some/. : after a variable will be dropped if there was already a trailing :
This commit is contained in:
parent
9fda034e0e
commit
42fe265dd2
@ -82,6 +82,20 @@ namespace {
|
||||
%%{
|
||||
machine variables;
|
||||
|
||||
coalesce_colon := |*
|
||||
|
||||
':' {
|
||||
if (rv.length() && rv.back() != ':')
|
||||
rv.push_back(':');
|
||||
|
||||
fgoto main;
|
||||
};
|
||||
any {
|
||||
fhold;
|
||||
fgoto main;
|
||||
};
|
||||
*|;
|
||||
|
||||
main := |*
|
||||
|
||||
'{' [A-Za-z0-9_]+ '}' {
|
||||
@ -90,15 +104,23 @@ namespace {
|
||||
auto iter = Environment.find(name);
|
||||
if (iter != Environment.end())
|
||||
rv.append(iter->second);
|
||||
|
||||
fgoto coalesce_colon;
|
||||
};
|
||||
|
||||
# backwards compatibility.
|
||||
'${' [A-Za-z0-9_]+ '}' {
|
||||
|
||||
std::string name(ts + 2, te - 1);
|
||||
auto iter = Environment.find(name);
|
||||
if (iter != Environment.end())
|
||||
rv.append(iter->second);
|
||||
if (pathname) {
|
||||
rv.append(ts, te);
|
||||
} else {
|
||||
std::string name(ts + 2, te - 1);
|
||||
auto iter = Environment.find(name);
|
||||
if (iter != Environment.end())
|
||||
rv.append(iter->second);
|
||||
|
||||
fgoto coalesce_colon;
|
||||
}
|
||||
};
|
||||
|
||||
# backwards compatibility.
|
||||
@ -112,6 +134,8 @@ namespace {
|
||||
auto iter = Environment.find(name);
|
||||
if (iter != Environment.end())
|
||||
rv.append(iter->second);
|
||||
|
||||
fgoto coalesce_colon;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -4,7 +4,10 @@
|
||||
# $MPW uses MacOS : paths.
|
||||
#
|
||||
# $MPW includes the trailing ':'.
|
||||
#Be mindful of this since '::' is equivalent to '..' in Unix.
|
||||
# Since '::' is equivalent to '..' in Unix,
|
||||
# A ':'' after a variable (eg, ${MPW}:)
|
||||
# will be dropped if it's duplicative.
|
||||
#
|
||||
#
|
||||
# = assigns (replacing any existing value)
|
||||
# ?= will not replace an existing value.
|
||||
|
Loading…
x
Reference in New Issue
Block a user