]> git.cameronkatri.com Git - cgit.git/blobdiff - ui-ssdiff.c
tests: try with commit-graph
[cgit.git] / ui-ssdiff.c
index c4560330a9c265a67bc2e65a28d4617b5de74a07..af8bc9e0659bff07c1cf51733ef15b4cd37ea990 100644 (file)
@@ -117,7 +117,7 @@ static char *replace_tabs(char *line)
        int n_tabs = 0;
        int i;
        char *result;
-       int result_len;
+       size_t result_len;
 
        if (linelen == 0) {
                result = xmalloc(1);
@@ -136,10 +136,12 @@ static char *replace_tabs(char *line)
        for (;;) {
                cur_buf = strchr(prev_buf, '\t');
                if (!cur_buf) {
-                       strncat(result, prev_buf, result_len);
+                       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';
@@ -207,11 +209,13 @@ static void print_part_with_lcs(char *class, char *line, char *lcs)
                        }
                } else if (line[i] == lcs[j]) {
                        same = 1;
-                       htmlf("</span>");
+                       html("</span>");
                        j += 1;
                }
                html_txt(c);
        }
+       if (!same)
+               html("</span>");
 }
 
 static void print_ssdiff_line(char *class,
@@ -236,7 +240,7 @@ static void print_ssdiff_line(char *class,
                char *fileurl = cgit_fileurl(ctx.repo->url, "tree", old_file->path, id_str);
                html("<td class='lineno'><a href='");
                html(fileurl);
-               htmlf("' id='%s'>%s</a>", lineno_str, lineno_str + 1);
+               htmlf("'>%s</a>", lineno_str + 1);
                html("</td>");
                htmlf("<td class='%s'>", class);
                free(fileurl);
@@ -259,7 +263,7 @@ static void print_ssdiff_line(char *class,
                char *fileurl = cgit_fileurl(ctx.repo->url, "tree", new_file->path, id_str);
                html("<td class='lineno'><a href='");
                html(fileurl);
-               htmlf("' id='%s'>%s</a>", lineno_str, lineno_str + 1);
+               htmlf("'>%s</a>", lineno_str + 1);
                html("</td>");
                htmlf("<td class='%s'>", class);
                free(fileurl);
@@ -405,7 +409,7 @@ void cgit_ssdiff_header_begin(void)
 
 void cgit_ssdiff_header_end(void)
 {
-       html("</td><tr>");
+       html("</td></tr>");
 }
 
 void cgit_ssdiff_footer(void)