Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
Co-authored-by: John Ericson <git@JohnEricson.me>
This commit is contained in:
Robert Hensing 2023-04-15 20:56:51 +02:00 committed by GitHub
parent 4e0804c920
commit 9c74df5bb4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -3,7 +3,8 @@
namespace nix { namespace nix {
std::ostream & std::ostream &
printLiteral(std::ostream & str, const std::string_view string) { printLiteral(std::ostream & str, const std::string_view string)
{
str << "\""; str << "\"";
for (auto i = string.begin(); i != string.end(); ++i) { for (auto i = string.begin(); i != string.end(); ++i) {
if (*i == '\"' || *i == '\\') str << "\\" << *i; if (*i == '\"' || *i == '\\') str << "\\" << *i;
@ -18,7 +19,8 @@ printLiteral(std::ostream & str, const std::string_view string) {
} }
std::ostream & std::ostream &
printLiteral(std::ostream & str, bool boolean) { printLiteral(std::ostream & str, bool boolean)
{
str << (boolean ? "true" : "false"); str << (boolean ? "true" : "false");
return str; return str;
} }

View file

@ -314,7 +314,7 @@ Derivation parseDerivation(const Store & store, std::string && s, std::string_vi
/** /**
* Print a derivation string literal to an std::string. * Print a derivation string literal to an `std::string`.
* *
* This syntax does not generalize to the expression language, which needs to * This syntax does not generalize to the expression language, which needs to
* escape `$`. * escape `$`.