diff options
author | Lukas Fleischer <cgit@cryptocrack.de> | 2013-03-04 00:04:29 (JST) |
---|---|---|
committer | Lukas Fleischer <cgit@cryptocrack.de> | 2013-03-04 09:12:48 (JST) |
commit | 53bc747d311d18642fa3ad0cc0de34f3899ed1f4 (patch) | |
tree | 97e6fa2e4e7300f55a180917059b71e566c260fe | |
parent | 7f4e8c33aeb65bdc5695c9fd13ec1ceb100303c7 (diff) | |
download | cgit-53bc747d311d18642fa3ad0cc0de34f3899ed1f4.zip cgit-53bc747d311d18642fa3ad0cc0de34f3899ed1f4.tar.gz |
Fix several whitespace errors
* Remove whitespace at the end of lines.
* Replace space indentation by tabs.
* Add whitespace before/after several operators ("+", "-", "*", ...)
* Add whitespace to assignments ("foo = bar;").
* Fix whitespace in parameter lists ("foobar(foo, bar, 42)").
Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
-rw-r--r-- | cache.c | 6 | ||||
-rw-r--r-- | cgit.c | 18 | ||||
-rw-r--r-- | configfile.c | 22 | ||||
-rw-r--r-- | html.c | 78 | ||||
-rw-r--r-- | scan-tree.c | 4 | ||||
-rw-r--r-- | shared.c | 14 | ||||
-rw-r--r-- | ui-blob.c | 10 | ||||
-rw-r--r-- | ui-commit.c | 4 | ||||
-rw-r--r-- | ui-refs.c | 4 | ||||
-rw-r--r-- | ui-repolist.c | 6 | ||||
-rw-r--r-- | ui-shared.c | 18 | ||||
-rw-r--r-- | ui-stats.c | 8 | ||||
-rw-r--r-- | ui-tag.c | 2 | ||||
-rw-r--r-- | ui-tree.c | 4 |
14 files changed, 99 insertions, 99 deletions
@@ -105,7 +105,7 @@ static int is_expired(struct cache_slot *slot) | |||
105 | if (slot->ttl < 0) | 105 | if (slot->ttl < 0) |
106 | return 0; | 106 | return 0; |
107 | else | 107 | else |
108 | return slot->cache_st.st_mtime + slot->ttl*60 < time(NULL); | 108 | return slot->cache_st.st_mtime + slot->ttl * 60 < time(NULL); |
109 | } | 109 | } |
110 | 110 | ||
111 | /* Check if the slot has been modified since we opened it. | 111 | /* Check if the slot has been modified since we opened it. |
@@ -141,8 +141,8 @@ static int close_lock(struct cache_slot *slot) | |||
141 | */ | 141 | */ |
142 | static int lock_slot(struct cache_slot *slot) | 142 | static int lock_slot(struct cache_slot *slot) |
143 | { | 143 | { |
144 | slot->lock_fd = open(slot->lock_name, O_RDWR|O_CREAT|O_EXCL, | 144 | slot->lock_fd = open(slot->lock_name, O_RDWR | O_CREAT | O_EXCL, |
145 | S_IRUSR|S_IWUSR); | 145 | S_IRUSR | S_IWUSR); |
146 | if (slot->lock_fd == -1) | 146 | if (slot->lock_fd == -1) |
147 | return errno; | 147 | return errno; |
148 | if (xwrite(slot->lock_fd, slot->key, slot->keylen + 1) < 0) | 148 | if (xwrite(slot->lock_fd, slot->key, slot->keylen + 1) < 0) |
@@ -741,7 +741,7 @@ static void cgit_parse_args(int argc, const char **argv) | |||
741 | 741 | ||
742 | for (i = 1; i < argc; i++) { | 742 | for (i = 1; i < argc; i++) { |
743 | if (!strncmp(argv[i], "--cache=", 8)) { | 743 | if (!strncmp(argv[i], "--cache=", 8)) { |
744 | ctx.cfg.cache_root = xstrdup(argv[i]+8); | 744 | ctx.cfg.cache_root = xstrdup(argv[i] + 8); |
745 | } | 745 | } |
746 | if (!strcmp(argv[i], "--nocache")) { | 746 | if (!strcmp(argv[i], "--nocache")) { |
747 | ctx.cfg.nocache = 1; | 747 | ctx.cfg.nocache = 1; |
@@ -750,24 +750,24 @@ static void cgit_parse_args(int argc, const char **argv) | |||
750 | ctx.env.no_http = "1"; | 750 | ctx.env.no_http = "1"; |
751 | } | 751 | } |
752 | if (!strncmp(argv[i], "--query=", 8)) { | 752 | if (!strncmp(argv[i], "--query=", 8)) { |
753 | ctx.qry.raw = xstrdup(argv[i]+8); | 753 | ctx.qry.raw = xstrdup(argv[i] + 8); |
754 | } | 754 | } |
755 | if (!strncmp(argv[i], "--repo=", 7)) { | 755 | if (!strncmp(argv[i], "--repo=", 7)) { |
756 | ctx.qry.repo = xstrdup(argv[i]+7); | 756 | ctx.qry.repo = xstrdup(argv[i] + 7); |
757 | } | 757 | } |
758 | if (!strncmp(argv[i], "--page=", 7)) { | 758 | if (!strncmp(argv[i], "--page=", 7)) { |
759 | ctx.qry.page = xstrdup(argv[i]+7); | 759 | ctx.qry.page = xstrdup(argv[i] + 7); |
760 | } | 760 | } |
761 | if (!strncmp(argv[i], "--head=", 7)) { | 761 | if (!strncmp(argv[i], "--head=", 7)) { |
762 | ctx.qry.head = xstrdup(argv[i]+7); | 762 | ctx.qry.head = xstrdup(argv[i] + 7); |
763 | ctx.qry.has_symref = 1; | 763 | ctx.qry.has_symref = 1; |
764 | } | 764 | } |
765 | if (!strncmp(argv[i], "--sha1=", 7)) { | 765 | if (!strncmp(argv[i], "--sha1=", 7)) { |
766 | ctx.qry.sha1 = xstrdup(argv[i]+7); | 766 | ctx.qry.sha1 = xstrdup(argv[i] + 7); |
767 | ctx.qry.has_sha1 = 1; | 767 | ctx.qry.has_sha1 = 1; |
768 | } | 768 | } |
769 | if (!strncmp(argv[i], "--ofs=", 6)) { | 769 | if (!strncmp(argv[i], "--ofs=", 6)) { |
770 | ctx.qry.ofs = atoi(argv[i]+6); | 770 | ctx.qry.ofs = atoi(argv[i] + 6); |
771 | } | 771 | } |
772 | if (!strncmp(argv[i], "--scan-tree=", 12) || | 772 | if (!strncmp(argv[i], "--scan-tree=", 12) || |
773 | !strncmp(argv[i], "--scan-path=", 12)) { | 773 | !strncmp(argv[i], "--scan-path=", 12)) { |
@@ -834,7 +834,7 @@ int main(int argc, const char **argv) | |||
834 | ctx.cfg.virtual_root = trim_end(ctx.cfg.script_name, '/'); | 834 | ctx.cfg.virtual_root = trim_end(ctx.cfg.script_name, '/'); |
835 | if (!ctx.cfg.virtual_root) | 835 | if (!ctx.cfg.virtual_root) |
836 | ctx.cfg.virtual_root = ""; | 836 | ctx.cfg.virtual_root = ""; |
837 | } | 837 | } |
838 | 838 | ||
839 | /* If no url parameter is specified on the querystring, lets | 839 | /* If no url parameter is specified on the querystring, lets |
840 | * use PATH_INFO as url. This allows cgit to work with virtual | 840 | * use PATH_INFO as url. This allows cgit to work with virtual |
@@ -856,7 +856,7 @@ int main(int argc, const char **argv) | |||
856 | } | 856 | } |
857 | 857 | ||
858 | ttl = calc_ttl(); | 858 | ttl = calc_ttl(); |
859 | ctx.page.expires += ttl*60; | 859 | ctx.page.expires += ttl * 60; |
860 | if (ctx.env.request_method && !strcmp(ctx.env.request_method, "HEAD")) | 860 | if (ctx.env.request_method && !strcmp(ctx.env.request_method, "HEAD")) |
861 | ctx.cfg.nocache = 1; | 861 | ctx.cfg.nocache = 1; |
862 | if (ctx.cfg.nocache) | 862 | if (ctx.cfg.nocache) |
diff --git a/configfile.c b/configfile.c index 4908058..fe5f9c5 100644 --- a/configfile.c +++ b/configfile.c | |||
@@ -13,9 +13,9 @@ | |||
13 | int next_char(FILE *f) | 13 | 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') { |
17 | c = fgetc(f); | 17 | c = fgetc(f); |
18 | if (c!='\n') { | 18 | if (c != '\n') { |
19 | ungetc(c, f); | 19 | ungetc(c, f); |
20 | c = '\r'; | 20 | c = '\r'; |
21 | } | 21 | } |
@@ -27,7 +27,7 @@ void skip_line(FILE *f) | |||
27 | { | 27 | { |
28 | int c; | 28 | int c; |
29 | 29 | ||
30 | while((c=next_char(f)) && c!='\n' && c!=EOF) | 30 | while((c = next_char(f)) && c != '\n' && c != EOF) |
31 | ; | 31 | ; |
32 | } | 32 | } |
33 | 33 | ||
@@ -36,31 +36,31 @@ int read_config_line(FILE *f, char *line, const char **value, int bufsize) | |||
36 | int i = 0, isname = 0; | 36 | int i = 0, isname = 0; |
37 | 37 | ||
38 | *value = NULL; | 38 | *value = NULL; |
39 | while(i<bufsize-1) { | 39 | while(i < bufsize - 1) { |
40 | int c = next_char(f); | 40 | int c = next_char(f); |
41 | if (!isname && (c=='#' || c==';')) { | 41 | if (!isname && (c == '#' || c == ';')) { |
42 | skip_line(f); | 42 | skip_line(f); |
43 | continue; | 43 | continue; |
44 | } | 44 | } |
45 | if (!isname && isspace(c)) | 45 | if (!isname && isspace(c)) |
46 | continue; | 46 | continue; |
47 | 47 | ||
48 | if (c=='=' && !*value) { | 48 | if (c == '=' && !*value) { |
49 | line[i] = 0; | 49 | line[i] = 0; |
50 | *value = &line[i+1]; | 50 | *value = &line[i + 1]; |
51 | } else if (c=='\n' && !isname) { | 51 | } else if (c == '\n' && !isname) { |
52 | i = 0; | 52 | i = 0; |
53 | continue; | 53 | continue; |
54 | } else if (c=='\n' || c==EOF) { | 54 | } else if (c == '\n' || c == EOF) { |
55 | line[i] = 0; | 55 | line[i] = 0; |
56 | break; | 56 | break; |
57 | } else { | 57 | } else { |
58 | line[i]=c; | 58 | line[i] = c; |
59 | } | 59 | } |
60 | isname = 1; | 60 | isname = 1; |
61 | i++; | 61 | i++; |
62 | } | 62 | } |
63 | line[i+1] = 0; | 63 | line[i + 1] = 0; |
64 | return i; | 64 | return i; |
65 | } | 65 | } |
66 | 66 | ||
@@ -54,7 +54,7 @@ char *fmt(const char *format, ...) | |||
54 | va_start(args, format); | 54 | va_start(args, format); |
55 | len = vsnprintf(buf[bufidx], sizeof(buf[bufidx]), format, args); | 55 | len = vsnprintf(buf[bufidx], sizeof(buf[bufidx]), format, args); |
56 | va_end(args); | 56 | va_end(args); |
57 | if (len>sizeof(buf[bufidx])) { | 57 | if (len > sizeof(buf[bufidx])) { |
58 | fprintf(stderr, "[html.c] string truncated: %s\n", format); | 58 | fprintf(stderr, "[html.c] string truncated: %s\n", format); |
59 | exit(1); | 59 | exit(1); |
60 | } | 60 | } |
@@ -94,19 +94,19 @@ void html_txt(const char *txt) | |||
94 | const char *t = txt; | 94 | const char *t = 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 | html_raw(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 == '<') |
102 | html("<"); | 102 | html("<"); |
103 | else if (c=='&') | 103 | else if (c == '&') |
104 | html("&"); | 104 | html("&"); |
105 | txt = t+1; | 105 | txt = t + 1; |
106 | } | 106 | } |
107 | t++; | 107 | t++; |
108 | } | 108 | } |
109 | if (t!=txt) | 109 | if (t != txt) |
110 | html(txt); | 110 | html(txt); |
111 | } | 111 | } |
112 | 112 | ||
@@ -115,21 +115,21 @@ void html_ntxt(int len, const char *txt) | |||
115 | const char *t = txt; | 115 | const char *t = 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 | html_raw(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 == '<') |
123 | html("<"); | 123 | html("<"); |
124 | else if (c=='&') | 124 | else if (c == '&') |
125 | html("&"); | 125 | html("&"); |
126 | txt = t+1; | 126 | txt = t + 1; |
127 | } | 127 | } |
128 | t++; | 128 | t++; |
129 | } | 129 | } |
130 | if (t!=txt) | 130 | if (t != txt) |
131 | html_raw(txt, t - txt); | 131 | html_raw(txt, t - txt); |
132 | if (len<0) | 132 | if (len < 0) |
133 | html("..."); | 133 | html("..."); |
134 | } | 134 | } |
135 | 135 | ||
@@ -138,23 +138,23 @@ void html_attr(const char *txt) | |||
138 | const char *t = txt; | 138 | const char *t = txt; |
139 | while(t && *t){ | 139 | while(t && *t){ |
140 | int c = *t; | 140 | int c = *t; |
141 | if (c=='<' || c=='>' || c=='\'' || c=='\"' || c=='&') { | 141 | if (c == '<' || c == '>' || c == '\'' || c == '\"' || c == '&') { |
142 | html_raw(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 == '<') |
146 | html("<"); | 146 | html("<"); |
147 | else if (c=='\'') | 147 | else if (c == '\'') |
148 | html("'"); | 148 | html("'"); |
149 | else if (c=='"') | 149 | else if (c == '"') |
150 | html("""); | 150 | html("""); |
151 | else if (c=='&') | 151 | else if (c == '&') |
152 | html("&"); | 152 | html("&"); |
153 | txt = t+1; | 153 | txt = t + 1; |
154 | } | 154 | } |
155 | t++; | 155 | t++; |
156 | } | 156 | } |
157 | if (t!=txt) | 157 | if (t != txt) |
158 | html(txt); | 158 | html(txt); |
159 | } | 159 | } |
160 | 160 | ||
@@ -164,14 +164,14 @@ void html_url_path(const char *txt) | |||
164 | while(t && *t){ | 164 | while(t && *t){ |
165 | unsigned char c = *t; | 165 | unsigned char c = *t; |
166 | const char *e = url_escape_table[c]; | 166 | const char *e = url_escape_table[c]; |
167 | if (e && c!='+' && c!='&') { | 167 | if (e && c != '+' && c != '&') { |
168 | html_raw(txt, t - txt); | 168 | html_raw(txt, t - txt); |
169 | html(e); | 169 | html(e); |
170 | txt = t+1; | 170 | txt = t + 1; |
171 | } | 171 | } |
172 | t++; | 172 | t++; |
173 | } | 173 | } |
174 | if (t!=txt) | 174 | if (t != txt) |
175 | html(txt); | 175 | html(txt); |
176 | } | 176 | } |
177 | 177 | ||
@@ -186,11 +186,11 @@ void html_url_arg(const char *txt) | |||
186 | if (e) { | 186 | if (e) { |
187 | html_raw(txt, t - txt); | 187 | html_raw(txt, t - txt); |
188 | html(e); | 188 | html(e); |
189 | txt = t+1; | 189 | txt = t + 1; |
190 | } | 190 | } |
191 | t++; | 191 | t++; |
192 | } | 192 | } |
193 | if (t!=txt) | 193 | if (t != txt) |
194 | html(txt); | 194 | html(txt); |
195 | } | 195 | } |
196 | 196 | ||
@@ -286,14 +286,14 @@ char *convert_query_hexchar(char *txt) | |||
286 | *txt = '\0'; | 286 | *txt = '\0'; |
287 | return txt-1; | 287 | return txt-1; |
288 | } | 288 | } |
289 | d1 = hextoint(*(txt+1)); | 289 | d1 = hextoint(*(txt + 1)); |
290 | d2 = hextoint(*(txt+2)); | 290 | d2 = hextoint(*(txt + 2)); |
291 | if (d1<0 || d2<0) { | 291 | if (d1 < 0 || d2 < 0) { |
292 | memmove(txt, txt+3, n-2); | 292 | memmove(txt, txt + 3, n - 2); |
293 | return txt-1; | 293 | return txt-1; |
294 | } else { | 294 | } else { |
295 | *txt = d1 * 16 + d2; | 295 | *txt = d1 * 16 + d2; |
296 | memmove(txt+1, txt+3, n-2); | 296 | memmove(txt + 1, txt + 3, n - 2); |
297 | return txt; | 297 | return txt; |
298 | } | 298 | } |
299 | } | 299 | } |
@@ -311,22 +311,22 @@ int http_parse_querystring(const char *txt_, void (*fn)(const char *name, const | |||
311 | exit(1); | 311 | exit(1); |
312 | } | 312 | } |
313 | while((c=*t) != '\0') { | 313 | while((c=*t) != '\0') { |
314 | if (c=='=') { | 314 | if (c == '=') { |
315 | *t = '\0'; | 315 | *t = '\0'; |
316 | value = t+1; | 316 | value = t + 1; |
317 | } else if (c=='+') { | 317 | } else if (c == '+') { |
318 | *t = ' '; | 318 | *t = ' '; |
319 | } else if (c=='%') { | 319 | } else if (c == '%') { |
320 | t = convert_query_hexchar(t); | 320 | t = convert_query_hexchar(t); |
321 | } else if (c=='&') { | 321 | } else if (c == '&') { |
322 | *t = '\0'; | 322 | *t = '\0'; |
323 | (*fn)(txt, value); | 323 | (*fn)(txt, value); |
324 | txt = t+1; | 324 | txt = t + 1; |
325 | value = NULL; | 325 | value = NULL; |
326 | } | 326 | } |
327 | t++; | 327 | t++; |
328 | } | 328 | } |
329 | if (t!=txt) | 329 | if (t != txt) |
330 | (*fn)(txt, value); | 330 | (*fn)(txt, value); |
331 | free(o); | 331 | free(o); |
332 | return 0; | 332 | return 0; |
diff --git a/scan-tree.c b/scan-tree.c index 6ce8036..98a99c9 100644 --- a/scan-tree.c +++ b/scan-tree.c | |||
@@ -106,7 +106,7 @@ static void add_repo(const char *base, const char *path, repo_config_fn fn) | |||
106 | config_fn = fn; | 106 | config_fn = fn; |
107 | if (ctx.cfg.enable_git_config) | 107 | if (ctx.cfg.enable_git_config) |
108 | git_config_from_file(gitconfig_config, fmt("%s/config", path), NULL); | 108 | git_config_from_file(gitconfig_config, fmt("%s/config", path), NULL); |
109 | 109 | ||
110 | if (ctx.cfg.remove_suffix) | 110 | if (ctx.cfg.remove_suffix) |
111 | if ((p = strrchr(repo->url, '.')) && !strcmp(p, ".git")) | 111 | if ((p = strrchr(repo->url, '.')) && !strcmp(p, ".git")) |
112 | *p = '\0'; | 112 | *p = '\0'; |
@@ -222,7 +222,7 @@ void scan_projects(const char *path, const char *projectsfile, repo_config_fn fn | |||
222 | char line[MAX_PATH * 2], *z; | 222 | char line[MAX_PATH * 2], *z; |
223 | FILE *projects; | 223 | FILE *projects; |
224 | int err; | 224 | int err; |
225 | 225 | ||
226 | projects = fopen(projectsfile, "r"); | 226 | projects = fopen(projectsfile, "r"); |
227 | if (!projects) { | 227 | if (!projects) { |
228 | fprintf(stderr, "Error opening projectsfile %s: %s (%d)\n", | 228 | fprintf(stderr, "Error opening projectsfile %s: %s (%d)\n", |
@@ -28,8 +28,8 @@ int chk_positive(int result, char *msg) | |||
28 | 28 | ||
29 | int chk_non_negative(int result, char *msg) | 29 | int chk_non_negative(int result, char *msg) |
30 | { | 30 | { |
31 | if (result < 0) | 31 | if (result < 0) |
32 | die("%s: %s",msg, strerror(errno)); | 32 | die("%s: %s", msg, strerror(errno)); |
33 | return result; | 33 | return result; |
34 | } | 34 | } |
35 | 35 | ||
@@ -80,7 +80,7 @@ struct cgit_repo *cgit_get_repoinfo(const char *url) | |||
80 | int i; | 80 | int i; |
81 | struct cgit_repo *repo; | 81 | struct cgit_repo *repo; |
82 | 82 | ||
83 | for (i=0; i<cgit_repolist.count; i++) { | 83 | for (i = 0; i < cgit_repolist.count; i++) { |
84 | repo = &cgit_repolist.repos[i]; | 84 | repo = &cgit_repolist.repos[i]; |
85 | if (!strcmp(repo->url, url)) | 85 | if (!strcmp(repo->url, url)) |
86 | return repo; | 86 | return repo; |
@@ -207,7 +207,7 @@ static int load_mmfile(mmfile_t *file, const unsigned char *sha1) | |||
207 | file->ptr = (char *)""; | 207 | file->ptr = (char *)""; |
208 | file->size = 0; | 208 | file->size = 0; |
209 | } else { | 209 | } else { |
210 | file->ptr = read_sha1_file(sha1, &type, | 210 | file->ptr = read_sha1_file(sha1, &type, |
211 | (unsigned long *)&file->size); | 211 | (unsigned long *)&file->size); |
212 | } | 212 | } |
213 | return 1; | 213 | return 1; |
@@ -354,14 +354,14 @@ int cgit_parse_snapshots_mask(const char *str) | |||
354 | if(atoi(str)) | 354 | if(atoi(str)) |
355 | return 1; | 355 | return 1; |
356 | for(;;) { | 356 | for(;;) { |
357 | str += strspn(str,delim); | 357 | str += strspn(str, delim); |
358 | tl = strcspn(str,delim); | 358 | tl = strcspn(str, delim); |
359 | if (!tl) | 359 | if (!tl) |
360 | break; | 360 | break; |
361 | for (f = cgit_snapshot_formats; f->suffix; f++) { | 361 | for (f = cgit_snapshot_formats; f->suffix; f++) { |
362 | sl = strlen(f->suffix); | 362 | sl = strlen(f->suffix); |
363 | if((tl == sl && !strncmp(f->suffix, str, tl)) || | 363 | if((tl == sl && !strncmp(f->suffix, str, tl)) || |
364 | (tl == sl-1 && !strncmp(f->suffix+1, str, tl-1))) { | 364 | (tl == sl - 1 && !strncmp(f->suffix + 1, str, tl - 1))) { |
365 | rv |= f->bit; | 365 | rv |= f->bit; |
366 | break; | 366 | break; |
367 | } | 367 | } |
@@ -15,12 +15,12 @@ static char *match_path; | |||
15 | static unsigned char *matched_sha1; | 15 | static unsigned char *matched_sha1; |
16 | static int found_path; | 16 | static int found_path; |
17 | 17 | ||
18 | static int walk_tree(const unsigned char *sha1, const char *base,int baselen, | 18 | static int walk_tree(const unsigned char *sha1, const char *base, int baselen, |
19 | const char *pathname, unsigned mode, int stage, void *cbdata) { | 19 | const char *pathname, unsigned mode, int stage, void *cbdata) { |
20 | if(strncmp(base,match_path,baselen) | 20 | if(strncmp(base, match_path, baselen) |
21 | || strcmp(match_path+baselen,pathname) ) | 21 | || strcmp(match_path + baselen, pathname)) |
22 | return READ_TREE_RECURSIVE; | 22 | return READ_TREE_RECURSIVE; |
23 | memmove(matched_sha1,sha1,20); | 23 | memmove(matched_sha1, sha1, 20); |
24 | found_path = 1; | 24 | found_path = 1; |
25 | return 0; | 25 | return 0; |
26 | } | 26 | } |
@@ -85,7 +85,7 @@ void cgit_print_blob(const char *hex, char *path, const char *head) | |||
85 | return; | 85 | return; |
86 | } | 86 | } |
87 | } else { | 87 | } else { |
88 | if (get_sha1(head,sha1)) { | 88 | if (get_sha1(head, sha1)) { |
89 | cgit_print_error(fmt("Bad ref: %s", head)); | 89 | cgit_print_error(fmt("Bad ref: %s", head)); |
90 | return; | 90 | return; |
91 | } | 91 | } |
diff --git a/ui-commit.c b/ui-commit.c index 536a8e8..74f37c8 100644 --- a/ui-commit.c +++ b/ui-commit.c | |||
@@ -39,7 +39,7 @@ void cgit_print_commit(char *hex, const char *prefix) | |||
39 | format_note(NULL, sha1, ¬es, PAGE_ENCODING, 0); | 39 | format_note(NULL, sha1, ¬es, PAGE_ENCODING, 0); |
40 | 40 | ||
41 | load_ref_decorations(DECORATE_FULL_REFS); | 41 | load_ref_decorations(DECORATE_FULL_REFS); |
42 | 42 | ||
43 | cgit_print_diff_ctrls(); | 43 | cgit_print_diff_ctrls(); |
44 | html("<table summary='commit info' class='commit-info'>\n"); | 44 | html("<table summary='commit info' class='commit-info'>\n"); |
45 | html("<tr><th>author</th><td>"); | 45 | html("<tr><th>author</th><td>"); |
@@ -75,7 +75,7 @@ void cgit_print_commit(char *hex, const char *prefix) | |||
75 | cgit_tree_link(prefix, NULL, NULL, ctx.qry.head, tmp, prefix); | 75 | cgit_tree_link(prefix, NULL, NULL, ctx.qry.head, tmp, prefix); |
76 | } | 76 | } |
77 | html("</td></tr>\n"); | 77 | html("</td></tr>\n"); |
78 | for (p = commit->parents; p ; p = p->next) { | 78 | for (p = commit->parents; p; p = p->next) { |
79 | parent = lookup_commit_reference(p->item->object.sha1); | 79 | parent = lookup_commit_reference(p->item->object.sha1); |
80 | if (!parent) { | 80 | if (!parent) { |
81 | html("<tr><td colspan='3'>"); | 81 | html("<tr><td colspan='3'>"); |
@@ -200,7 +200,7 @@ void cgit_print_branches(int maxcount) | |||
200 | qsort(list.refs, maxcount, sizeof(*list.refs), cmp_ref_name); | 200 | qsort(list.refs, maxcount, sizeof(*list.refs), cmp_ref_name); |
201 | } | 201 | } |
202 | 202 | ||
203 | for(i=0; i<maxcount; i++) | 203 | for(i = 0; i < maxcount; i++) |
204 | print_branch(list.refs[i]); | 204 | print_branch(list.refs[i]); |
205 | 205 | ||
206 | if (maxcount < list.count) | 206 | if (maxcount < list.count) |
@@ -224,7 +224,7 @@ void cgit_print_tags(int maxcount) | |||
224 | else if (maxcount > list.count) | 224 | else if (maxcount > list.count) |
225 | maxcount = list.count; | 225 | maxcount = list.count; |
226 | print_tag_header(); | 226 | print_tag_header(); |
227 | for(i=0; i<maxcount; i++) | 227 | for(i = 0; i < maxcount; i++) |
228 | print_tag(list.refs[i]); | 228 | print_tag(list.refs[i]); |
229 | 229 | ||
230 | if (maxcount < list.count) | 230 | if (maxcount < list.count) |
diff --git a/ui-repolist.c b/ui-repolist.c index 2a910bd..449478d 100644 --- a/ui-repolist.c +++ b/ui-repolist.c | |||
@@ -131,8 +131,8 @@ void print_pager(int items, int pagelen, char *search, char *sort) | |||
131 | html("<div class='pager'>"); | 131 | html("<div class='pager'>"); |
132 | for(i = 0, ofs = 0; ofs < items; i++, ofs = i * pagelen) { | 132 | for(i = 0, ofs = 0; ofs < items; i++, ofs = i * pagelen) { |
133 | class = (ctx.qry.ofs == ofs) ? "current" : NULL; | 133 | class = (ctx.qry.ofs == ofs) ? "current" : NULL; |
134 | cgit_index_link(fmt("[%d]", i+1), fmt("Page %d", i+1), class, | 134 | cgit_index_link(fmt("[%d]", i + 1), fmt("Page %d", i + 1), |
135 | search, sort, ofs); | 135 | class, search, sort, ofs); |
136 | } | 136 | } |
137 | html("</div>"); | 137 | html("</div>"); |
138 | } | 138 | } |
@@ -264,7 +264,7 @@ void cgit_print_repolist() | |||
264 | sort_repolist("section"); | 264 | sort_repolist("section"); |
265 | 265 | ||
266 | html("<table summary='repository list' class='list nowrap'>"); | 266 | html("<table summary='repository list' class='list nowrap'>"); |
267 | for (i=0; i<cgit_repolist.count; i++) { | 267 | for (i = 0; i < cgit_repolist.count; i++) { |
268 | ctx.repo = &cgit_repolist.repos[i]; | 268 | ctx.repo = &cgit_repolist.repos[i]; |
269 | if (!(is_match(ctx.repo) && is_in_url(ctx.repo))) | 269 | if (!(is_match(ctx.repo) && is_in_url(ctx.repo))) |
270 | continue; | 270 | continue; |
diff --git a/ui-shared.c b/ui-shared.c index c4fb437..1a28dce 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -23,7 +23,7 @@ static char *http_date(time_t t) | |||
23 | "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; | 23 | "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; |
24 | struct tm *tm = gmtime(&t); | 24 | struct tm *tm = gmtime(&t); |
25 | return fmt("%s, %02d %s %04d %02d:%02d:%02d GMT", day[tm->tm_wday], | 25 | return fmt("%s, %02d %s %04d %02d:%02d:%02d GMT", day[tm->tm_wday], |
26 | tm->tm_mday, month[tm->tm_mon], 1900+tm->tm_year, | 26 | tm->tm_mday, month[tm->tm_mon], 1900 + tm->tm_year, |
27 | tm->tm_hour, tm->tm_min, tm->tm_sec); | 27 | tm->tm_hour, tm->tm_min, tm->tm_sec); |
28 | } | 28 | } |
29 | 29 | ||
@@ -93,7 +93,7 @@ char *cgit_fileurl(const char *reponame, const char *pagename, | |||
93 | char *cgit_pageurl(const char *reponame, const char *pagename, | 93 | char *cgit_pageurl(const char *reponame, const char *pagename, |
94 | const char *query) | 94 | const char *query) |
95 | { | 95 | { |
96 | return cgit_fileurl(reponame,pagename,0,query); | 96 | return cgit_fileurl(reponame, pagename, 0, query); |
97 | } | 97 | } |
98 | 98 | ||
99 | const char *cgit_repobasename(const char *reponame) | 99 | const char *cgit_repobasename(const char *reponame) |
@@ -102,18 +102,18 @@ const char *cgit_repobasename(const char *reponame) | |||
102 | static char rvbuf[1024]; | 102 | static char rvbuf[1024]; |
103 | int p; | 103 | int p; |
104 | const char *rv; | 104 | const char *rv; |
105 | strncpy(rvbuf,reponame,sizeof(rvbuf)); | 105 | strncpy(rvbuf, reponame, sizeof(rvbuf)); |
106 | if(rvbuf[sizeof(rvbuf)-1]) | 106 | if(rvbuf[sizeof(rvbuf)-1]) |
107 | die("cgit_repobasename: truncated repository name '%s'", reponame); | 107 | die("cgit_repobasename: truncated repository name '%s'", reponame); |
108 | p = strlen(rvbuf)-1; | 108 | p = strlen(rvbuf)-1; |
109 | /* strip trailing slashes */ | 109 | /* strip trailing slashes */ |
110 | while(p && rvbuf[p]=='/') rvbuf[p--]=0; | 110 | while(p && rvbuf[p] == '/') rvbuf[p--] = 0; |
111 | /* strip trailing .git */ | 111 | /* strip trailing .git */ |
112 | if(p>=3 && !strncmp(&rvbuf[p-3],".git",4)) { | 112 | if(p >= 3 && !strncmp(&rvbuf[p-3], ".git", 4)) { |
113 | p -= 3; rvbuf[p--] = 0; | 113 | p -= 3; rvbuf[p--] = 0; |
114 | } | 114 | } |
115 | /* strip more trailing slashes if any */ | 115 | /* strip more trailing slashes if any */ |
116 | while( p && rvbuf[p]=='/') rvbuf[p--]=0; | 116 | while( p && rvbuf[p] == '/') rvbuf[p--] = 0; |
117 | /* find last slash in the remaining string */ | 117 | /* find last slash in the remaining string */ |
118 | rv = strrchr(rvbuf,'/'); | 118 | rv = strrchr(rvbuf,'/'); |
119 | if(rv) | 119 | if(rv) |
@@ -499,7 +499,7 @@ void cgit_object_link(struct object *obj) | |||
499 | shortrev = xstrdup(fullrev); | 499 | shortrev = xstrdup(fullrev); |
500 | shortrev[10] = '\0'; | 500 | shortrev[10] = '\0'; |
501 | if (obj->type == OBJ_COMMIT) { | 501 | if (obj->type == OBJ_COMMIT) { |
502 | cgit_commit_link(fmt("commit %s...", shortrev), NULL, NULL, | 502 | cgit_commit_link(fmt("commit %s...", shortrev), NULL, NULL, |
503 | ctx.qry.head, fullrev, NULL, 0); | 503 | ctx.qry.head, fullrev, NULL, 0); |
504 | return; | 504 | return; |
505 | } else if (obj->type == OBJ_TREE) | 505 | } else if (obj->type == OBJ_TREE) |
@@ -736,7 +736,7 @@ int print_archive_ref(const char *refname, const unsigned char *sha1, | |||
736 | 736 | ||
737 | if (prefixcmp(refname, "refs/archives")) | 737 | if (prefixcmp(refname, "refs/archives")) |
738 | return 0; | 738 | return 0; |
739 | strncpy(buf, refname+14, sizeof(buf)); | 739 | strncpy(buf, refname + 14, sizeof(buf)); |
740 | obj = parse_object(sha1); | 740 | obj = parse_object(sha1); |
741 | if (!obj) | 741 | if (!obj) |
742 | return 1; | 742 | return 1; |
@@ -968,7 +968,7 @@ void cgit_print_snapshot_links(const char *repo, const char *head, | |||
968 | { | 968 | { |
969 | const struct cgit_snapshot_format* f; | 969 | const struct cgit_snapshot_format* f; |
970 | char *prefix; | 970 | char *prefix; |
971 | char *filename; | 971 | char *filename; |
972 | unsigned char sha1[20]; | 972 | unsigned char sha1[20]; |
973 | 973 | ||
974 | if (get_sha1(fmt("refs/tags/%s", hex), sha1) == 0 && | 974 | if (get_sha1(fmt("refs/tags/%s", hex), sha1) == 0 && |
@@ -23,21 +23,21 @@ static void trunc_week(struct tm *tm) | |||
23 | { | 23 | { |
24 | time_t t = timegm(tm); | 24 | time_t t = timegm(tm); |
25 | t -= ((tm->tm_wday + 6) % 7) * DAY_SECS; | 25 | t -= ((tm->tm_wday + 6) % 7) * DAY_SECS; |
26 | gmtime_r(&t, tm); | 26 | gmtime_r(&t, tm); |
27 | } | 27 | } |
28 | 28 | ||
29 | static void dec_week(struct tm *tm) | 29 | static void dec_week(struct tm *tm) |
30 | { | 30 | { |
31 | time_t t = timegm(tm); | 31 | time_t t = timegm(tm); |
32 | t -= WEEK_SECS; | 32 | t -= WEEK_SECS; |
33 | gmtime_r(&t, tm); | 33 | gmtime_r(&t, tm); |
34 | } | 34 | } |
35 | 35 | ||
36 | static void inc_week(struct tm *tm) | 36 | static void inc_week(struct tm *tm) |
37 | { | 37 | { |
38 | time_t t = timegm(tm); | 38 | time_t t = timegm(tm); |
39 | t += WEEK_SECS; | 39 | t += WEEK_SECS; |
40 | gmtime_r(&t, tm); | 40 | gmtime_r(&t, tm); |
41 | } | 41 | } |
42 | 42 | ||
43 | static char *pretty_week(struct tm *tm) | 43 | static char *pretty_week(struct tm *tm) |
@@ -153,7 +153,7 @@ int cgit_find_stats_period(const char *expr, struct cgit_period **period) | |||
153 | if (periods[i].code == code || !strcmp(periods[i].name, expr)) { | 153 | if (periods[i].code == code || !strcmp(periods[i].name, expr)) { |
154 | if (period) | 154 | if (period) |
155 | *period = &periods[i]; | 155 | *period = &periods[i]; |
156 | return i+1; | 156 | return i + 1; |
157 | } | 157 | } |
158 | return 0; | 158 | return 0; |
159 | } | 159 | } |
@@ -99,6 +99,6 @@ void cgit_print_tag(char *revname) | |||
99 | if (ctx.repo->snapshots) | 99 | if (ctx.repo->snapshots) |
100 | print_download_links(revname); | 100 | print_download_links(revname); |
101 | html("</table>\n"); | 101 | html("</table>\n"); |
102 | } | 102 | } |
103 | return; | 103 | return; |
104 | } | 104 | } |
@@ -27,7 +27,7 @@ static void print_text_buffer(const char *name, char *buf, unsigned long size) | |||
27 | html("<tr><td class='linenumbers'><pre>"); | 27 | html("<tr><td class='linenumbers'><pre>"); |
28 | idx = 0; | 28 | idx = 0; |
29 | lineno = 0; | 29 | lineno = 0; |
30 | 30 | ||
31 | if (size) { | 31 | if (size) { |
32 | htmlf(numberfmt, ++lineno); | 32 | htmlf(numberfmt, ++lineno); |
33 | while(idx < size - 1) { // skip absolute last newline | 33 | while(idx < size - 1) { // skip absolute last newline |
@@ -228,7 +228,7 @@ static int walk_tree(const unsigned char *sha1, const char *base, int baselen, | |||
228 | 228 | ||
229 | if (state == 0) { | 229 | if (state == 0) { |
230 | memcpy(buffer, base, baselen); | 230 | memcpy(buffer, base, baselen); |
231 | strcpy(buffer+baselen, pathname); | 231 | strcpy(buffer + baselen, pathname); |
232 | if (strcmp(match_path, buffer)) | 232 | if (strcmp(match_path, buffer)) |
233 | return READ_TREE_RECURSIVE; | 233 | return READ_TREE_RECURSIVE; |
234 | 234 | ||