summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Smith <whydoubt@gmail.com>2017-09-27 17:43:28 -0500
committerChristian Hesse <mail@eworm.de>2017-09-28 15:15:45 +0200
commitc19e41466ec414cc792626c9114b56a15dd17b6b (patch)
tree94e8f3a2f8f496e70ca5712a906a4e52e8c65dbc
parent1f6a28fb3b8f998cc545c982ce8625adc8bd5de9 (diff)
downloadcgit-c19e41466ec414cc792626c9114b56a15dd17b6b.tar.gz
ui-tree: move set_title_from_path to ui-shared
The ui-blame code will also need to call set_title_from_path, so go ahead and move it to ui-shared. Signed-off-by: Jeff Smith <whydoubt@gmail.com>
-rw-r--r--ui-shared.c31
-rw-r--r--ui-shared.h2
-rw-r--r--ui-tree.c31
3 files changed, 33 insertions, 31 deletions
diff --git a/ui-shared.c b/ui-shared.c
index e5c9a02..4ace20c 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -1111,3 +1111,34 @@ void cgit_print_snapshot_links(const char *repo, const char *head,
}
strbuf_release(&filename);
}
+
+void set_title_from_path(const char *path)
+{
+ 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;
+}
diff --git a/ui-shared.h b/ui-shared.h
index 87799f1..7948867 100644
--- a/ui-shared.h
+++ b/ui-shared.h
@@ -77,4 +77,6 @@ extern void cgit_print_snapshot_links(const char *repo, const char *head,
const char *hex, int snapshots);
extern void cgit_add_hidden_formfields(int incl_head, int incl_search,
const char *page);
+
+extern void set_title_from_path(const char *path);
#endif /* UI_SHARED_H */
diff --git a/ui-tree.c b/ui-tree.c
index ca24a03..12eaaf0 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -84,37 +84,6 @@ static void print_binary_buffer(char *buf, unsigned long size)
html("</table>\n");
}
-static void set_title_from_path(const char *path)
-{
- 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;
-}
-
static void print_object(const unsigned char *sha1, char *path, const char *basename, const char *rev)
{
enum object_type type;