aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/eval.cc
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2023-04-09 22:42:20 +0200
committerRobert Hensing <robert@roberthensing.nl>2023-04-09 22:42:20 +0200
commit4e0804c920558575a4b3486df1e595445bf67555 (patch)
tree9dbeb968bb9c3d4a1bc02b49ab2ff219f8e1f065 /src/libexpr/eval.cc
parent8f0ec323ea0cb4791ca8edfe122b0d7523acfc80 (diff)
Deduplicate string literal rendering, fix 4909
Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r--src/libexpr/eval.cc13
1 files changed, 3 insertions, 10 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index 18cfd9531..06208897f 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -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?