diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2013-03-21 04:21:25 (JST) |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2013-03-21 04:21:25 (JST) |
commit | 0255821e22678d4c58c809efe17bf2798835d5b9 (patch) | |
tree | d4679ff23796406648cf83ff0b98940ba844c5e1 | |
parent | 6d8a789d61f3a682bc040f1f7f44050b1f723546 (diff) | |
parent | 59fe348deaa270434f05afc56ca8d13618af9ca9 (diff) | |
download | cgit-0255821e22678d4c58c809efe17bf2798835d5b9.zip cgit-0255821e22678d4c58c809efe17bf2798835d5b9.tar.gz |
Merge branch 'wip'
-rw-r--r-- | cache.c | 2 | ||||
-rw-r--r-- | cgit.c | 34 | ||||
-rw-r--r-- | cgit.h | 1 | ||||
-rw-r--r-- | configfile.c | 6 | ||||
-rw-r--r-- | html.c | 6 | ||||
-rw-r--r-- | parsing.c | 6 | ||||
-rw-r--r-- | shared.c | 48 | ||||
-rw-r--r-- | ui-atom.c | 2 | ||||
-rw-r--r-- | ui-commit.c | 1 | ||||
-rw-r--r-- | ui-diff.c | 5 | ||||
-rw-r--r-- | ui-log.c | 6 | ||||
-rw-r--r-- | ui-refs.c | 12 | ||||
-rw-r--r-- | ui-repolist.c | 14 | ||||
-rw-r--r-- | ui-shared.c | 64 | ||||
-rw-r--r-- | ui-snapshot.c | 2 | ||||
-rw-r--r-- | ui-stats.c | 17 | ||||
-rw-r--r-- | ui-tag.c | 2 | ||||
-rw-r--r-- | ui-tree.c | 8 |
18 files changed, 125 insertions, 111 deletions
@@ -363,7 +363,7 @@ int cache_process(int size, const char *path, const char *key, int ttl, | |||
363 | /* Return a strftime formatted date/time | 363 | /* Return a strftime formatted date/time |
364 | * NB: the result from this function is to shared memory | 364 | * NB: the result from this function is to shared memory |
365 | */ | 365 | */ |
366 | char *sprintftime(const char *format, time_t time) | 366 | static char *sprintftime(const char *format, time_t time) |
367 | { | 367 | { |
368 | static char buf[64]; | 368 | static char buf[64]; |
369 | struct tm *tm; | 369 | struct tm *tm; |
@@ -18,7 +18,7 @@ | |||
18 | 18 | ||
19 | const char *cgit_version = CGIT_VERSION; | 19 | const char *cgit_version = CGIT_VERSION; |
20 | 20 | ||
21 | void add_mimetype(const char *name, const char *value) | 21 | static void add_mimetype(const char *name, const char *value) |
22 | { | 22 | { |
23 | struct string_list_item *item; | 23 | struct string_list_item *item; |
24 | 24 | ||
@@ -26,7 +26,7 @@ void add_mimetype(const char *name, const char *value) | |||
26 | item->util = xstrdup(value); | 26 | item->util = xstrdup(value); |
27 | } | 27 | } |
28 | 28 | ||
29 | struct cgit_filter *new_filter(const char *cmd, filter_type filtertype) | 29 | static struct cgit_filter *new_filter(const char *cmd, filter_type filtertype) |
30 | { | 30 | { |
31 | struct cgit_filter *f; | 31 | struct cgit_filter *f; |
32 | int args_size = 0; | 32 | int args_size = 0; |
@@ -58,7 +58,7 @@ struct cgit_filter *new_filter(const char *cmd, filter_type filtertype) | |||
58 | 58 | ||
59 | static void process_cached_repolist(const char *path); | 59 | static void process_cached_repolist(const char *path); |
60 | 60 | ||
61 | void repo_config(struct cgit_repo *repo, const char *name, const char *value) | 61 | static void repo_config(struct cgit_repo *repo, const char *name, const char *value) |
62 | { | 62 | { |
63 | struct string_list_item *item; | 63 | struct string_list_item *item; |
64 | 64 | ||
@@ -114,7 +114,7 @@ void repo_config(struct cgit_repo *repo, const char *name, const char *value) | |||
114 | } | 114 | } |
115 | } | 115 | } |
116 | 116 | ||
117 | void config_cb(const char *name, const char *value) | 117 | static void config_cb(const char *name, const char *value) |
118 | { | 118 | { |
119 | if (!strcmp(name, "section") || !strcmp(name, "repo.group")) | 119 | if (!strcmp(name, "section") || !strcmp(name, "repo.group")) |
120 | ctx.cfg.section = xstrdup(value); | 120 | ctx.cfg.section = xstrdup(value); |
@@ -333,7 +333,7 @@ static void querystring_cb(const char *name, const char *value) | |||
333 | } | 333 | } |
334 | } | 334 | } |
335 | 335 | ||
336 | char *xstrdupn(const char *str) | 336 | static char *xstrdupn(const char *str) |
337 | { | 337 | { |
338 | return (str ? xstrdup(str) : NULL); | 338 | return (str ? xstrdup(str) : NULL); |
339 | } | 339 | } |
@@ -414,8 +414,8 @@ struct refmatch { | |||
414 | int match; | 414 | int match; |
415 | }; | 415 | }; |
416 | 416 | ||
417 | int find_current_ref(const char *refname, const unsigned char *sha1, | 417 | static int find_current_ref(const char *refname, const unsigned char *sha1, |
418 | int flags, void *cb_data) | 418 | int flags, void *cb_data) |
419 | { | 419 | { |
420 | struct refmatch *info; | 420 | struct refmatch *info; |
421 | 421 | ||
@@ -427,7 +427,13 @@ int find_current_ref(const char *refname, const unsigned char *sha1, | |||
427 | return info->match; | 427 | return info->match; |
428 | } | 428 | } |
429 | 429 | ||
430 | char *find_default_branch(struct cgit_repo *repo) | 430 | static void free_refmatch_inner(struct refmatch *info) |
431 | { | ||
432 | if (info->first_ref) | ||
433 | free(info->first_ref); | ||
434 | } | ||
435 | |||
436 | static char *find_default_branch(struct cgit_repo *repo) | ||
431 | { | 437 | { |
432 | struct refmatch info; | 438 | struct refmatch info; |
433 | char *ref; | 439 | char *ref; |
@@ -442,6 +448,8 @@ char *find_default_branch(struct cgit_repo *repo) | |||
442 | ref = info.first_ref; | 448 | ref = info.first_ref; |
443 | if (ref) | 449 | if (ref) |
444 | ref = xstrdup(ref); | 450 | ref = xstrdup(ref); |
451 | free_refmatch_inner(&info); | ||
452 | |||
445 | return ref; | 453 | return ref; |
446 | } | 454 | } |
447 | 455 | ||
@@ -569,13 +577,13 @@ static void process_request(void *cbdata) | |||
569 | cgit_print_docend(); | 577 | cgit_print_docend(); |
570 | } | 578 | } |
571 | 579 | ||
572 | int cmp_repos(const void *a, const void *b) | 580 | static int cmp_repos(const void *a, const void *b) |
573 | { | 581 | { |
574 | const struct cgit_repo *ra = a, *rb = b; | 582 | const struct cgit_repo *ra = a, *rb = b; |
575 | return strcmp(ra->url, rb->url); | 583 | return strcmp(ra->url, rb->url); |
576 | } | 584 | } |
577 | 585 | ||
578 | char *build_snapshot_setting(int bitmap) | 586 | static char *build_snapshot_setting(int bitmap) |
579 | { | 587 | { |
580 | const struct cgit_snapshot_format *f; | 588 | const struct cgit_snapshot_format *f; |
581 | char *result = xstrdup(""); | 589 | char *result = xstrdup(""); |
@@ -595,7 +603,7 @@ char *build_snapshot_setting(int bitmap) | |||
595 | return result; | 603 | return result; |
596 | } | 604 | } |
597 | 605 | ||
598 | char *get_first_line(char *txt) | 606 | static char *get_first_line(char *txt) |
599 | { | 607 | { |
600 | char *t = xstrdup(txt); | 608 | char *t = xstrdup(txt); |
601 | char *p = strchr(t, '\n'); | 609 | char *p = strchr(t, '\n'); |
@@ -604,7 +612,7 @@ char *get_first_line(char *txt) | |||
604 | return t; | 612 | return t; |
605 | } | 613 | } |
606 | 614 | ||
607 | void print_repo(FILE *f, struct cgit_repo *repo) | 615 | static void print_repo(FILE *f, struct cgit_repo *repo) |
608 | { | 616 | { |
609 | fprintf(f, "repo.url=%s\n", repo->url); | 617 | fprintf(f, "repo.url=%s\n", repo->url); |
610 | fprintf(f, "repo.name=%s\n", repo->name); | 618 | fprintf(f, "repo.name=%s\n", repo->name); |
@@ -649,7 +657,7 @@ void print_repo(FILE *f, struct cgit_repo *repo) | |||
649 | fprintf(f, "\n"); | 657 | fprintf(f, "\n"); |
650 | } | 658 | } |
651 | 659 | ||
652 | void print_repolist(FILE *f, struct cgit_repolist *list, int start) | 660 | static void print_repolist(FILE *f, struct cgit_repolist *list, int start) |
653 | { | 661 | { |
654 | int i; | 662 | int i; |
655 | 663 | ||
@@ -304,6 +304,7 @@ extern char *strlpart(char *txt, int maxlen); | |||
304 | extern char *strrpart(char *txt, int maxlen); | 304 | extern char *strrpart(char *txt, int maxlen); |
305 | 305 | ||
306 | extern void cgit_add_ref(struct reflist *list, struct refinfo *ref); | 306 | extern void cgit_add_ref(struct reflist *list, struct refinfo *ref); |
307 | extern void cgit_free_reflist_inner(struct reflist *list); | ||
307 | extern int cgit_refs_cb(const char *refname, const unsigned char *sha1, | 308 | extern int cgit_refs_cb(const char *refname, const unsigned char *sha1, |
308 | int flags, void *cb_data); | 309 | int flags, void *cb_data); |
309 | 310 | ||
diff --git a/configfile.c b/configfile.c index 3fa217f..d98989c 100644 --- a/configfile.c +++ b/configfile.c | |||
@@ -10,7 +10,7 @@ | |||
10 | #include <stdio.h> | 10 | #include <stdio.h> |
11 | #include "configfile.h" | 11 | #include "configfile.h" |
12 | 12 | ||
13 | int next_char(FILE *f) | 13 | static int next_char(FILE *f) |
14 | { | 14 | { |
15 | int c = fgetc(f); | 15 | int c = fgetc(f); |
16 | if (c == '\r') { | 16 | if (c == '\r') { |
@@ -23,7 +23,7 @@ int next_char(FILE *f) | |||
23 | return c; | 23 | return c; |
24 | } | 24 | } |
25 | 25 | ||
26 | void skip_line(FILE *f) | 26 | static void skip_line(FILE *f) |
27 | { | 27 | { |
28 | int c; | 28 | int c; |
29 | 29 | ||
@@ -31,7 +31,7 @@ void skip_line(FILE *f) | |||
31 | ; | 31 | ; |
32 | } | 32 | } |
33 | 33 | ||
34 | int read_config_line(FILE *f, char *line, const char **value, int bufsize) | 34 | static int read_config_line(FILE *f, char *line, const char **value, int bufsize) |
35 | { | 35 | { |
36 | int i = 0, isname = 0; | 36 | int i = 0, isname = 0; |
37 | 37 | ||
@@ -39,7 +39,7 @@ static const char* url_escape_table[256] = { | |||
39 | "%fe", "%ff" | 39 | "%fe", "%ff" |
40 | }; | 40 | }; |
41 | 41 | ||
42 | int htmlfd = STDOUT_FILENO; | 42 | static int htmlfd = STDOUT_FILENO; |
43 | 43 | ||
44 | char *fmt(const char *format, ...) | 44 | char *fmt(const char *format, ...) |
45 | { | 45 | { |
@@ -266,7 +266,7 @@ int html_include(const char *filename) | |||
266 | return 0; | 266 | return 0; |
267 | } | 267 | } |
268 | 268 | ||
269 | int hextoint(char c) | 269 | static int hextoint(char c) |
270 | { | 270 | { |
271 | if (c >= 'a' && c <= 'f') | 271 | if (c >= 'a' && c <= 'f') |
272 | return 10 + c - 'a'; | 272 | return 10 + c - 'a'; |
@@ -278,7 +278,7 @@ int hextoint(char c) | |||
278 | return -1; | 278 | return -1; |
279 | } | 279 | } |
280 | 280 | ||
281 | char *convert_query_hexchar(char *txt) | 281 | static char *convert_query_hexchar(char *txt) |
282 | { | 282 | { |
283 | int d1, d2, n; | 283 | int d1, d2, n; |
284 | n = strlen(txt); | 284 | n = strlen(txt); |
@@ -52,7 +52,7 @@ void cgit_parse_url(const char *url) | |||
52 | } | 52 | } |
53 | } | 53 | } |
54 | 54 | ||
55 | char *substr(const char *head, const char *tail) | 55 | static char *substr(const char *head, const char *tail) |
56 | { | 56 | { |
57 | char *buf; | 57 | char *buf; |
58 | 58 | ||
@@ -64,7 +64,7 @@ char *substr(const char *head, const char *tail) | |||
64 | return buf; | 64 | return buf; |
65 | } | 65 | } |
66 | 66 | ||
67 | char *parse_user(char *t, char **name, char **email, unsigned long *date) | 67 | static char *parse_user(char *t, char **name, char **email, unsigned long *date) |
68 | { | 68 | { |
69 | char *p = t; | 69 | char *p = t; |
70 | int mode = 1; | 70 | int mode = 1; |
@@ -101,7 +101,7 @@ char *parse_user(char *t, char **name, char **email, unsigned long *date) | |||
101 | #ifdef NO_ICONV | 101 | #ifdef NO_ICONV |
102 | #define reencode(a, b, c) | 102 | #define reencode(a, b, c) |
103 | #else | 103 | #else |
104 | const char *reencode(char **txt, const char *src_enc, const char *dst_enc) | 104 | static const char *reencode(char **txt, const char *src_enc, const char *dst_enc) |
105 | { | 105 | { |
106 | char *tmp; | 106 | char *tmp; |
107 | 107 | ||
@@ -158,7 +158,7 @@ void cgit_add_ref(struct reflist *list, struct refinfo *ref) | |||
158 | list->refs[list->count++] = ref; | 158 | list->refs[list->count++] = ref; |
159 | } | 159 | } |
160 | 160 | ||
161 | struct refinfo *cgit_mk_refinfo(const char *refname, const unsigned char *sha1) | 161 | static struct refinfo *cgit_mk_refinfo(const char *refname, const unsigned char *sha1) |
162 | { | 162 | { |
163 | struct refinfo *ref; | 163 | struct refinfo *ref; |
164 | 164 | ||
@@ -176,6 +176,42 @@ struct refinfo *cgit_mk_refinfo(const char *refname, const unsigned char *sha1) | |||
176 | return ref; | 176 | return ref; |
177 | } | 177 | } |
178 | 178 | ||
179 | static void cgit_free_taginfo(struct taginfo *tag) | ||
180 | { | ||
181 | if (tag->tagger) | ||
182 | free(tag->tagger); | ||
183 | if (tag->tagger_email) | ||
184 | free(tag->tagger_email); | ||
185 | if (tag->msg) | ||
186 | free(tag->msg); | ||
187 | free(tag); | ||
188 | } | ||
189 | |||
190 | static void cgit_free_refinfo(struct refinfo *ref) | ||
191 | { | ||
192 | if (ref->refname) | ||
193 | free((char *)ref->refname); | ||
194 | switch (ref->object->type) { | ||
195 | case OBJ_TAG: | ||
196 | cgit_free_taginfo(ref->tag); | ||
197 | break; | ||
198 | case OBJ_COMMIT: | ||
199 | cgit_free_commitinfo(ref->commit); | ||
200 | break; | ||
201 | } | ||
202 | free(ref); | ||
203 | } | ||
204 | |||
205 | void cgit_free_reflist_inner(struct reflist *list) | ||
206 | { | ||
207 | int i; | ||
208 | |||
209 | for (i = 0; i < list->count; i++) { | ||
210 | cgit_free_refinfo(list->refs[i]); | ||
211 | } | ||
212 | free(list->refs); | ||
213 | } | ||
214 | |||
179 | int cgit_refs_cb(const char *refname, const unsigned char *sha1, int flags, | 215 | int cgit_refs_cb(const char *refname, const unsigned char *sha1, int flags, |
180 | void *cb_data) | 216 | void *cb_data) |
181 | { | 217 | { |
@@ -187,8 +223,8 @@ int cgit_refs_cb(const char *refname, const unsigned char *sha1, int flags, | |||
187 | return 0; | 223 | return 0; |
188 | } | 224 | } |
189 | 225 | ||
190 | void cgit_diff_tree_cb(struct diff_queue_struct *q, | 226 | static void cgit_diff_tree_cb(struct diff_queue_struct *q, |
191 | struct diff_options *options, void *data) | 227 | struct diff_options *options, void *data) |
192 | { | 228 | { |
193 | int i; | 229 | int i; |
194 | 230 | ||
@@ -224,7 +260,7 @@ static int load_mmfile(mmfile_t *file, const unsigned char *sha1) | |||
224 | char *diffbuf = NULL; | 260 | char *diffbuf = NULL; |
225 | int buflen = 0; | 261 | int buflen = 0; |
226 | 262 | ||
227 | int filediff_cb(void *priv, mmbuffer_t *mb, int nbuf) | 263 | static int filediff_cb(void *priv, mmbuffer_t *mb, int nbuf) |
228 | { | 264 | { |
229 | int i; | 265 | int i; |
230 | 266 | ||
@@ -461,14 +497,14 @@ int readfile(const char *path, char **buf, size_t *size) | |||
461 | return (*size == st.st_size ? 0 : e); | 497 | return (*size == st.st_size ? 0 : e); |
462 | } | 498 | } |
463 | 499 | ||
464 | int is_token_char(char c) | 500 | static int is_token_char(char c) |
465 | { | 501 | { |
466 | return isalnum(c) || c == '_'; | 502 | return isalnum(c) || c == '_'; |
467 | } | 503 | } |
468 | 504 | ||
469 | /* Replace name with getenv(name), return pointer to zero-terminating char | 505 | /* Replace name with getenv(name), return pointer to zero-terminating char |
470 | */ | 506 | */ |
471 | char *expand_macro(char *name, int maxlength) | 507 | static char *expand_macro(char *name, int maxlength) |
472 | { | 508 | { |
473 | char *value; | 509 | char *value; |
474 | int len; | 510 | int len; |
@@ -10,7 +10,7 @@ | |||
10 | #include "html.h" | 10 | #include "html.h" |
11 | #include "ui-shared.h" | 11 | #include "ui-shared.h" |
12 | 12 | ||
13 | void add_entry(struct commit *commit, char *host) | 13 | static void add_entry(struct commit *commit, char *host) |
14 | { | 14 | { |
15 | char delim = '&'; | 15 | char delim = '&'; |
16 | char *hex; | 16 | char *hex; |
diff --git a/ui-commit.c b/ui-commit.c index 74f37c8..0783285 100644 --- a/ui-commit.c +++ b/ui-commit.c | |||
@@ -74,6 +74,7 @@ void cgit_print_commit(char *hex, const char *prefix) | |||