aboutsummaryrefslogtreecommitdiffstats
path: root/ui-summary.c
diff options
context:
space:
mode:
authorGravatar Lukas Fleischer <cgit@cryptocrack.de>2013-03-06 00:48:27 (JST)
committerGravatar Jason A. Donenfeld <Jason@zx2c4.com>2013-03-21 05:08:32 (JST)
commit977a3ad7bf212e6ec7f43c16763321061ee64a69 (patch)
tree49b80b6cac3e0d66e7ff73ef45d42f66ac8c5859 /ui-summary.c
parentef8a97d9c6983e4fc3710bdbe771edd4e3550dba (diff)
downloadcgit-977a3ad7bf212e6ec7f43c16763321061ee64a69.zip
cgit-977a3ad7bf212e6ec7f43c16763321061ee64a69.tar.gz
ui-summary.c: Move urls variable into print_urls()
There's no need for this variable to be global. Printing the header in print_urls() instead of print_url() allows for moving this variable into print_urls() without having to pass any status to print_url(). Note that this only works as long as we don't call print_urls() more than once. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
Diffstat (limited to 'ui-summary.c')
-rw-r--r--ui-summary.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/ui-summary.c b/ui-summary.c
index 38639ce..0754bb7 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -13,8 +13,6 @@
13#include "ui-refs.h" 13#include "ui-refs.h"
14#include "ui-blob.h" 14#include "ui-blob.h"
15 15
16int urls = 0;
17
18static void print_url(char *base, char *suffix) 16static void print_url(char *base, char *suffix)
19{ 17{
20 int columns = 3; 18 int columns = 3;
@@ -26,10 +24,6 @@ static void print_url(char *base, char *suffix)
26 24
27 if (!base || !*base) 25 if (!base || !*base)
28 return; 26 return;
29 if (urls++ == 0) {
30 htmlf("<tr class='nohover'><td colspan='%d'>&nbsp;</td></tr>", columns);
31 htmlf("<tr><th class='left' colspan='%d'>Clone</th></tr>\n", columns);
32 }
33 if (suffix && *suffix) 27 if (suffix && *suffix)
34 base = fmt("%s/%s", base, suffix); 28 base = fmt("%s/%s", base, suffix);
35 htmlf("<tr><td colspan='%d'><a href='", columns); 29 htmlf("<tr><td colspan='%d'><a href='", columns);
@@ -42,15 +36,29 @@ static void print_url(char *base, char *suffix)
42static void print_urls(char *txt, char *suffix) 36static void print_urls(char *txt, char *suffix)
43{ 37{
44 char *h = txt, *t, c; 38 char *h = txt, *t, c;
39 int urls = 0;
40 int columns = 3;
41
42 if (ctx.repo->enable_log_filecount)
43 columns++;
44 if (ctx.repo->enable_log_linecount)
45 columns++;
46
45 47
46 while (h && *h) { 48 while (h && *h) {
47 while (h && *h == ' ') 49 while (h && *h == ' ')
48 h++; 50 h++;
51 if (!*h)
52 break;
49 t = h; 53 t = h;
50 while (t && *t && *t != ' ') 54 while (t && *t && *t != ' ')
51 t++; 55 t++;
52 c = *t; 56 c = *t;
53 *t = 0; 57 *t = 0;
58 if (urls++ == 0) {
59 htmlf("<tr class='nohover'><td colspan='%d'>&nbsp;</td></tr>", columns);
60 htmlf("<tr><th class='left' colspan='%d'>Clone</th></tr>\n", columns);
61 }
54 print_url(h, suffix); 62 print_url(h, suffix);
55 *t = c; 63 *t = c;
56 h = t; 64 h = t;