aboutsummaryrefslogtreecommitdiff
path: root/src/stdlib/print.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-04-14 16:39:35 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-04-14 16:39:35 -0400
commitc3cec08ce94b25eb19588d333c738a24e96abac4 (patch)
tree4004b4a6fdaaec28fe8277e064b1dccda14da66a /src/stdlib/print.c
parent7bd8304557b7781f321f8e35da299e5417eadd04 (diff)
Further fixes for printing quoted strings/chars
Diffstat (limited to 'src/stdlib/print.c')
-rw-r--r--src/stdlib/print.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/stdlib/print.c b/src/stdlib/print.c
index 76a770bc..aeb71fae 100644
--- a/src/stdlib/print.c
+++ b/src/stdlib/print.c
@@ -11,7 +11,8 @@ public int _print_char(FILE *f, char c)
#else
#define ESC(e) "'\\" e "'"
#endif
- const char *named[256] = {['\n']=ESC("n"), ['\t']=ESC("t"), ['\r']=ESC("r"),
+ const char *named[256] = {['\'']=ESC("'"), ['\\']=ESC("\\"),
+ ['\n']=ESC("n"), ['\t']=ESC("t"), ['\r']=ESC("r"),
['\033']=ESC("e"), ['\v']=ESC("v"), ['\a']=ESC("a"), ['\b']=ESC("b")};
const char *name = named[(uint8_t)c];
if (name != NULL)
@@ -34,7 +35,8 @@ public int _print_quoted(FILE *f, quoted_t quoted)
#else
#define ESC(e) "\\" e
#endif
- const char *named[256] = {['"']=ESC("\""), ['\n']=ESC("n"), ['\t']=ESC("t"), ['\r']=ESC("r"),
+ const char *named[256] = {['"']=ESC("\""), ['\\']=ESC("\\"),
+ ['\n']=ESC("n"), ['\t']=ESC("t"), ['\r']=ESC("r"),
['\033']=ESC("e"), ['\v']=ESC("v"), ['\a']=ESC("a"), ['\b']=ESC("b")};
int printed =
#if PRINT_COLOR