aboutsummaryrefslogtreecommitdiff
path: root/build2/variable.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-07-28 07:17:29 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-07-28 13:53:22 +0200
commitb11aaa16d404ce7dc55de6b7338dccbf053a72bd (patch)
treebe5a63a170f9de7318e91d79c4784badb8a4488f /build2/variable.cxx
parentad7d4bd0722aa70ba634900cebf93a1b1814fed9 (diff)
Adjust to new path implementation, use to support reversibility
Diffstat (limited to 'build2/variable.cxx')
-rw-r--r--build2/variable.cxx24
1 files changed, 11 insertions, 13 deletions
diff --git a/build2/variable.cxx b/build2/variable.cxx
index 7a333bb..2d4db86 100644
--- a/build2/variable.cxx
+++ b/build2/variable.cxx
@@ -436,16 +436,13 @@ namespace build2
string s;
if (n.directory (true))
- {
- s = move (n.dir).string (); // Move string out of path.
-
- // Add / back to the end of the path unless it is already there. Note
- // that the string cannot be empty (n.directory () would have been
- // false).
+ // Use either the precise or traditional representation depending on
+ // whethe this is the original name (if it is, then this might not be
+ // a path after all; think s/foo/bar/).
//
- if (!dir_path::traits::is_separator (s[s.size () - 1]))
- s += '/';
- }
+ s = n.original
+ ? move (n.dir).representation () // Move out of path.
+ : move (n.dir).string ();
else
s.swap (n.value);
@@ -473,10 +470,10 @@ namespace build2
if (r->directory (true))
{
- s += r->dir.string ();
-
- if (!dir_path::traits::is_separator (s[s.size () - 1]))
- s += '/';
+ if (r->original)
+ s += move (r->dir).representation ();
+ else
+ s += r->dir.string ();
}
else
s += r->value;
@@ -636,6 +633,7 @@ namespace build2
if (r != nullptr)
throw invalid_argument (string ());
+ n.original = false;
return move (n);
}