Yes, it is identical. I will look at extracting to ui-shared.c as you suggest.
On Sat, Sep 23, 2017 at 10:47 AM, John Keeping <[email protected]> wrote: > On Fri, Sep 22, 2017 at 10:38:43PM -0500, Jeff Smith wrote: >> Create framework for a page that will contain the 'blame' for a file >> in the repository. >> >> Signed-off-by: Jeff Smith <[email protected]> >> --- >> ui-blame.c | 160 >> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ >> ui-blame.h | 7 +++ >> 2 files changed, 167 insertions(+) >> create mode 100644 ui-blame.c >> create mode 100644 ui-blame.h >> >> diff --git a/ui-blame.c b/ui-blame.c >> new file mode 100644 >> index 0000000..901ca89 >> --- /dev/null >> +++ b/ui-blame.c >> @@ -0,0 +1,160 @@ >> +/* ui-blame.c: functions for blame output >> + * >> + * Copyright (C) 2006-2017 cgit Development Team <[email protected]> >> + * >> + * Licensed under GNU General Public License v2 >> + * (see COPYING for full license text) >> + */ >> + >> +#include "cgit.h" >> +#include "ui-blame.h" >> +#include "html.h" >> +#include "ui-shared.h" >> + >> +struct walk_tree_context { >> + char *curr_rev; >> + int match_baselen; >> + int state; >> +}; >> + >> +static void set_title_from_path(const char *path) > > This looks exactly the same as the function in ui-tree.c, so can't we > extract it to ui-shared.c? > >> +{ >> + size_t path_len, path_index, path_last_end; >> + char *new_title; >> + >> + if (!path) >> + return; >> + >> + path_len = strlen(path); >> + new_title = xmalloc(path_len + 3 + strlen(ctx.page.title) + 1); >> + new_title[0] = '\0'; >> + >> + for (path_index = path_len, path_last_end = path_len; path_index-- > >> 0;) { >> + if (path[path_index] == '/') { >> + if (path_index == path_len - 1) { >> + path_last_end = path_index - 1; >> + continue; >> + } >> + strncat(new_title, &path[path_index + 1], >> path_last_end - path_index - 1); >> + strcat(new_title, "\\"); >> + path_last_end = path_index; >> + } >> + } >> + if (path_last_end) >> + strncat(new_title, path, path_last_end); >> + >> + strcat(new_title, " - "); >> + strcat(new_title, ctx.page.title); >> + ctx.page.title = new_title; >> +} _______________________________________________ CGit mailing list [email protected] https://lists.zx2c4.com/mailman/listinfo/cgit
