From 882583f64e517ab232edb6bbb7433631c655c9da Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 7 Nov 2019 11:12:43 +0200 Subject: Initial work on path_name use for `-` to stdin/stdout translation --- libbuild2/config/functions.cxx | 5 ++++- libbuild2/config/init.cxx | 5 ++++- libbuild2/config/operation.cxx | 33 +++++++++++++++++---------------- libbuild2/config/operation.hxx | 2 +- libbuild2/config/utility.cxx | 6 +++--- 5 files changed, 29 insertions(+), 22 deletions(-) (limited to 'libbuild2/config') diff --git a/libbuild2/config/functions.cxx b/libbuild2/config/functions.cxx index 79447a4..b6ccb74 100644 --- a/libbuild2/config/functions.cxx +++ b/libbuild2/config/functions.cxx @@ -43,7 +43,10 @@ namespace build2 // Empty project set should is ok as long as inherit is false. // project_set ps; - save_config (*s, os, "config.export()", false /* inherit */, ps); + save_config (*s, + os, path_name ("config.export()"), + false /* inherit */, + ps); return os.str (); }; diff --git a/libbuild2/config/init.cxx b/libbuild2/config/init.cxx index 2d4ed20..890efa3 100644 --- a/libbuild2/config/init.cxx +++ b/libbuild2/config/init.cxx @@ -169,8 +169,11 @@ namespace build2 auto load_config_file = [&load_config] (const path& f, const location& l) { + // @@ PATH_NAME TODO + // + path_name fn (f); ifdstream ifs; - load_config (open_file_or_stdin (f, ifs), f, l); + load_config (open_file_or_stdin (fn, ifs), f /* fn */, l); }; { diff --git a/libbuild2/config/operation.cxx b/libbuild2/config/operation.cxx index c9b5ef6..14576a0 100644 --- a/libbuild2/config/operation.cxx +++ b/libbuild2/config/operation.cxx @@ -50,7 +50,7 @@ namespace build2 } catch (const io_error& e) { - fail << "unable to write " << f << ": " << e; + fail << "unable to write to " << f << ": " << e; } } @@ -79,7 +79,7 @@ namespace build2 } catch (const io_error& e) { - fail << "unable to write " << f << ": " << e; + fail << "unable to write to " << f << ": " << e; } } @@ -90,8 +90,7 @@ namespace build2 // void save_config (const scope& rs, - ostream& os, - const string& name, + ostream& os, const path_name& on, bool inherit, const project_set& projects) { @@ -100,8 +99,8 @@ namespace build2 const module* mod (rs.lookup_module (module::name)); if (mod == nullptr) - fail << "no configuration information available during this meta-" - << "operation"; + fail (on) << "no configuration information available during this " + << "meta-operation"; try { @@ -231,8 +230,8 @@ namespace build2 // then something is broken. // if (r == nullptr) - fail << name << ": inherited variable " << var << " value " - << "is not from a root scope"; + fail (on) << "inherited variable " << var << " value is not " + << "from a root scope"; // If none of the outer project's configurations use this // value, then we warn (unless we couldn't check) and save as @@ -242,8 +241,8 @@ namespace build2 if (checked && org.first == ovr.first) { diag_record dr; - dr << warn << name << ": saving previously inherited " - << "variable " << var; + dr << warn (on) << "saving previously inherited variable " + << var; dr << info << "because project " << *r << " no longer uses " << "it in its configuration"; @@ -321,7 +320,7 @@ namespace build2 } catch (const io_error& e) { - fail << "unable to write " << name << ": " << e; + fail << "unable to write to " << on << ": " << e; } } @@ -331,21 +330,23 @@ namespace build2 bool inherit, const project_set& projects) { - const string& fs (f.string () != "-" ? f.string () : ""); + path_name fn (f); + + if (f.string () == "-") + fn.name = ""; if (verb) - text << (verb >= 2 ? "cat >" : "save ") << fs; + text << (verb >= 2 ? "cat >" : "save ") << fn; try { ofdstream ofs; - ostream& os (); - save_config (rs, open_file_or_stdout (f, ofs), fs, inherit, projects); + save_config (rs, open_file_or_stdout (fn, ofs), fn, inherit, projects); ofs.close (); } catch (const io_error& e) { - fail << "unable to write " << fs << ": " << e; + fail << "unable to write to " << fn << ": " << e; } } diff --git a/libbuild2/config/operation.hxx b/libbuild2/config/operation.hxx index 9ec854a..1b4a452 100644 --- a/libbuild2/config/operation.hxx +++ b/libbuild2/config/operation.hxx @@ -36,7 +36,7 @@ namespace build2 // void save_config (const scope& rs, - ostream&, const string& name, + ostream&, const path_name&, bool inherit, const project_set&); } diff --git a/libbuild2/config/utility.cxx b/libbuild2/config/utility.cxx index 8a99a8b..56c1f79 100644 --- a/libbuild2/config/utility.cxx +++ b/libbuild2/config/utility.cxx @@ -215,7 +215,7 @@ namespace build2 } catch (const io_error& e) { - fail << "unable to write " << f << ": " << e; + fail << "unable to write to " << f << ": " << e; } } @@ -263,7 +263,7 @@ namespace build2 } catch (const io_error& e) { - fail << "unable to write " << f << ": " << e; + fail << "unable to write to " << f << ": " << e; } } @@ -287,7 +287,7 @@ namespace build2 } catch (const io_error& e) { - fail << "unable to write " << f << ": " << e; + fail << "unable to write to " << f << ": " << e; } } } -- cgit v1.1