aboutsummaryrefslogtreecommitdiff
path: root/build2/variable.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-06-20 09:51:56 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-06-20 09:51:56 +0200
commit353438a94953bf4d093af0d84decd5ec7529ed34 (patch)
tree4c4e376ff8d831e85954a9b74f2157ad4b06351a /build2/variable.cxx
parentc6b3f6659eda9b0b255ddc2d24accdd998b5938d (diff)
Add $process.run() and $process.run_regex() functions
$process.run(<prog>[ <args>...]) Return trimmed stdout. $process.run_regex(<prog>[ <args>...], <pat> [, <fmt>]) Return stdout lines matched and optionally processed with regex. Each line of stdout (including the customary trailing blank) is matched (as a whole) against <pat> and, if successful, returned, optionally processed with <fmt>, as an element of a list.
Diffstat (limited to 'build2/variable.cxx')
-rw-r--r--build2/variable.cxx34
1 files changed, 33 insertions, 1 deletions
diff --git a/build2/variable.cxx b/build2/variable.cxx
index 8000913..0c07db6 100644
--- a/build2/variable.cxx
+++ b/build2/variable.cxx
@@ -600,7 +600,20 @@ namespace build2
catch (invalid_path& e)
{
n.value = move (e.path); // Restore the name object for diagnostics.
+ // Fall through.
+ }
+ }
+ // Reassemble split dir/value.
+ //
+ if (n.untyped () && n.unqualified ())
+ {
+ try
+ {
+ return n.dir / n.value;
+ }
+ catch (const invalid_path&)
+ {
// Fall through.
}
}
@@ -649,7 +662,26 @@ namespace build2
{
return dir_path (move (n.value));
}
- catch (const invalid_path&) {} // Fall through.
+ catch (invalid_path& e)
+ {
+ n.value = move (e.path); // Restore the name object for diagnostics.
+ // Fall through.
+ }
+ }
+
+ // Reassemble split dir/value.
+ //
+ if (n.untyped () && n.unqualified ())
+ {
+ try
+ {
+ n.dir /= n.value;
+ return move (n.dir);
+ }
+ catch (const invalid_path&)
+ {
+ // Fall through.
+ }
}
// Fall through.