aboutsummaryrefslogtreecommitdiff
path: root/ui-ssdiff.c
diff refs
from: back
to: back
| flip
diff options
context:
space:
mode:
Diffstat (limited to 'ui-ssdiff.c')
-rw-r--r--ui-ssdiff.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/ui-ssdiff.c b/ui-ssdiff.c
index af8bc9e..c456033 100644
--- a/ui-ssdiff.c
+++ b/ui-ssdiff.c
@@ -117,7 +117,7 @@ static char *replace_tabs(char *line)
int n_tabs = 0;
int i;
char *result;
- size_t result_len;
+ int result_len;
if (linelen == 0) {
result = xmalloc(1);
@@ -136,12 +136,10 @@ static char *replace_tabs(char *line)
for (;;) {
cur_buf = strchr(prev_buf, '\t');
if (!cur_buf) {
- linelen = strlen(result);
- strlcpy(&result[linelen], prev_buf, result_len - linelen + 1);
+ strncat(result, prev_buf, result_len);
break;
} else {
- linelen = strlen(result);
- strlcpy(&result[linelen], prev_buf, cur_buf - prev_buf + 1);
+ strncat(result, prev_buf, cur_buf - prev_buf);
linelen = strlen(result);
memset(&result[linelen], ' ', 8 - (linelen % 8));
result[linelen + 8 - (linelen % 8)] = '\0';
@@ -209,13 +207,11 @@ static void print_part_with_lcs(char *class, char *line, char *lcs)
}
} else if (line[i] == lcs[j]) {
same = 1;
- html("</span>");
+ htmlf("</span>");
j += 1;
}
html_txt(c);
}
- if (!same)
- html("</span>");
}
static void print_ssdiff_line(char *class,
@@ -240,7 +236,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("'>%s</a>", lineno_str + 1);
+ htmlf("' id='%s'>%s</a>", lineno_str, lineno_str + 1);
html("</td>");
htmlf("<td class='%s'>", class);
free(fileurl);
@@ -263,7 +259,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("'>%s</a>", lineno_str + 1);
+ htmlf("' id='%s'>%s</a>", lineno_str, lineno_str + 1);
html("</td>");
htmlf("<td class='%s'>", class);
free(fileurl);
@@ -409,7 +405,7 @@ void cgit_ssdiff_header_begin(void)
void cgit_ssdiff_header_end(void)
{
- html("</td></tr>");
+ html("</td><tr>");
}
void cgit_ssdiff_footer(void)