aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-09-15 14:09:49 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-09-15 14:09:49 -0400
commit259c7efcf8c3808d8151d8e15f1167ad2b6f2ca7 (patch)
tree66a7963e090ca4906957a82105d83280d6fb6fc1 /stdlib
parent9cff275dc6aa90085bb2c336c4e056df0f87b186 (diff)
Make sure that escape sequences don't accidentally trigger the next
backslash to be interpreted as an escape sequence when printing quoted text
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/text.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/stdlib/text.c b/stdlib/text.c
index 39b97962..ec54a5d1 100644
--- a/stdlib/text.c
+++ b/stdlib/text.c
@@ -1044,6 +1044,13 @@ static inline Text_t _quoted(Text_t text, bool colorize, char quote_char)
case '\r': add_escaped("r"); break;
case '\t': add_escaped("t"); break;
case '\v': add_escaped("v"); break;
+ case '\\': {
+ if (just_escaped)
+ add_escaped("\\");
+ else
+ add_char('\\');
+ break;
+ }
case '$': if (quote_char == '\'') add_char('$'); else add_escaped("$"); break;
case '\x00' ... '\x06': case '\x0E' ... '\x1A':
case '\x1C' ... '\x1F': case '\x7F' ... '\x7F': {