From 0e0842330d1ef11f9ac6fa70d9f84bdb16084c45 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 18 Oct 2019 15:20:49 +0200 Subject: Add $quote() function for quoting values This can be useful if we want to pass a value on the command line, for example, in a testscript: $* config.cxx=$quote($recall($cxx.path) $cxx.mode, true) --- libbuild2/name.hxx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'libbuild2/name.hxx') diff --git a/libbuild2/name.hxx b/libbuild2/name.hxx index 1ce073a..738645d 100644 --- a/libbuild2/name.hxx +++ b/libbuild2/name.hxx @@ -129,11 +129,19 @@ namespace build2 // // \$(" // + // If escape is true, then escape (with a backslash) the quote characters + // being added (this is useful if the result will be re-parsed, for example + // as a Testscript command line). + // // Note that in the quoted mode empty unqualified name is printed as '', // not {}. // LIBBUILD2_SYMEXPORT ostream& - to_stream (ostream&, const name&, bool quote, char pair = '\0'); + to_stream (ostream&, + const name&, + bool quote, + char pair = '\0', + bool escape = false); inline ostream& operator<< (ostream& os, const name& n) {return to_stream (os, n, false);} @@ -153,7 +161,11 @@ namespace build2 // The same semantics as to_stream(name). // LIBBUILD2_SYMEXPORT ostream& - to_stream (ostream&, const names_view&, bool quote, char pair = '\0'); + to_stream (ostream&, + const names_view&, + bool quote, + char pair = '\0', + bool escape = false); inline ostream& operator<< (ostream& os, const names_view& ns) { -- cgit v1.1