about summary refs log tree commit diff stats
path: root/ui-shared.c
diff options
context:
space:
mode:
authorJeff Smith2017-10-01 23:39:07 -0500
committerJohn Keeping2017-10-03 19:19:34 +0100
commitf6ffe40d1a2c985494e48dc2d36663ffde1e6044 (patch)
tree7fc72e55df7be47827a276a73926f8f31f4b55e2 /ui-shared.c
parentui-tree: move set_title_from_path to ui-shared (diff)
downloadcgit-f6ffe40d1a2c985494e48dc2d36663ffde1e6044.tar.gz
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 'ui-shared.c')
-rw-r--r--ui-shared.c19
1 files changed, 8 insertions, 11 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,
347 html("</a>"); 347 html("</a>");
348} 348}
349 349
350void cgit_commit_link(char *name, const char *title, const char *class, 350void cgit_commit_link(const char *name, const char *title, const char *class,
351 const char *head, const char *rev, const char *path) 351 const char *head, const char *rev, const char *path)
352{ 352{
353 char *delim; 353 char *delim;
354 354
355 if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) {
356 name[ctx.cfg.max_msg_len] = '\0';
357 name[ctx.cfg.max_msg_len - 1] = '.';
358 name[ctx.cfg.max_msg_len - 2] = '.';
359 name[ctx.cfg.max_msg_len - 3] = '.';
360 }
361
362 delim = repolink(title, class, "commit", head, path); 355 delim = repolink(title, class, "commit", head, path);
363 if (rev && ctx.qry.head && strcmp(rev, ctx.qry.head)) { 356 if (rev && ctx.qry.head && strcmp(rev, ctx.qry.head)) {
364 html(delim); 357 html(delim);
@@ -387,9 +380,13 @@ void cgit_commit_link(char *name, const char *title, const char *class,
387 html("follow=1"); 380 html("follow=1");
388 } 381 }
389 html("'>"); 382 html("'>");
390 if (name[0] != '\0') 383 if (name[0] != '\0') {
391 html_txt(name); 384 if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) {
392 else 385 html_ntxt(name, ctx.cfg.max_msg_len - 3);
386 html("...");
387 } else
388 html_txt(name);
389 } else
393 html_txt("(no commit message)"); 390 html_txt("(no commit message)");
394 html("</a>"); 391 html("</a>");
395} 392}