aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Smith <whydoubt@gmail.com>2017-10-01 23:39:07 -0500
committerJohn Keeping <john@keeping.me.uk>2017-10-03 19:19:34 +0100
commitf6ffe40d1a2c985494e48dc2d36663ffde1e6044 (patch)
tree7fc72e55df7be47827a276a73926f8f31f4b55e2
parentui-tree: move set_title_from_path to ui-shared (diff)
downloadcgit-f6ffe40d1a2c985494e48dc2d36663ffde1e6044.tar.xz
cgit-f6ffe40d1a2c985494e48dc2d36663ffde1e6044.zip
ui-shared: make a char* parameter const
All cgit_xxx_link functions take const char* for the 'name' parameter, except for cgit_commit_link, which takes a char* and subsequently modifies the contents. Avoiding the content changes, and making it const char* will avoid the need to make copies of const char* strings being passed to cgit_commit_link. Signed-off-by: Jeff Smith <whydoubt@gmail.com> Reviewed-by: John Keeping <john@keeping.me.uk>
Diffstat (limited to '')
-rw-r--r--ui-shared.c19
-rw-r--r--ui-shared.h2
2 files changed, 9 insertions, 12 deletions
diff --git a/ui-shared.c b/ui-shared.c
index 2547e43..315dedb 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -347,18 +347,11 @@ void cgit_log_link(const char *name, const char *title, const char *class,
html("</a>");
}
-void cgit_commit_link(char *name, const char *title, const char *class,
+void cgit_commit_link(const char *name, const char *title, const char *class,
const char *head, const char *rev, const char *path)
{
char *delim;
- if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) {
- name[ctx.cfg.max_msg_len] = '\0';
- name[ctx.cfg.max_msg_len - 1] = '.';
- name[ctx.cfg.max_msg_len - 2] = '.';
- name[ctx.cfg.max_msg_len - 3] = '.';
- }
-
delim = repolink(title, class, "commit", head, path);
if (rev && ctx.qry.head && strcmp(rev, ctx.qry.head)) {
html(delim);
@@ -387,9 +380,13 @@ void cgit_commit_link(char *name, const char *title, const char *class,
html("follow=1");
}
html("'>");
- if (name[0] != '\0')
- html_txt(name);
- else
+ if (name[0] != '\0') {
+ if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) {
+ html_ntxt(name, ctx.cfg.max_msg_len - 3);
+ html("...");
+ } else
+ html_txt(name);
+ } else
html_txt("(no commit message)");
html("</a>");
}
diff --git a/ui-shared.h b/ui-shared.h
index 40f6207..2cd7ac9 100644
--- a/ui-shared.h
+++ b/ui-shared.h
@@ -30,7 +30,7 @@ extern void cgit_log_link(const char *name, const char *title,
const char *class, const char *head, const char *rev,
const char *path, int ofs, const char *grep,
const char *pattern, int showmsg, int follow);
-extern void cgit_commit_link(char *name, const char *title,
+extern void cgit_commit_link(const char *name, const char *title,
const char *class, const char *head,
const char *rev, const char *path);
extern void cgit_patch_link(const char *name, const char *title,