aboutsummaryrefslogtreecommitdiffstats
path: root/ui-shared.c
diff options
context:
space:
mode:
authorJohn Keeping2016-08-07 16:13:30 +0100
committerJohn Keeping2016-10-01 11:43:45 +0100
commitbead27b730526e4501ebaeb3b7c1116cd09f7b93 (patch)
treef8c19108c0852ee534a680d4083e4de2adebc057 /ui-shared.c
parent35df710a1fa21b62c5328e2c98f29a68a0312a25 (diff)
downloadcgit-bead27b730526e4501ebaeb3b7c1116cd09f7b93.tar.gz
cgit-bead27b730526e4501ebaeb3b7c1116cd09f7b93.tar.bz2
cgit-bead27b730526e4501ebaeb3b7c1116cd09f7b93.zip
ui-shared: fix decl-after-statement warnings
git.git's coding style avoids decl-after-statement and we generally try to follow it but a few warnings have crept in recently. Fix the ones in ui-shared.c Signed-off-by: John Keeping <john@keeping.me.uk>
Diffstat (limited to 'ui-shared.c')
-rw-r--r--ui-shared.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/ui-shared.c b/ui-shared.c
index e39d004..3fa36d6 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -66,10 +66,11 @@ char *cgit_hosturl(void)
66 66
67char *cgit_currenturl(void) 67char *cgit_currenturl(void)
68{ 68{
69 if (!ctx.qry.url)
70 return xstrdup(cgit_rooturl());
71 const char *root = cgit_rooturl(); 69 const char *root = cgit_rooturl();
72 size_t len = strlen(root); 70 size_t len = strlen(root);
71
72 if (!ctx.qry.url)
73 return xstrdup(root);
73 if (len && root[len - 1] == '/') 74 if (len && root[len - 1] == '/')
74 return fmtalloc("%s%s", root, ctx.qry.url); 75 return fmtalloc("%s%s", root, ctx.qry.url);
75 return fmtalloc("%s/%s", root, ctx.qry.url); 76 return fmtalloc("%s/%s", root, ctx.qry.url);
@@ -349,6 +350,8 @@ void cgit_log_link(const char *name, const char *title, const char *class,
349void cgit_commit_link(char *name, const char *title, const char *class, 350void cgit_commit_link(char *name, const char *title, const char *class,
350 const char *head, const char *rev, const char *path) 351 const char *head, const char *rev, const char *path)
351{ 352{
353 char *delim;
354
352 if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) { 355 if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) {
353 name[ctx.cfg.max_msg_len] = '\0'; 356 name[ctx.cfg.max_msg_len] = '\0';
354 name[ctx.cfg.max_msg_len - 1] = '.'; 357 name[ctx.cfg.max_msg_len - 1] = '.';
@@ -356,8 +359,6 @@ void cgit_commit_link(char *name, const char *title, const char *class,
356 name[ctx.cfg.max_msg_len - 3] = '.'; 359 name[ctx.cfg.max_msg_len - 3] = '.';
357 } 360 }
358 361
359 char *delim;
360
361 delim = repolink(title, class, "commit", head, path); 362 delim = repolink(title, class, "commit", head, path);
362 if (rev && ctx.qry.head && strcmp(rev, ctx.qry.head)) { 363 if (rev && ctx.qry.head && strcmp(rev, ctx.qry.head)) {
363 html(delim); 364 html(delim);
@@ -714,13 +715,14 @@ static void print_rel_vcs_link(const char *url)
714 715
715void cgit_print_docstart(void) 716void cgit_print_docstart(void)
716{ 717{
718 char *host = cgit_hosturl();
719
717 if (ctx.cfg.embedded) { 720 if (ctx.cfg.embedded) {
718 if (ctx.cfg.header) 721 if (ctx.cfg.header)
719 html_include(ctx.cfg.header); 722 html_include(ctx.cfg.header);
720 return; 723 return;
721 } 724 }
722 725
723 char *host = cgit_hosturl();
724 html(cgit_doctype); 726 html(cgit_doctype);
725 html("<html lang='en'>\n"); 727 html("<html lang='en'>\n");
726 html("<head>\n"); 728 html("<head>\n");