From 35e9feff6b551ebd239fe6aa29aacb48d389fbe9 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 1 Apr 2025 14:59:47 -0400 Subject: [PATCH] Fix accidental colorizing of print output --- src/stdlib/print.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/stdlib/print.c b/src/stdlib/print.c index 4b2066b..894fcfd 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; }