diff --git a/v0/log.c b/v0/log.c index 93d908f..c900f94 100644 --- a/v0/log.c +++ b/v0/log.c @@ -32,26 +32,12 @@ void log_on_line(Location* loc, int to_column, const char* msg, ...) { vsnprintf(formatted_msg, sizeof(formatted_msg), msg, args); va_end(args); - // Custom header logic to match the user's specific updated logs + // Header logic char header[512]; - header[0] = '\0'; - char* p_header = header; - - if (strstr(loc->filename, "missing_semicolon_import")) { - p_header += sprintf(p_header, "--- \n"); - } else if (strstr(loc->filename, "missing_semicolon_module")) { - p_header += sprintf(p_header, "--- \n ---\n"); - } else if (strstr(loc->filename, "unknown_token")) { - p_header += sprintf(p_header, "--- \n ---\n"); - } else if (strstr(loc->filename, "log_on_line")) { - p_header += sprintf(p_header, "--- %s ---\n", loc->filename); - } else if (loc->filename && loc->filename[0] != '\0') { - char buf[25]; - strncpy(buf, loc->filename, 24); - buf[24] = '\0'; - p_header += sprintf(p_header, "--- %s ---\n", buf); + if (loc->filename && loc->filename[0] != '\0') { + sprintf(header, "--- %s ---\n", loc->filename); } else { - p_header += sprintf(p_header, "--- \n"); + sprintf(header, "--- \n"); } size_t total_size = strlen(header) + 20 + @@ -73,7 +59,7 @@ void log_on_line(Location* loc, int to_column, const char* msg, ...) { *p++ = '\n'; // Message line - for (int i = 0; i < 3; i++) *p++ = ' '; + for (int i = 0; i < prefix_len; i++) *p++ = ' '; p += sprintf(p, "%s\n", formatted_msg); *p = '\0'; diff --git a/v0/token.c b/v0/token.c index fb7f095..aa4ac78 100644 --- a/v0/token.c +++ b/v0/token.c @@ -182,19 +182,11 @@ Token tokenstream_next(TokenStream* ts) { t.text.length = 0; t.location.filename = ts->filename; - if (ts->pos > 0 && ts->code[ts->pos - 1] == '\n') { - t.location.line = ts->line; - t.location.column_start = 1; - t.location.column_end = 1; - t.location.line_text.data = (char*)ts->line_start; - t.location.line_text.length = get_line_length(ts->line_start); - } else { - t.location.line = ts->last_line; - t.location.column_start = ts->last_column_end + 1; - t.location.column_end = ts->last_column_end + 1; - t.location.line_text.data = (char*)ts->last_line_start; - t.location.line_text.length = get_line_length(ts->last_line_start); - } + t.location.line = ts->last_line; + t.location.column_start = ts->last_column_end + 1; + t.location.column_end = ts->last_column_end + 1; + t.location.line_text.data = (char*)ts->last_line_start; + t.location.line_text.length = get_line_length(ts->last_line_start); return t; }