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>
This commit is contained in:
parent
9337c7ee83
commit
f6ffe40d1a
17
ui-shared.c
17
ui-shared.c
@ -347,18 +347,11 @@ void cgit_log_link(const char *name, const char *title, const char *class,
|
|||||||
html("</a>");
|
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)
|
const char *head, const char *rev, const char *path)
|
||||||
{
|
{
|
||||||
char *delim;
|
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);
|
delim = repolink(title, class, "commit", head, path);
|
||||||
if (rev && ctx.qry.head && strcmp(rev, ctx.qry.head)) {
|
if (rev && ctx.qry.head && strcmp(rev, ctx.qry.head)) {
|
||||||
html(delim);
|
html(delim);
|
||||||
@ -387,9 +380,13 @@ void cgit_commit_link(char *name, const char *title, const char *class,
|
|||||||
html("follow=1");
|
html("follow=1");
|
||||||
}
|
}
|
||||||
html("'>");
|
html("'>");
|
||||||
if (name[0] != '\0')
|
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);
|
html_txt(name);
|
||||||
else
|
} else
|
||||||
html_txt("(no commit message)");
|
html_txt("(no commit message)");
|
||||||
html("</a>");
|
html("</a>");
|
||||||
}
|
}
|
||||||
|
@ -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 *class, const char *head, const char *rev,
|
||||||
const char *path, int ofs, const char *grep,
|
const char *path, int ofs, const char *grep,
|
||||||
const char *pattern, int showmsg, int follow);
|
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 *class, const char *head,
|
||||||
const char *rev, const char *path);
|
const char *rev, const char *path);
|
||||||
extern void cgit_patch_link(const char *name, const char *title,
|
extern void cgit_patch_link(const char *name, const char *title,
|
||||||
|
Loading…
Reference in New Issue
Block a user