mirror of
https://github.com/ksherlock/mpw.git
synced 2025-02-19 17:30:32 +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;
|
machine variables;
|
||||||
|
|
||||||
|
coalesce_colon := |*
|
||||||
|
|
||||||
|
':' {
|
||||||
|
if (rv.length() && rv.back() != ':')
|
||||||
|
rv.push_back(':');
|
||||||
|
|
||||||
|
fgoto main;
|
||||||
|
};
|
||||||
|
any {
|
||||||
|
fhold;
|
||||||
|
fgoto main;
|
||||||
|
};
|
||||||
|
*|;
|
||||||
|
|
||||||
main := |*
|
main := |*
|
||||||
|
|
||||||
'{' [A-Za-z0-9_]+ '}' {
|
'{' [A-Za-z0-9_]+ '}' {
|
||||||
@ -90,15 +104,23 @@ namespace {
|
|||||||
auto iter = Environment.find(name);
|
auto iter = Environment.find(name);
|
||||||
if (iter != Environment.end())
|
if (iter != Environment.end())
|
||||||
rv.append(iter->second);
|
rv.append(iter->second);
|
||||||
|
|
||||||
|
fgoto coalesce_colon;
|
||||||
};
|
};
|
||||||
|
|
||||||
# backwards compatibility.
|
# backwards compatibility.
|
||||||
'${' [A-Za-z0-9_]+ '}' {
|
'${' [A-Za-z0-9_]+ '}' {
|
||||||
|
|
||||||
std::string name(ts + 2, te - 1);
|
if (pathname) {
|
||||||
auto iter = Environment.find(name);
|
rv.append(ts, te);
|
||||||
if (iter != Environment.end())
|
} else {
|
||||||
rv.append(iter->second);
|
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.
|
# backwards compatibility.
|
||||||
@ -112,6 +134,8 @@ namespace {
|
|||||||
auto iter = Environment.find(name);
|
auto iter = Environment.find(name);
|
||||||
if (iter != Environment.end())
|
if (iter != Environment.end())
|
||||||
rv.append(iter->second);
|
rv.append(iter->second);
|
||||||
|
|
||||||
|
fgoto coalesce_colon;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4,7 +4,10 @@
|
|||||||
# $MPW uses MacOS : paths.
|
# $MPW uses MacOS : paths.
|
||||||
#
|
#
|
||||||
# $MPW includes the trailing ':'.
|
# $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)
|
# = assigns (replacing any existing value)
|
||||||
# ?= will not replace an existing value.
|
# ?= will not replace an existing value.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user