diff options
author | Lars Hjemli | 2010-09-19 19:00:05 +0200 |
---|---|---|
committer | Lars Hjemli | 2010-09-19 19:00:05 +0200 |
commit | a9d6e6e695da6c6ed7f4bb32630ab2f3d9314806 (patch) | |
tree | de8271ebfabd244437cd68021c8af86391afb9bd | |
parent | Merge branch 'lh/section-from-path' (diff) | |
parent | prefer html_raw() to write() (diff) | |
download | cgit-a9d6e6e695da6c6ed7f4bb32630ab2f3d9314806.tar.gz cgit-a9d6e6e695da6c6ed7f4bb32630ab2f3d9314806.zip |
Merge branch 'ml/bugfix'
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | cache.h | 1 | ||||
-rw-r--r-- | cgit.c | 2 | ||||
-rw-r--r-- | cgit.h | 1 | ||||
-rw-r--r-- | html.c | 18 | ||||
-rw-r--r-- | html.h | 3 | ||||
-rw-r--r-- | ui-blob.c | 4 | ||||
-rw-r--r-- | ui-diff.c | 2 | ||||
-rw-r--r-- | ui-log.c | 3 | ||||
-rw-r--r-- | ui-repolist.c | 6 | ||||
-rw-r--r-- | ui-stats.c | 18 | ||||
-rw-r--r-- | ui-tree.c | 6 |
12 files changed, 42 insertions, 30 deletions
diff --git a/Makefile b/Makefile index 23fdd53..6a47ed2 100644 --- a/Makefile +++ b/Makefile | |||
@@ -16,6 +16,11 @@ INSTALL = install | |||
16 | # | 16 | # |
17 | # Define NEEDS_LIBICONV if linking with libc is not enough (eg. Darwin). | 17 | # Define NEEDS_LIBICONV if linking with libc is not enough (eg. Darwin). |
18 | # | 18 | # |
19 | # Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.) | ||
20 | # do not support the 'size specifiers' introduced by C99, namely ll, hh, | ||
21 | # j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t). | ||
22 | # some C compilers supported these specifiers prior to C99 as an extension. | ||
23 | # | ||
19 | 24 | ||
20 | #-include config.mak | 25 | #-include config.mak |
21 | 26 | ||
@@ -127,6 +132,9 @@ endif | |||
127 | ifdef NO_STRCASESTR | 132 | ifdef NO_STRCASESTR |
128 | CFLAGS += -DNO_STRCASESTR | 133 | CFLAGS += -DNO_STRCASESTR |
129 | endif | 134 | endif |
135 | ifdef NO_C99_FORMAT | ||
136 | CFLAGS += -DNO_C99_FORMAT | ||
137 | endif | ||
130 | ifdef NO_OPENSSL | 138 | ifdef NO_OPENSSL |
131 | CFLAGS += -DNO_OPENSSL | 139 | CFLAGS += -DNO_OPENSSL |
132 | GIT_OPTIONS += NO_OPENSSL=1 | 140 | GIT_OPTIONS += NO_OPENSSL=1 |
diff --git a/cache.h b/cache.h index ac9276b..5cfdb4f 100644 --- a/cache.h +++ b/cache.h | |||
@@ -30,6 +30,7 @@ extern int cache_process(int size, const char *path, const char *key, int ttl, | |||
30 | extern int cache_ls(const char *path); | 30 | extern int cache_ls(const char *path); |
31 | 31 | ||
32 | /* Print a message to stdout */ | 32 | /* Print a message to stdout */ |
33 | __attribute__((format (printf,1,2))) | ||
33 | extern void cache_log(const char *format, ...); | 34 | extern void cache_log(const char *format, ...); |
34 | 35 | ||
35 | extern unsigned long hash_str(const char *str); | 36 | extern unsigned long hash_str(const char *str); |
diff --git a/cgit.c b/cgit.c index e1d2216..96900bb 100644 --- a/cgit.c +++ b/cgit.c | |||
@@ -610,7 +610,7 @@ static void process_cached_repolist(const char *path) | |||
610 | hash = hash_str(path); | 610 | hash = hash_str(path); |
611 | if (ctx.cfg.project_list) | 611 | if (ctx.cfg.project_list) |
612 | hash += hash_str(ctx.cfg.project_list); | 612 | hash += hash_str(ctx.cfg.project_list); |
613 | cached_rc = xstrdup(fmt("%s/rc-%8x", ctx.cfg.cache_root, hash)); | 613 | cached_rc = xstrdup(fmt("%s/rc-%8lx", ctx.cfg.cache_root, hash)); |
614 | 614 | ||
615 | if (stat(cached_rc, &st)) { | 615 | if (stat(cached_rc, &st)) { |
616 | /* Nothing is cached, we need to scan without forking. And | 616 | /* Nothing is cached, we need to scan without forking. And |
diff --git a/cgit.h b/cgit.h index f8076c5..8f5dd2a 100644 --- a/cgit.h +++ b/cgit.h | |||
@@ -295,6 +295,7 @@ extern void cgit_diff_tree(const unsigned char *old_sha1, | |||
295 | 295 | ||
296 | extern void cgit_diff_commit(struct commit *commit, filepair_fn fn); | 296 | extern void cgit_diff_commit(struct commit *commit, filepair_fn fn); |
297 | 297 | ||
298 | __attribute__((format (printf,1,2))) | ||
298 | extern char *fmt(const char *format,...); | 299 | extern char *fmt(const char *format,...); |
299 | 300 | ||
300 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); | 301 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); |
diff --git a/html.c b/html.c index eaabf72..1305910 100644 --- a/html.c +++ b/html.c | |||
@@ -95,7 +95,7 @@ void html_txt(const char *txt) | |||
95 | while(t && *t){ | 95 | while(t && *t){ |
96 | int c = *t; | 96 | int c = *t; |
97 | if (c=='<' || c=='>' || c=='&') { | 97 | if (c=='<' || c=='>' || c=='&') { |
98 | write(htmlfd, txt, t - txt); | 98 | html_raw(txt, t - txt); |
99 | if (c=='>') | 99 | if (c=='>') |
100 | html(">"); | 100 | html(">"); |
101 | else if (c=='<') | 101 | else if (c=='<') |
@@ -116,7 +116,7 @@ void html_ntxt(int len, const char *txt) | |||
116 | while(t && *t && len--){ | 116 | while(t && *t && len--){ |
117 | int c = *t; | 117 | int c = *t; |
118 | if (c=='<' || c=='>' || c=='&') { | 118 | if (c=='<' || c=='>' || c=='&') { |
119 | write(htmlfd, txt, t - txt); | 119 | html_raw(txt, t - txt); |
120 | if (c=='>') | 120 | if (c=='>') |
121 | html(">"); | 121 | html(">"); |
122 | else if (c=='<') | 122 | else if (c=='<') |
@@ -128,7 +128,7 @@ void html_ntxt(int len, const char *txt) | |||
128 | t++; | 128 | t++; |
129 | } | 129 | } |
130 | if (t!=txt) | 130 | if (t!=txt) |
131 | write(htmlfd, txt, t - txt); | 131 | html_raw(txt, t - txt); |
132 | if (len<0) | 132 | if (len<0) |
133 | html("..."); | 133 | html("..."); |
134 | } | 134 | } |
@@ -139,7 +139,7 @@ void html_attr(const char *txt) | |||
139 | while(t && *t){ | 139 | while(t && *t){ |
140 | int c = *t; | 140 | int c = *t; |
141 | if (c=='<' || c=='>' || c=='\'' || c=='\"') { | 141 | if (c=='<' || c=='>' || c=='\'' || c=='\"') { |
142 | write(htmlfd, txt, t - txt); | 142 | html_raw(txt, t - txt); |
143 | if (c=='>') | 143 | if (c=='>') |
144 | html(">"); | 144 | html(">"); |
145 | else if (c=='<') | 145 | else if (c=='<') |
@@ -163,8 +163,8 @@ void html_url_path(const char *txt) | |||
163 | int c = *t; | 163 | int c = *t; |
164 | const char *e = url_escape_table[c]; | 164 | const char *e = url_escape_table[c]; |
165 | if (e && c!='+' && c!='&' && c!='+') { | 165 | if (e && c!='+' && c!='&' && c!='+') { |
166 | write(htmlfd, txt, t - txt); | 166 | html_raw(txt, t - txt); |
167 | write(htmlfd, e, 3); | 167 | html_raw(e, 3); |
168 | txt = t+1; | 168 | txt = t+1; |
169 | } | 169 | } |
170 | t++; | 170 | t++; |
@@ -180,8 +180,8 @@ void html_url_arg(const char *txt) | |||
180 | int c = *t; | 180 | int c = *t; |
181 | const char *e = url_escape_table[c]; | 181 | const char *e = url_escape_table[c]; |
182 | if (e) { | 182 | if (e) { |
183 | write(htmlfd, txt, t - txt); | 183 | html_raw(txt, t - txt); |
184 | write(htmlfd, e, 3); | 184 | html_raw(e, 3); |
185 | txt = t+1; | 185 | txt = t+1; |
186 | } | 186 | } |
187 | t++; | 187 | t++; |
@@ -249,7 +249,7 @@ int html_include(const char *filename) | |||
249 | return -1; | 249 | return -1; |
250 | } | 250 | } |
251 | while((len = fread(buf, 1, 4096, f)) > 0) | 251 | while((len = fread(buf, 1, 4096, f)) > 0) |
252 | write(htmlfd, buf, len); | 252 | html_raw(buf, len); |
253 | fclose(f); | 253 | fclose(f); |
254 | return 0; | 254 | return 0; |
255 | } | 255 | } |
diff --git a/html.h b/html.h index 16d55ec..1135fb8 100644 --- a/html.h +++ b/html.h | |||
@@ -5,7 +5,10 @@ extern int htmlfd; | |||
5 | 5 | ||
6 | extern void html_raw(const char *txt, size_t size); | 6 | extern void html_raw(const char *txt, size_t size); |
7 | extern void html(const char *txt); | 7 | extern void html(const char *txt); |
8 | |||
9 | __attribute__((format (printf,1,2))) | ||
8 | extern void htmlf(const char *format,...); | 10 | extern void htmlf(const char *format,...); |
11 | |||
9 | extern void html_status(int code, const char *msg, int more_headers); | 12 | extern void html_status(int code, const char *msg, int more_headers); |
10 | extern void html_txt(const char *txt); | 13 | extern void html_txt(const char *txt); |
11 | extern void html_ntxt(int len, const char *txt); | 14 | extern void html_ntxt(int len, const char *txt); |
diff --git a/ui-blob.c b/ui-blob.c index 667a451..ec435e1 100644 --- a/ui-blob.c +++ b/ui-blob.c | |||
@@ -52,7 +52,7 @@ int cgit_print_file(char *path, const char *head) | |||
52 | if (!buf) | 52 | if (!buf) |
53 | return -1; | 53 | return -1; |
54 | buf[size] = '\0'; | 54 | buf[size] = '\0'; |
55 | write(htmlfd, buf, size); | 55 | html_raw(buf, size); |
56 | return 0; | 56 | return 0; |
57 | } | 57 | } |
58 | 58 | ||
@@ -108,5 +108,5 @@ void cgit_print_blob(const char *hex, char *path, const char *head) | |||
108 | } | 108 | } |
109 | ctx.page.filename = path; | 109 | ctx.page.filename = path; |
110 | cgit_print_http_headers(&ctx); | 110 | cgit_print_http_headers(&ctx); |
111 | write(htmlfd, buf, size); | 111 | html_raw(buf, size); |
112 | } | 112 | } |
diff --git a/ui-diff.c b/ui-diff.c index 0dcabe9..7ff7e46 100644 --- a/ui-diff.c +++ b/ui-diff.c | |||
@@ -92,7 +92,7 @@ static void print_fileinfo(struct fileinfo *info) | |||
92 | info->old_path); | 92 | info->old_path); |
93 | html("</td><td class='right'>"); | 93 | html("</td><td class='right'>"); |
94 | if (info->binary) { | 94 | if (info->binary) { |
95 | htmlf("bin</td><td class='graph'>%d -> %d bytes", | 95 | htmlf("bin</td><td class='graph'>%ld -> %ld bytes", |
96 | info->old_size, info->new_size); | 96 | info->old_size, info->new_size); |
97 | return; | 97 | return; |
98 | } | 98 | } |
diff --git a/ui-log.c b/ui-log.c index 0536b23..41b5225 100644 --- a/ui-log.c +++ b/ui-log.c | |||
@@ -228,8 +228,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern | |||
228 | commit->parents = NULL; | 228 | commit->parents = NULL; |
229 | } | 229 | } |
230 | if (pager) { | 230 | if (pager) { |
231 | htmlf("</table><div class='pager'>", | 231 | html("</table><div class='pager'>"); |
232 | columns); | ||
233 | if (ofs > 0) { | 232 | if (ofs > 0) { |
234 | cgit_log_link("[prev]", NULL, NULL, ctx.qry.head, | 233 | cgit_log_link("[prev]", NULL, NULL, ctx.qry.head, |
235 | ctx.qry.sha1, ctx.qry.vpath, | 234 | ctx.qry.sha1, ctx.qry.vpath, |
diff --git a/ui-repolist.c b/ui-repolist.c index 0a0b6ca..2c98668 100644 --- a/ui-repolist.c +++ b/ui-repolist.c | |||
@@ -6,12 +6,6 @@ | |||
6 | * (see COPYING for full license text) | 6 | * (see COPYING for full license text) |
7 | */ | 7 | */ |
8 | 8 | ||
9 | /* This is needed for strcasestr to be defined by <string.h> */ | ||
10 | #define _GNU_SOURCE 1 | ||
11 | #include <string.h> | ||
12 | |||
13 | #include <time.h> | ||
14 | |||
15 | #include "cgit.h" | 9 | #include "cgit.h" |
16 | #include "html.h" | 10 | #include "html.h" |
17 | #include "ui-shared.h" | 11 | #include "ui-shared.h" |
diff --git a/ui-stats.c b/ui-stats.c index 50c2540..946a6ea 100644 --- a/ui-stats.c +++ b/ui-stats.c | |||
@@ -5,6 +5,12 @@ | |||
5 | #include "ui-shared.h" | 5 | #include "ui-shared.h" |
6 | #include "ui-stats.h" | 6 | #include "ui-stats.h" |
7 | 7 | ||
8 | #ifdef NO_C99_FORMAT | ||
9 | #define SZ_FMT "%u" | ||
10 | #else | ||
11 | #define SZ_FMT "%zu" | ||
12 | #endif | ||
13 | |||
8 | #define MONTHS 6 | 14 | #define MONTHS 6 |
9 | 15 | ||
10 | struct authorstat { | 16 | struct authorstat { |
@@ -283,10 +289,10 @@ void print_combined_authorrow(struct string_list *authors, int from, int to, | |||
283 | if (date) | 289 | if (date) |
284 | subtotal += (size_t)date->util; | 290 | subtotal += (size_t)date->util; |
285 | } | 291 | } |
286 | htmlf("<td class='%s'>%d</td>", centerclass, subtotal); | 292 | htmlf("<td class='%s'>%ld</td>", centerclass, subtotal); |
287 | total += subtotal; | 293 | total += subtotal; |
288 | } | 294 | } |
289 | htmlf("<td class='%s'>%d</td></tr>", rightclass, total); | 295 | htmlf("<td class='%s'>%ld</td></tr>", rightclass, total); |
290 | } | 296 | } |
291 | 297 | ||
292 | void print_authors(struct string_list *authors, int top, | 298 | void print_authors(struct string_list *authors, int top, |
@@ -335,16 +341,16 @@ void print_authors(struct string_list *authors, int top, | |||
335 | if (!date) | 341 | if (!date) |
336 | html("<td>0</td>"); | 342 | html("<td>0</td>"); |
337 | else { | 343 | else { |
338 | htmlf("<td>%d</td>", date->util); | 344 | htmlf("<td>"SZ_FMT"</td>", (size_t)date->util); |
339 | total += (size_t)date->util; | 345 | total += (size_t)date->util; |
340 | } | 346 | } |
341 | } | 347 | } |
342 | htmlf("<td class='sum'>%d</td></tr>", total); | 348 | htmlf("<td class='sum'>%ld</td></tr>", total); |
343 | } | 349 | } |
344 | 350 | ||
345 | if (top < authors->nr) | 351 | if (top < authors->nr) |
346 | print_combined_authorrow(authors, top, authors->nr - 1, | 352 | print_combined_authorrow(authors, top, authors->nr - 1, |
347 | "Others (%d)", "left", "", "sum", period); | 353 | "Others (%ld)", "left", "", "sum", period); |
348 | 354 | ||
349 | print_combined_authorrow(authors, 0, authors->nr - 1, "Total", | 355 | print_combined_authorrow(authors, 0, authors->nr - 1, "Total", |
350 | "total", "sum", "sum", period); | 356 | "total", "sum", "sum", period); |
@@ -367,7 +373,7 @@ void cgit_show_stats(struct cgit_context *ctx) | |||
367 | 373 | ||
368 | i = cgit_find_stats_period(code, &period); | 374 | i = cgit_find_stats_period(code, &period); |
369 | if (!i) { | 375 | if (!i) { |
370 | cgit_print_error(fmt("Unknown statistics type: %c", code)); | 376 | cgit_print_error(fmt("Unknown statistics type: %c", code[0])); |
371 | return; | 377 | return; |
372 | } | 378 | } |
373 | if (i > ctx->repo->max_stats) { | 379 | if (i > ctx->repo->max_stats) { |
diff --git a/ui-tree.c b/ui-tree.c index 75ec9cb..0b1b531 100644 --- a/ui-tree.c +++ b/ui-tree.c | |||
@@ -46,7 +46,7 @@ static void print_text_buffer(const char *name, char *buf, unsigned long size) | |||
46 | html("<td class='lines'><pre><code>"); | 46 | html("<td class='lines'><pre><code>"); |
47 | ctx.repo->source_filter->argv[1] = xstrdup(name); | 47 | ctx.repo->source_filter->argv[1] = xstrdup(name); |
48 | cgit_open_filter(ctx.repo->source_filter); | 48 | cgit_open_filter(ctx.repo->source_filter); |
49 | write(STDOUT_FILENO, buf, size); | 49 | html_raw(buf, size); |
50 | cgit_close_filter(ctx.repo->source_filter); | 50 | cgit_close_filter(ctx.repo->source_filter); |
51 | html("</code></pre></td></tr></table>\n"); | 51 | html("</code></pre></td></tr></table>\n"); |
52 | return; | 52 | return; |
@@ -67,7 +67,7 @@ static void print_binary_buffer(char *buf, unsigned long size) | |||
67 | html("<table summary='blob content' class='bin-blob'>\n"); | 67 | html("<table summary='blob content' class='bin-blob'>\n"); |
68 | html("<tr><th>ofs</th><th>hex dump</th><th>ascii</th></tr>"); | 68 | html("<tr><th>ofs</th><th>hex dump</th><th>ascii</th></tr>"); |
69 | for (ofs = 0; ofs < size; ofs += ROWLEN, buf += ROWLEN) { | 69 | for (ofs = 0; ofs < size; ofs += ROWLEN, buf += ROWLEN) { |
70 | htmlf("<tr><td class='right'>%04x</td><td class='hex'>", ofs); | 70 | htmlf("<tr><td class='right'>%04lx</td><td class='hex'>", ofs); |
71 | for (idx = 0; idx < ROWLEN && ofs + idx < size; idx++) | 71 | for (idx = 0; idx < ROWLEN && ofs + idx < size; idx++) |
72 | htmlf("%*s%02x", | 72 | htmlf("%*s%02x", |
73 | idx == 16 ? 4 : 1, "", | 73 | idx == 16 ? 4 : 1, "", |
@@ -108,7 +108,7 @@ static void print_object(const unsigned char *sha1, char *path, const char *base | |||
108 | html(")\n"); | 108 | html(")\n"); |
109 | 109 | ||
110 | if (ctx.cfg.max_blob_size && size / 1024 > ctx.cfg.max_blob_size) { | 110 | if (ctx.cfg.max_blob_size && size / 1024 > ctx.cfg.max_blob_size) { |
111 | htmlf("<div class='error'>blob size (%dKB) exceeds display size limit (%dKB).</div>", | 111 | htmlf("<div class='error'>blob size (%ldKB) exceeds display size limit (%dKB).</div>", |
112 | size / 1024, ctx.cfg.max_blob_size); | 112 | size / 1024, ctx.cfg.max_blob_size); |
113 | return; | 113 | return; |
114 | } | 114 | } |