diff options
| -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
| @@ -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 |
| @@ -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); |
| @@ -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 |
| @@ -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); |
| @@ -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 | } |
| @@ -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); |
| @@ -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 | } |
| @@ -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 | |||
