From cef4ee8d70dc9a06fcdb8eb88cbc9ddf4827c6a8 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Fri, 16 Aug 2019 21:54:39 -0400 Subject: Finished literals; cleaned up code --- util/colored_text.c | 10 ++++++++++ util/err.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 util/colored_text.c (limited to 'util') diff --git a/util/colored_text.c b/util/colored_text.c new file mode 100644 index 0000000..836f357 --- /dev/null +++ b/util/colored_text.c @@ -0,0 +1,10 @@ + +#define USE_COLORED_TEXT 1 + +#if USE_COLORED_TEXT +#define TEXT_ERROR(x) "\x1b[91m" x "\x1b[0m" +#define TEXT_IMPORTANT(x) "\x1b[1m" x "\x1b[0m" +#else +#define TEXT_ERROR(x) x +#define TEXT_IMPORTANT(x) x +#endif diff --git a/util/err.c b/util/err.c index 89a1335..6fd2ac3 100644 --- a/util/err.c +++ b/util/err.c @@ -3,7 +3,7 @@ typedef uint32_t LineNo; static void err_print(LineNo line, LineNo col, const char *fmt, ...) { /* TODO: Color */ va_list args; - fprintf(stderr, "Error at line %lu col %lu:\n", (unsigned long)line, (unsigned long)col); + fprintf(stderr, TEXT_ERROR("error:") " at line %lu col %lu:\n", (unsigned long)line, (unsigned long)col); va_start(args, fmt); vfprintf(stderr, fmt, args); va_end(args); -- cgit v1.2.3