aboutsummaryrefslogtreecommitdiff
path: root/src/stdlib
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-04-01 14:59:47 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-04-01 14:59:47 -0400
commit35e9feff6b551ebd239fe6aa29aacb48d389fbe9 (patch)
treed052e1d26a7a4a4c270e466fcfd6ef55c4bba26d /src/stdlib
parentfd5380625ef15a86f6b17df29302537852a02d59 (diff)
Fix accidental colorizing of print output
Diffstat (limited to 'src/stdlib')
-rw-r--r--src/stdlib/print.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/stdlib/print.c b/src/stdlib/print.c
index 4b2066b7..894fcfd0 100644
--- a/src/stdlib/print.c
+++ b/src/stdlib/print.c
@@ -36,7 +36,12 @@ int _print_quoted(FILE *f, quoted_t quoted)
#endif
const char *named[256] = {['\n']=ESC("n"), ['\t']=ESC("t"), ['\r']=ESC("r"),
['\033']=ESC("e"), ['\v']=ESC("v"), ['\a']=ESC("a"), ['\b']=ESC("b")};
- int printed = fputs("\033[35m\"", f);
+ int printed =
+#if PRINT_COLOR
+ fputs("\033[35m\"", f);
+#else
+ fputc('"', f);
+#endif
for (const char *p = quoted.str; *p; p++) {
const char *name = named[(uint8_t)*p];
if (name != NULL) {
@@ -47,7 +52,11 @@ int _print_quoted(FILE *f, quoted_t quoted)
printed += fprintf(f, ESC("x%02X"), (uint8_t)*p);
}
}
+#if PRINT_COLOR
printed += fputs("\"\033[m", f);
+#else
+ printed += fputc('"', f);
+#endif
#undef ESC
return printed;
}