From 4168cda2363f3d796d0b9922852e249aac3131ba Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 4 Dec 2020 08:39:35 +0200 Subject: Mark Buildfile functions as pure or impure --- libbuild2/functions-process.cxx | 65 ++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 30 deletions(-) (limited to 'libbuild2/functions-process.cxx') diff --git a/libbuild2/functions-process.cxx b/libbuild2/functions-process.cxx index 73ca916..0870874 100644 --- a/libbuild2/functions-process.cxx +++ b/libbuild2/functions-process.cxx @@ -414,12 +414,14 @@ namespace build2 // // Run builtin or external program and return trimmed stdout. // - f[".run"] = [](const scope* s, names args) + // Note that this function is not pure. + // + f.insert (".run", false) += [](const scope* s, names args) { return run (s, move (args)); }; - f["run"] = [](const scope* s, process_path pp) + f.insert ("run", false) += [](const scope* s, process_path pp) { return run_process (s, pp, strings ()); }; @@ -433,38 +435,41 @@ namespace build2 // (as a whole) against and, if successful, returned, optionally // processed with , as an element of a list. // - f[".run_regex"] = [](const scope* s, names a, string p, optional f) + // Note that this function is not pure. + // { - return run_regex (s, move (a), p, f); - }; + auto e (f.insert (".run_regex", false)); - f[".run_regex"] = [] (const scope* s, names a, names p, optional f) - { - return run_regex (s, - move (a), - convert (move (p)), - f ? convert (move (*f)) : nullopt_string); - }; + e += [](const scope* s, names a, string p, optional f) + { + return run_regex (s, move (a), p, f); + }; - f["run_regex"] = [](const scope* s, - process_path pp, - string p, - optional f) + e += [] (const scope* s, names a, names p, optional f) + { + return run_regex (s, + move (a), + convert (move (p)), + f ? convert (move (*f)) : nullopt_string); + }; + } { - return run_process_regex (s, pp, strings (), p, f); - }; + auto e (f.insert ("run_regex", false)); - f["run_regex"] = [](const scope* s, - process_path pp, - names p, - optional f) - { - return run_process_regex (s, - pp, strings (), - convert (move (p)), - (f - ? convert (move (*f)) - : nullopt_string)); - }; + e += [](const scope* s, process_path pp, string p, optional f) + { + return run_process_regex (s, pp, strings (), p, f); + }; + + e += [](const scope* s, process_path pp, names p, optional f) + { + return run_process_regex (s, + pp, strings (), + convert (move (p)), + (f + ? convert (move (*f)) + : nullopt_string)); + }; + } } } -- cgit v1.1