From 7c047df78502d53411fef09c6e39540d2b7e796a Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Tue, 27 Apr 2021 16:24:24 +0200 Subject: Fixed some overflows and enabled live parsing --- src/warnings.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/warnings.c') diff --git a/src/warnings.c b/src/warnings.c index da8d11b..47566ba 100644 --- a/src/warnings.c +++ b/src/warnings.c @@ -33,14 +33,20 @@ void warnings_add(struct context *ctx, const char *fmt, ...) warning_index++; } -static void warnings_generate_name(u32 i) { +static void warnings_generate_name(u32 i) +{ static u32 ctr = 0; snprintf(warnings[i].name, 8, "%d", ctr++); } +void warnings_remove_marks(void) +{ + gui_remove_line_marker("warning"); +} + void warnings_print(void) { - gui_remove_line_marker("error"); + warnings_remove_marks(); for (u32 i = 0; i < WARNING_COUNT; i++) { if (!warnings[i].exists) continue; @@ -48,8 +54,8 @@ void warnings_print(void) printf("Line %d:%d: %s\n", warnings[i].ctx.line, warnings[i].ctx.column, warnings[i].text); warnings_generate_name(i); - gui_add_line_marker(warnings[i].ctx.line - 1, warnings[i].name, warnings[i].text, "error", - "dialog-warning", (GdkRGBA){ 1, 0, 0, .3 }); + gui_add_line_marker(warnings[i].ctx.line - 1, warnings[i].text, warnings[i].name, + "warning", "dialog-warning", (GdkRGBA){ 1, 0, 0, .3 }); } } @@ -60,6 +66,8 @@ u8 warnings_exist(void) void warnings_clear(void) { - if (warning_index) + if (warnings_exist()) { memset(warnings, 0, sizeof(warnings)); + warning_index = 0; + } } -- cgit v1.2.3