diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2021-02-16 15:38:59 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2021-02-16 15:38:59 -0500 |
commit | 4b8db533619ee8eef64ded0793f413faaa7609c2 (patch) | |
tree | 8b3f158897ae2ff2f3e8f78ad0712bc4b40b328f /build.c | |
parent | 824c4ff4be5a0bf55b6644fed06fcfe2248c4301 (diff) |
detecting errors in build output
Diffstat (limited to 'build.c')
-rw-r--r-- | build.c | 60 |
1 files changed, 60 insertions, 0 deletions
@@ -1,4 +1,5 @@ static void build_start(Ted *ted) { + chdir(ted->cwd); #if __unix__ char *program = "/bin/sh"; char *argv[] = { @@ -19,6 +20,9 @@ static void build_start(Ted *ted) { static void build_stop(Ted *ted) { if (ted->building) process_kill(&ted->build_process); + arr_foreach_ptr(ted->build_errors, BuildError, err) { + free(err->filename); + } ted->building = false; ted->build_shown = false; } @@ -89,6 +93,62 @@ static void build_frame(Ted *ted, float x1, float y1, float x2, float y2) { } else { buffer_insert_utf8_at_cursor(buffer, message); ted->building = false; + + // check for errors + for (u32 line_idx = 0; line_idx < buffer->nlines; ++line_idx) { + Line *line = &buffer->lines[line_idx]; + if (line->len < 3) { + continue; + } + bool is_error = true; + u32 i = 0; + char32_t *str = line->str; u32 len = line->len; + + // we have something like main.c:5 + + // get file name + while (i < len) { + if (str[i] == ':') break; + if (!is32_alnum(str[i]) && str[i] != '/' && str[i] != '.' && str[i] != '\\') { + is_error = false; + break; + } + ++i; + } + if (i >= len) is_error = false; + + if (is_error) { + u32 filename_len = i; + u32 line_number_len = 0; + ++i; + while (i < len) { + if (str[i] == ':') break; + if (str[i] < '0' || str[i] > '9') { + is_error = false; + break; + } + ++i; + ++line_number_len; + } + if (i >= len) is_error = false; + if (line_number_len == 0) is_error = false; + + if (is_error) { + char *line_number_str = str32_to_utf8_cstr(str32(str + filename_len + 1, line_number_len)); + if (line_number_str) { + int line_number = atoi(line_number_str); + free(line_number_str); + + char *filename = str32_to_utf8_cstr(str32(str, filename_len)); + if (filename) { + char full_path[TED_PATH_MAX]; + ted_full_path(ted, filename, full_path, sizeof full_path); + printf("File %s line %d\n",full_path,line_number); + } + } + } + } + } } buffer->view_only = true; } |