diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2019-08-22 10:38:44 -0400 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2019-08-22 10:38:44 -0400 |
commit | eda9077ce320fd683f5574441749f9ed6ffbb4b2 (patch) | |
tree | 8193c9d90f894117af77f258d9a09a85ea6e5a34 /util | |
parent | d63a28aa4d227544b912b3edc2479de622d18a32 (diff) |
Started code generation
Diffstat (limited to 'util')
-rw-r--r-- | util/err.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -3,10 +3,12 @@ #if USE_COLORED_TEXT #define TEXT_ERROR(x) "\x1b[91m" x "\x1b[0m" #define TEXT_INFO(x) "\x1b[94m" x "\x1b[0m" +#define TEXT_WARN(x) "\x1b[93m" x "\x1b[0m" #define TEXT_IMPORTANT(x) "\x1b[1m" x "\x1b[0m" #else #define TEXT_ERROR(x) x #define TEXT_INFO(x) x +#define TEXT_WARN(x) x #define TEXT_IMPORTANT(x) x #endif @@ -44,6 +46,10 @@ static void info_print_header_(LineNo line) { err_fprint(TEXT_INFO("info:") " at line %lu of %s:\n", (unsigned long)line, err_filename); } +static void warn_print_header_(LineNo line) { + err_fprint(TEXT_WARN("warning:") " at line %lu of %s:\n", (unsigned long)line, err_filename); +} + static void err_print_footer_(const char *context) { err_fprint("\n\there --> "); const char *end = strchr(context, '\n'); @@ -82,6 +88,14 @@ static void info_print(Location where, const char *fmt, ...) { va_end(args); } +static void warn_print(Location where, const char *fmt, ...) { + va_list args; + va_start(args, fmt); + warn_print_header_(where.line); + err_vfprint(fmt, args); + err_print_footer_(where.code); + va_end(args); +} static void *err_malloc(size_t size) { void *ret = malloc(size); |