diff options
-rw-r--r-- | build2/name | 12 | ||||
-rw-r--r-- | build2/name.cxx | 7 |
2 files changed, 13 insertions, 6 deletions
diff --git a/build2/name b/build2/name index 4e514c5..12aa9dc 100644 --- a/build2/name +++ b/build2/name @@ -113,12 +113,14 @@ namespace build2 // // \$(" // + // Note that in the quoted mode empty unqualified name is printed as '', + // not {}. + // ostream& - to_stream (ostream&, const name&, bool quote, char pair); + to_stream (ostream&, const name&, bool quote, char pair = '\0'); inline ostream& - operator<< (ostream& os, const name& n) { - return to_stream (os, n, false, '\0');} + operator<< (ostream& os, const name& n) {return to_stream (os, n, false);} // Vector of names. @@ -129,11 +131,11 @@ namespace build2 // The same semantics as to_stream(name). // ostream& - to_stream (ostream&, const names_view&, bool quote, char pair); + to_stream (ostream&, const names_view&, bool quote, char pair = '\0'); inline ostream& operator<< (ostream& os, const names_view& ns) { - return to_stream (os, ns, false, '\0');} + return to_stream (os, ns, false);} inline ostream& operator<< (ostream& os, const names& ns) {return os << names_view (ns);} diff --git a/build2/name.cxx b/build2/name.cxx index de1ee51..5f6762d 100644 --- a/build2/name.cxx +++ b/build2/name.cxx @@ -62,6 +62,11 @@ namespace build2 os << d; }; + // If quoted then print empty name as '' rather than {}. + // + if (quote && n.empty () && n.proj == nullptr) + return os << "''"; + if (n.proj != nullptr) { write_string (*n.proj); @@ -70,7 +75,7 @@ namespace build2 // If the value is empty, then we want to print the directory // inside {}, e.g., dir{bar/}, not bar/dir{}. We also want to - // print {} for an empty name. + // print {} for an empty name (unless quoted). // bool d (!n.dir.empty ()); bool v (!n.value.empty ()); |