all repos — cgit @ bead27b730526e4501ebaeb3b7c1116cd09f7b93

a hyperfast web frontend for git written in c

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>
John Keeping john@keeping.me.uk
Sun, 07 Aug 2016 16:13:30 +0100
commit

bead27b730526e4501ebaeb3b7c1116cd09f7b93

parent

35df710a1fa21b62c5328e2c98f29a68a0312a25

1 files changed, 7 insertions(+), 5 deletions(-)

jump to
M ui-shared.cui-shared.c

@@ -66,10 +66,11 @@ }

char *cgit_currenturl(void) { - if (!ctx.qry.url) - return xstrdup(cgit_rooturl()); const char *root = cgit_rooturl(); size_t len = strlen(root); + + if (!ctx.qry.url) + return xstrdup(root); if (len && root[len - 1] == '/') return fmtalloc("%s%s", root, ctx.qry.url); return fmtalloc("%s/%s", root, ctx.qry.url);

@@ -349,14 +350,14 @@

void cgit_commit_link(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] = '.'; } - - char *delim; delim = repolink(title, class, "commit", head, path); if (rev && ctx.qry.head && strcmp(rev, ctx.qry.head)) {

@@ -714,13 +715,14 @@ }

void cgit_print_docstart(void) { + char *host = cgit_hosturl(); + if (ctx.cfg.embedded) { if (ctx.cfg.header) html_include(ctx.cfg.header); return; } - char *host = cgit_hosturl(); html(cgit_doctype); html("<html lang='en'>\n"); html("<head>\n");