X-Git-Url: https://git.cameronkatri.com/cgit.git/blobdiff_plain/0899eb644fab415e9a3b304f53da9da50aaf91aa..adcc4f822fe11836e5f942fc1ae0f00db4eb8d5f:/ui-ssdiff.c diff --git a/ui-ssdiff.c b/ui-ssdiff.c index a3dd059..af8bc9e 100644 --- a/ui-ssdiff.c +++ b/ui-ssdiff.c @@ -117,6 +117,7 @@ static char *replace_tabs(char *line) int n_tabs = 0; int i; char *result; + size_t result_len; if (linelen == 0) { result = xmalloc(1); @@ -128,16 +129,19 @@ static char *replace_tabs(char *line) if (line[i] == '\t') n_tabs += 1; } - result = xmalloc(linelen + n_tabs * 8 + 1); + result_len = linelen + n_tabs * 8; + result = xmalloc(result_len + 1); result[0] = '\0'; for (;;) { cur_buf = strchr(prev_buf, '\t'); if (!cur_buf) { - strcat(result, prev_buf); + linelen = strlen(result); + strlcpy(&result[linelen], prev_buf, result_len - linelen + 1); break; } else { - strncat(result, prev_buf, cur_buf - prev_buf); + linelen = strlen(result); + strlcpy(&result[linelen], prev_buf, cur_buf - prev_buf + 1); linelen = strlen(result); memset(&result[linelen], ' ', 8 - (linelen % 8)); result[linelen + 8 - (linelen % 8)] = '\0'; @@ -205,11 +209,13 @@ static void print_part_with_lcs(char *class, char *line, char *lcs) } } else if (line[i] == lcs[j]) { same = 1; - htmlf(""); + html(""); j += 1; } html_txt(c); } + if (!same) + html(""); } static void print_ssdiff_line(char *class, @@ -234,7 +240,7 @@ static void print_ssdiff_line(char *class, char *fileurl = cgit_fileurl(ctx.repo->url, "tree", old_file->path, id_str); html("%s", lineno_str, lineno_str + 1); + htmlf("'>%s", lineno_str + 1); html(""); htmlf("", class); free(fileurl); @@ -257,7 +263,7 @@ static void print_ssdiff_line(char *class, char *fileurl = cgit_fileurl(ctx.repo->url, "tree", new_file->path, id_str); html("%s", lineno_str, lineno_str + 1); + htmlf("'>%s", lineno_str + 1); html(""); htmlf("", class); free(fileurl); @@ -403,7 +409,7 @@ void cgit_ssdiff_header_begin(void) void cgit_ssdiff_header_end(void) { - html(""); + html(""); } void cgit_ssdiff_footer(void)