mirror of
https://github.com/NixOS/nix
synced 2025-06-25 10:41:16 +02:00
Deduplicate string literal rendering, fix 4909
This commit is contained in:
parent
8f0ec323ea
commit
4e0804c920
7 changed files with 86 additions and 39 deletions
|
@ -9,6 +9,7 @@
|
|||
#include "filetransfer.hh"
|
||||
#include "function-trace.hh"
|
||||
#include "profiles.hh"
|
||||
#include "value/print.hh"
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
|
@ -104,18 +105,10 @@ void Value::print(const SymbolTable & symbols, std::ostream & str,
|
|||
str << integer;
|
||||
break;
|
||||
case tBool:
|
||||
str << (boolean ? "true" : "false");
|
||||
printLiteral(str, boolean);
|
||||
break;
|
||||
case tString:
|
||||
str << "\"";
|
||||
for (const char * i = string.s; *i; i++)
|
||||
if (*i == '\"' || *i == '\\') str << "\\" << *i;
|
||||
else if (*i == '\n') str << "\\n";
|
||||
else if (*i == '\r') str << "\\r";
|
||||
else if (*i == '\t') str << "\\t";
|
||||
else if (*i == '$' && *(i+1) == '{') str << "\\" << *i;
|
||||
else str << *i;
|
||||
str << "\"";
|
||||
printLiteral(str, string.s);
|
||||
break;
|
||||
case tPath:
|
||||
str << path; // !!! escaping?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue