From d8a045c91469b1d121b8fd14dffaa367b194831d Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sun, 6 Sep 2026 21:46:52 -1000 Subject: Clean up the whole tree --- source/ui-ssdiff.c | 52 ++++++++++++++++++---------------------------------- 1 file changed, 18 insertions(+), 34 deletions(-) (limited to 'source/ui-ssdiff.c') diff --git a/source/ui-ssdiff.c b/source/ui-ssdiff.c index 759a77b..2ea4751 100644 --- a/source/ui-ssdiff.c +++ b/source/ui-ssdiff.c @@ -53,8 +53,7 @@ static void create_lcs_table(void) * owns. A line too long for the table gets NULL back and is shown whole * instead. */ -static char *longest_common_subsequence(const char *old_line, - const char *new_line) +static char *longest_common_subsequence(const char *old_line, const char *new_line) { int old_len = strlen(old_line); int new_len = strlen(new_line); @@ -76,8 +75,7 @@ static char *longest_common_subsequence(const char *old_line, int drop_old = lcs_table[i + 1][j]; int drop_new = lcs_table[i][j + 1]; - lcs_table[i][j] = (drop_old > drop_new ? - drop_old : drop_new); + lcs_table[i][j] = (drop_old > drop_new ? drop_old : drop_new); } } } @@ -116,8 +114,7 @@ static char *expand_tabs(const char *line) for (p = line; *p; p++) { if (*p == '\t') - strbuf_addchars(&out, ' ', - TAB_WIDTH - (out.len % TAB_WIDTH)); + strbuf_addchars(&out, ' ', TAB_WIDTH - (out.len % TAB_WIDTH)); else strbuf_addch(&out, *p); } @@ -136,8 +133,7 @@ static void flush_run(struct strbuf *run) * A stretch the other side does not share is escaped in one call, so a * changed line does not go through the output path a byte at a time. */ -static void print_line_with_lcs(const char *class, const char *line, - const char *lcs) +static void print_line_with_lcs(const char *class, const char *line, const char *lcs) { int len = strlen(line); int in_common = 1; @@ -168,8 +164,7 @@ static void print_line_with_lcs(const char *class, const char *line, strbuf_release(&run); } -static void print_lineno_cell(struct diff_filespec *file, - const struct object_id *rev, int line_no) +static void print_lineno_cell(struct diff_filespec *file, const struct object_id *rev, int line_no) { struct strbuf path = STRBUF_INIT; char *anchor, *query, *fileurl; @@ -191,10 +186,8 @@ static void print_lineno_cell(struct diff_filespec *file, strbuf_release(&path); } -static void print_row(const char *class, - int old_line_no, char *old_line, - int new_line_no, char *new_line, - int highlight_chars) +static void print_row(const char *class, int old_line_no, char *old_line, + int new_line_no, char *new_line, int highlight_chars) { char *lcs = NULL; @@ -207,8 +200,7 @@ static void print_row(const char *class, lcs = longest_common_subsequence(old_line, new_line); html("\n"); if (old_line_no > 0) { - print_lineno_cell(cgit_get_current_old_file(), old_rev_oid, - old_line_no); + print_lineno_cell(cgit_get_current_old_file(), old_rev_oid, old_line_no); htmlf("", class); } else if (old_line) htmlf("", class); @@ -223,8 +215,7 @@ static void print_row(const char *class, html("\n"); if (new_line_no > 0) { - print_lineno_cell(cgit_get_current_new_file(), new_rev_oid, - new_line_no); + print_lineno_cell(cgit_get_current_new_file(), new_rev_oid, new_line_no); htmlf("", class); } else if (new_line) htmlf("", class); @@ -243,9 +234,8 @@ static void print_row(const char *class, free(old_line); } -static void defer_line(struct deferred_line **head, - struct deferred_line **last, - const char *line, int line_no) +static void defer_line(struct deferred_line **head, struct deferred_line **last, + const char *line, int line_no) { struct deferred_line *item = xmalloc(sizeof(*item)); @@ -321,15 +311,12 @@ static void print_deferred_changed_lines(void) highlight_chars = count_deferred(old_item) == count_deferred(new_item); while (old_item || new_item) { if (old_item && new_item) - print_row("changed", old_item->line_no, - old_item->line, new_item->line_no, - new_item->line, highlight_chars); + print_row("changed", old_item->line_no, old_item->line, + new_item->line_no, new_item->line, highlight_chars); else if (old_item) - print_row("changed", old_item->line_no, - old_item->line, -1, NULL, 0); + print_row("changed", old_item->line_no, old_item->line, -1, NULL, 0); else if (new_item) - print_row("changed", -1, NULL, - new_item->line_no, new_item->line, 0); + print_row("changed", -1, NULL, new_item->line_no, new_item->line, 0); if (old_item) { next = old_item->next; free_deferred(old_item); @@ -395,17 +382,14 @@ void cgit_ssdiff_line_cb(char *line, int len) if (line[0] == ' ') { print_deferred_lines(); - print_row("ctx", current_old_line, line, - current_new_line, line, 0); + print_row("ctx", current_old_line, line, current_new_line, line, 0); current_old_line += 1; current_new_line += 1; } else if (line[0] == '+') { - defer_line(&deferred_new, &deferred_new_last, line, - current_new_line); + defer_line(&deferred_new, &deferred_new_last, line, current_new_line); current_new_line += 1; } else if (line[0] == '-') { - defer_line(&deferred_old, &deferred_old_last, line, - current_old_line); + defer_line(&deferred_old, &deferred_old_last, line, current_old_line); current_old_line += 1; } else if (line[0] == '@') { html(""); -- cgit v2.8.0