-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | html.c | 4 | ||||
-rw-r--r-- | ui-log.c | 71 | ||||
-rw-r--r-- | vector.c | 38 | ||||
-rw-r--r-- | vector.h | 17 |
5 files changed, 118 insertions, 13 deletions
@@ -94,48 +94,49 @@ OBJECTS += cache.o | |||
94 | OBJECTS += cgit.o | 94 | OBJECTS += cgit.o |
95 | OBJECTS += cmd.o | 95 | OBJECTS += cmd.o |
96 | OBJECTS += configfile.o | 96 | OBJECTS += configfile.o |
97 | OBJECTS += html.o | 97 | OBJECTS += html.o |
98 | OBJECTS += parsing.o | 98 | OBJECTS += parsing.o |
99 | OBJECTS += scan-tree.o | 99 | OBJECTS += scan-tree.o |
100 | OBJECTS += shared.o | 100 | OBJECTS += shared.o |
101 | OBJECTS += ui-atom.o | 101 | OBJECTS += ui-atom.o |
102 | OBJECTS += ui-blob.o | 102 | OBJECTS += ui-blob.o |
103 | OBJECTS += ui-clone.o | 103 | OBJECTS += ui-clone.o |
104 | OBJECTS += ui-commit.o | 104 | OBJECTS += ui-commit.o |
105 | OBJECTS += ui-diff.o | 105 | OBJECTS += ui-diff.o |
106 | OBJECTS += ui-log.o | 106 | OBJECTS += ui-log.o |
107 | OBJECTS += ui-patch.o | 107 | OBJECTS += ui-patch.o |
108 | OBJECTS += ui-plain.o | 108 | OBJECTS += ui-plain.o |
109 | OBJECTS += ui-refs.o | 109 | OBJECTS += ui-refs.o |
110 | OBJECTS += ui-repolist.o | 110 | OBJECTS += ui-repolist.o |
111 | OBJECTS += ui-shared.o | 111 | OBJECTS += ui-shared.o |
112 | OBJECTS += ui-snapshot.o | 112 | OBJECTS += ui-snapshot.o |
113 | OBJECTS += ui-ssdiff.o | 113 | OBJECTS += ui-ssdiff.o |
114 | OBJECTS += ui-stats.o | 114 | OBJECTS += ui-stats.o |
115 | OBJECTS += ui-summary.o | 115 | OBJECTS += ui-summary.o |
116 | OBJECTS += ui-tag.o | 116 | OBJECTS += ui-tag.o |
117 | OBJECTS += ui-tree.o | 117 | OBJECTS += ui-tree.o |
118 | OBJECTS += vector.o | ||
118 | 119 | ||
119 | ifdef NEEDS_LIBICONV | 120 | ifdef NEEDS_LIBICONV |
120 | EXTLIBS += -liconv | 121 | EXTLIBS += -liconv |
121 | endif | 122 | endif |
122 | 123 | ||
123 | 124 | ||
124 | .PHONY: all libgit test install uninstall clean force-version get-git \ | 125 | .PHONY: all libgit test install uninstall clean force-version get-git \ |
125 | doc clean-doc install-doc install-man install-html install-pdf \ | 126 | doc clean-doc install-doc install-man install-html install-pdf \ |
126 | uninstall-doc uninstall-man uninstall-html uninstall-pdf | 127 | uninstall-doc uninstall-man uninstall-html uninstall-pdf |
127 | 128 | ||
128 | all: cgit | 129 | all: cgit |
129 | 130 | ||
130 | VERSION: force-version | 131 | VERSION: force-version |
131 | @./gen-version.sh "$(CGIT_VERSION)" | 132 | @./gen-version.sh "$(CGIT_VERSION)" |
132 | -include VERSION | 133 | -include VERSION |
133 | 134 | ||
134 | 135 | ||
135 | CFLAGS += -g -Wall -Igit | 136 | CFLAGS += -g -Wall -Igit |
136 | CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER)' | 137 | CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER)' |
137 | CFLAGS += -DCGIT_VERSION='"$(CGIT_VERSION)"' | 138 | CFLAGS += -DCGIT_VERSION='"$(CGIT_VERSION)"' |
138 | CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"' | 139 | CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"' |
139 | CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"' | 140 | CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"' |
140 | CFLAGS += -DCGIT_CACHE_ROOT='"$(CACHE_ROOT)"' | 141 | CFLAGS += -DCGIT_CACHE_ROOT='"$(CACHE_ROOT)"' |
141 | 142 | ||
@@ -1,45 +1,45 @@ | |||
1 | /* html.c: helper functions for html output | 1 | /* html.c: helper functions for html output |
2 | * | 2 | * |
3 | * Copyright (C) 2006 Lars Hjemli | 3 | * Copyright (C) 2006 Lars Hjemli |
4 | * | 4 | * |
5 | * Licensed under GNU General Public License v2 | 5 | * Licensed under GNU General Public License v2 |
6 | * (see COPYING for full license text) | 6 | * (see COPYING for full license text) |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <unistd.h> | 9 | #include <unistd.h> |
10 | #include <stdio.h> | 10 | #include <stdio.h> |
11 | #include <stdlib.h> | 11 | #include <stdlib.h> |
12 | #include <stdarg.h> | 12 | #include <stdarg.h> |
13 | #include <string.h> | 13 | #include <string.h> |
14 | #include <errno.h> | 14 | #include <errno.h> |
15 | 15 | ||
16 | /* Percent-encoding of each character, except: a-zA-Z0-9!$()*,./:;@- */ | 16 | /* Percent-encoding of each character, except: a-zA-Z0-9!$()*,./:;@- */ |
17 | static const char* url_escape_table[256] = { | 17 | static const char* url_escape_table[256] = { |
18 | "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07", "%08", "%09", | 18 | "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07", "%08", "%09", |
19 | "%0a", "%0b", "%0c", "%0d", "%0e", "%0f", "%10", "%11", "%12", "%13", | 19 | "%0a", "%0b", "%0c", "%0d", "%0e", "%0f", "%10", "%11", "%12", "%13", |
20 | "%14", "%15", "%16", "%17", "%18", "%19", "%1a", "%1b", "%1c", "%1d", | 20 | "%14", "%15", "%16", "%17", "%18", "%19", "%1a", "%1b", "%1c", "%1d", |
21 | "%1e", "%1f", "%20", 0, "%22", "%23", 0, "%25", "%26", "%27", 0, 0, 0, | 21 | "%1e", "%1f", "+", 0, "%22", "%23", 0, "%25", "%26", "%27", 0, 0, 0, |
22 | "%2b", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "%3c", "%3d", | 22 | "%2b", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "%3c", "%3d", |
23 | "%3e", "%3f", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 23 | "%3e", "%3f", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
24 | 0, 0, 0, 0, 0, 0, 0, 0, 0, "%5c", 0, "%5e", 0, "%60", 0, 0, 0, 0, 0, | 24 | 0, 0, 0, 0, 0, 0, 0, 0, 0, "%5c", 0, "%5e", 0, "%60", 0, 0, 0, 0, 0, |
25 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "%7b", | 25 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "%7b", |
26 | "%7c", "%7d", 0, "%7f", "%80", "%81", "%82", "%83", "%84", "%85", | 26 | "%7c", "%7d", 0, "%7f", "%80", "%81", "%82", "%83", "%84", "%85", |
27 | "%86", "%87", "%88", "%89", "%8a", "%8b", "%8c", "%8d", "%8e", "%8f", | 27 | "%86", "%87", "%88", "%89", "%8a", "%8b", "%8c", "%8d", "%8e", "%8f", |
28 | "%90", "%91", "%92", "%93", "%94", "%95", "%96", "%97", "%98", "%99", | 28 | "%90", "%91", "%92", "%93", "%94", "%95", "%96", "%97", "%98", "%99", |
29 | "%9a", "%9b", "%9c", "%9d", "%9e", "%9f", "%a0", "%a1", "%a2", "%a3", | 29 | "%9a", "%9b", "%9c", "%9d", "%9e", "%9f", "%a0", "%a1", "%a2", "%a3", |
30 | "%a4", "%a5", "%a6", "%a7", "%a8", "%a9", "%aa", "%ab", "%ac", "%ad", | 30 | "%a4", "%a5", "%a6", "%a7", "%a8", "%a9", "%aa", "%ab", "%ac", "%ad", |
31 | "%ae", "%af", "%b0", "%b1", "%b2", "%b3", "%b4", "%b5", "%b6", "%b7", | 31 | "%ae", "%af", "%b0", "%b1", "%b2", "%b3", "%b4", "%b5", "%b6", "%b7", |
32 | "%b8", "%b9", "%ba", "%bb", "%bc", "%bd", "%be", "%bf", "%c0", "%c1", | 32 | "%b8", "%b9", "%ba", "%bb", "%bc", "%bd", "%be", "%bf", "%c0", "%c1", |
33 | "%c2", "%c3", "%c4", "%c5", "%c6", "%c7", "%c8", "%c9", "%ca", "%cb", | 33 | "%c2", "%c3", "%c4", "%c5", "%c6", "%c7", "%c8", "%c9", "%ca", "%cb", |
34 | "%cc", "%cd", "%ce", "%cf", "%d0", "%d1", "%d2", "%d3", "%d4", "%d5", | 34 | "%cc", "%cd", "%ce", "%cf", "%d0", "%d1", "%d2", "%d3", "%d4", "%d5", |
35 | "%d6", "%d7", "%d8", "%d9", "%da", "%db", "%dc", "%dd", "%de", "%df", | 35 | "%d6", "%d7", "%d8", "%d9", "%da", "%db", "%dc", "%dd", "%de", "%df", |
36 | "%e0", "%e1", "%e2", "%e3", "%e4", "%e5", "%e6", "%e7", "%e8", "%e9", | 36 | "%e0", "%e1", "%e2", "%e3", "%e4", "%e5", "%e6", "%e7", "%e8", "%e9", |
37 | "%ea", "%eb", "%ec", "%ed", "%ee", "%ef", "%f0", "%f1", "%f2", "%f3", | 37 | "%ea", "%eb", "%ec", "%ed", "%ee", "%ef", "%f0", "%f1", "%f2", "%f3", |
38 | "%f4", "%f5", "%f6", "%f7", "%f8", "%f9", "%fa", "%fb", "%fc", "%fd", | 38 | "%f4", "%f5", "%f6", "%f7", "%f8", "%f9", "%fa", "%fb", "%fc", "%fd", |
39 | "%fe", "%ff" | 39 | "%fe", "%ff" |
40 | }; | 40 | }; |
41 | 41 | ||
42 | int htmlfd = STDOUT_FILENO; | 42 | int htmlfd = STDOUT_FILENO; |
43 | 43 | ||
44 | char *fmt(const char *format, ...) | 44 | char *fmt(const char *format, ...) |
45 | { | 45 | { |
@@ -160,49 +160,49 @@ void html_url_path(const char *txt) | |||
160 | { | 160 | { |
161 | const char *t = txt; | 161 | const char *t = txt; |
162 | while(t && *t){ | 162 | while(t && *t){ |
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 | html_raw(txt, t - txt); | 166 | html_raw(txt, t - txt); |
167 | html_raw(e, 3); | 167 | html_raw(e, 3); |
168 | txt = t+1; | 168 | txt = t+1; |
169 | } | 169 | } |
170 | t++; | 170 | t++; |
171 | } | 171 | } |
172 | if (t!=txt) | 172 | if (t!=txt) |
173 | html(txt); | 173 | html(txt); |
174 | } | 174 | } |
175 | 175 | ||
176 | void html_url_arg(const char *txt) | 176 | void html_url_arg(const char *txt) |
177 | { | 177 | { |
178 | const char *t = txt; | 178 | const char *t = txt; |
179 | while(t && *t){ | 179 | while(t && *t){ |
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 | html_raw(txt, t - txt); | 183 | html_raw(txt, t - txt); |
184 | html_raw(e, 3); | 184 | html_raw(e, strlen(e)); |
185 | txt = t+1; | 185 | txt = t+1; |
186 | } | 186 | } |
187 | t++; | 187 | t++; |
188 | } | 188 | } |
189 | if (t!=txt) | 189 | if (t!=txt) |
190 | html(txt); | 190 | html(txt); |
191 | } | 191 | } |
192 | 192 | ||
193 | void html_hidden(const char *name, const char *value) | 193 | void html_hidden(const char *name, const char *value) |
194 | { | 194 | { |
195 | html("<input type='hidden' name='"); | 195 | html("<input type='hidden' name='"); |
196 | html_attr(name); | 196 | html_attr(name); |
197 | html("' value='"); | 197 | html("' value='"); |
198 | html_attr(value); | 198 | html_attr(value); |
199 | html("'/>"); | 199 | html("'/>"); |
200 | } | 200 | } |
201 | 201 | ||
202 | void html_option(const char *value, const char *text, const char *selected_value) | 202 | void html_option(const char *value, const char *text, const char *selected_value) |
203 | { | 203 | { |
204 | html("<option value='"); | 204 | html("<option value='"); |
205 | html_attr(value); | 205 | html_attr(value); |
206 | html("'"); | 206 | html("'"); |
207 | if (selected_value && !strcmp(selected_value, value)) | 207 | if (selected_value && !strcmp(selected_value, value)) |
208 | html(" selected='selected'"); | 208 | html(" selected='selected'"); |
@@ -1,35 +1,36 @@ | |||
1 | /* ui-log.c: functions for log output | 1 | /* ui-log.c: functions for log output |
2 | * | 2 | * |
3 | * Copyright (C) 2006 Lars Hjemli | 3 | * Copyright (C) 2006 Lars Hjemli |
4 | * | 4 | * |
5 | * Licensed under GNU General Public License v2 | 5 | * Licensed under GNU General Public License v2 |
6 | * (see COPYING for full license text) | 6 | * (see COPYING for full license text) |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include "cgit.h" | 9 | #include "cgit.h" |
10 | #include "html.h" | 10 | #include "html.h" |
11 | #include "ui-shared.h" | 11 | #include "ui-shared.h" |
12 | #include "vector.h" | ||
12 | 13 | ||
13 | int files, add_lines, rem_lines; | 14 | int files, add_lines, rem_lines; |
14 | 15 | ||
15 | void count_lines(char *line, int size) | 16 | void count_lines(char *line, int size) |
16 | { | 17 | { |
17 | if (size <= 0) | 18 | if (size <= 0) |
18 | return; | 19 | return; |
19 | 20 | ||
20 | if (line[0] == '+') | 21 | if (line[0] == '+') |
21 | add_lines++; | 22 | add_lines++; |
22 | 23 | ||
23 | else if (line[0] == '-') | 24 | else if (line[0] == '-') |
24 | rem_lines++; | 25 | rem_lines++; |
25 | } | 26 | } |
26 | 27 | ||
27 | void inspect_files(struct diff_filepair *pair) | 28 | void inspect_files(struct diff_filepair *pair) |
28 | { | 29 | { |
29 | unsigned long old_size = 0; | 30 | unsigned long old_size = 0; |
30 | unsigned long new_size = 0; | 31 | unsigned long new_size = 0; |
31 | int binary = 0; | 32 | int binary = 0; |
32 | 33 | ||
33 | files++; | 34 | files++; |
34 | if (ctx.repo->enable_log_linecount) | 35 | if (ctx.repo->enable_log_linecount) |
35 | cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size, | 36 | cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size, |
@@ -127,80 +128,128 @@ void print_commit(struct commit *commit) | |||
127 | html("<tr class='nohover'>"); | 128 | html("<tr class='nohover'>"); |
128 | html("<td class='lognotes-label'>Notes:</td>"); | 129 | html("<td class='lognotes-label'>Notes:</td>"); |
129 | htmlf("<td colspan='%d' class='lognotes'>", | 130 | htmlf("<td colspan='%d' class='lognotes'>", |
130 | cols); | 131 | cols); |
131 | html_txt(notes.buf); | 132 | html_txt(notes.buf); |
132 | html("</td></tr>\n"); | 133 | html("</td></tr>\n"); |
133 | } | 134 | } |
134 | strbuf_release(¬es); | 135 | strbuf_release(¬es); |
135 | } | 136 | } |
136 | cgit_free_commitinfo(info); | 137 | cgit_free_commitinfo(info); |
137 | } | 138 | } |
138 | 139 | ||
139 | static const char *disambiguate_ref(const char *ref) | 140 | static const char *disambiguate_ref(const char *ref) |
140 | { | 141 | { |
141 | unsigned char sha1[20]; | 142 | unsigned char sha1[20]; |
142 | const char *longref; | 143 | const char *longref; |
143 | 144 | ||
144 | longref = fmt("refs/heads/%s", ref); | 145 | longref = fmt("refs/heads/%s", ref); |
145 | if (get_sha1(longref, sha1) == 0) | 146 | if (get_sha1(longref, sha1) == 0) |
146 | return longref; | 147 | return longref; |
147 | 148 | ||
148 | return ref; | 149 | return ref; |
149 | } | 150 | } |
150 | 151 | ||
152 | static char *next_token(char **src) | ||
153 | { | ||
154 | char *result; | ||
155 | |||
156 | if (!src || !*src) | ||
157 | return NULL; | ||
158 | while (isspace(**src)) | ||
159 | (*src)++; | ||
160 | if (!**src) | ||
161 | return NULL; | ||
162 | result = *src; | ||
163 | while (**src) { | ||
164 | if (isspace(**src)) { | ||
165 | **src = '\0'; | ||
166 | (*src)++; | ||
167 | break; | ||
168 | } | ||
169 | (*src)++; | ||
170 | } | ||
171 | return result; | ||
172 | } | ||
173 | |||
151 | void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern, | 174 | void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern, |
152 | char *path, int pager) | 175 | char *path, int pager) |
153 | { | 176 | { |
154 | struct rev_info rev; | 177 | struct rev_info rev; |
155 | struct commit *commit; | 178 | struct commit *commit; |
156 | const char *argv[] = {NULL, NULL, NULL, NULL, NULL}; | 179 | struct vector vec = VECTOR_INIT(char *); |
157 | int argc = 2; | ||
158 | int i, columns = 3; | 180 | int i, columns = 3; |
181 | char *arg; | ||
182 | |||
183 | /* First argv is NULL */ | ||
184 | vector_push(&vec, NULL, 0); | ||
159 | 185 | ||
160 | if (!tip) | 186 | if (!tip) |
161 | tip = ctx.qry.head; | 187 | tip = ctx.qry.head; |
162 | 188 | tip = disambiguate_ref(tip); | |
163 | argv[1] = disambiguate_ref(tip); | 189 | vector_push(&vec, &tip, 0); |
164 | 190 | ||
165 | if (grep && pattern && *pattern) { | 191 | if (grep && pattern && *pattern) { |
192 | pattern = xstrdup(pattern); | ||
166 | if (!strcmp(grep, "grep") || !strcmp(grep, "author") || | 193 | if (!strcmp(grep, "grep") || !strcmp(grep, "author") || |
167 | !strcmp(grep, "committer")) | 194 | !strcmp(grep, "committer")) { |
168 | argv[argc++] = fmt("--%s=%s", grep, pattern); | 195 | arg = fmt("--%s=%s", grep, pattern); |
169 | if (!strcmp(grep, "range")) | 196 | vector_push(&vec, &arg, 0); |
170 | argv[1] = pattern; | 197 | } |
198 | if (!strcmp(grep, "range")) { | ||
199 | /* Split the pattern at whitespace and add each token | ||
200 | * as a revision expression. Do not accept other | ||
201 | * rev-list options. Also, replace the previously | ||
202 | * pushed tip (it's no longer relevant). | ||
203 | */ | ||
204 | vec.count--; | ||
205 | while ((arg = next_token(&pattern))) { | ||
206 | if (*arg == '-') { | ||
207 | fprintf(stderr, "Bad range expr: %s\n", | ||
208 | arg); | ||
209 | break; | ||
210 | } | ||
211 | vector_push(&vec, &arg, 0); | ||
212 | } | ||
213 | } | ||
171 | } | 214 | } |
172 | 215 | ||
173 | if (path) { | 216 | if (path) { |
174 | argv[argc++] = "--"; | 217 | arg = "--"; |
175 | argv[argc++] = path; | 218 | vector_push(&vec, &arg, 0); |
219 | vector_push(&vec, &path, 0); | ||
176 | } | 220 | } |
221 | |||
222 | /* Make sure the vector is NULL-terminated */ | ||
223 | vector_push(&vec, NULL, 0); | ||
224 | vec.count--; | ||
225 | |||
177 | init_revisions(&rev, NULL); | 226 | init_revisions(&rev, NULL); |
178 | rev.abbrev = DEFAULT_ABBREV; | 227 | rev.abbrev = DEFAULT_ABBREV; |
179 | rev.commit_format = CMIT_FMT_DEFAULT; | 228 | rev.commit_format = CMIT_FMT_DEFAULT; |
180 | rev.verbose_header = 1; | 229 | rev.verbose_header = 1; |
181 | rev.show_root_diff = 0; | 230 | rev.show_root_diff = 0; |
182 | setup_revisions(argc, argv, &rev, NULL); | 231 | setup_revisions(vec.count, vec.data, &rev, NULL); |
183 | load_ref_decorations(DECORATE_FULL_REFS); | 232 | load_ref_decorations(DECORATE_FULL_REFS); |
184 | rev.show_decorations = 1; | 233 | rev.show_decorations = 1; |
185 | rev.grep_filter.regflags |= REG_ICASE; | 234 | rev.grep_filter.regflags |= REG_ICASE; |
186 | compile_grep_patterns(&rev.grep_filter); | 235 | compile_grep_patterns(&rev.grep_filter); |
187 | prepare_revision_walk(&rev); | 236 | prepare_revision_walk(&rev); |
188 | 237 | ||
189 | if (pager) | 238 | if (pager) |
190 | html("<table class='list nowrap'>"); | 239 | html("<table class='list nowrap'>"); |
191 | 240 | ||
192 | html("<tr class='nohover'><th class='left'>Age</th>" | 241 | html("<tr class='nohover'><th class='left'>Age</th>" |
193 | "<th class='left'>Commit message"); | 242 | "<th class='left'>Commit message"); |
194 | if (pager) { | 243 | if (pager) { |
195 | html(" ("); | 244 | html(" ("); |
196 | cgit_log_link(ctx.qry.showmsg ? "Collapse" : "Expand", NULL, | 245 | cgit_log_link(ctx.qry.showmsg ? "Collapse" : "Expand", NULL, |
197 | NULL, ctx.qry.head, ctx.qry.sha1, | 246 | NULL, ctx.qry.head, ctx.qry.sha1, |
198 | ctx.qry.vpath, ctx.qry.ofs, ctx.qry.grep, | 247 | ctx.qry.vpath, ctx.qry.ofs, ctx.qry.grep, |
199 | ctx.qry.search, ctx.qry.showmsg ? 0 : 1); | 248 | ctx.qry.search, ctx.qry.showmsg ? 0 : 1); |
200 | html(")"); | 249 | html(")"); |
201 | } | 250 | } |
202 | html("</th><th class='left'>Author</th>"); | 251 | html("</th><th class='left'>Author</th>"); |
203 | if (ctx.repo->enable_log_filecount) { | 252 | if (ctx.repo->enable_log_filecount) { |
204 | html("<th class='left'>Files</th>"); | 253 | html("<th class='left'>Files</th>"); |
205 | columns++; | 254 | columns++; |
206 | if (ctx.repo->enable_log_linecount) { | 255 | if (ctx.repo->enable_log_linecount) { |
diff --git a/vector.c b/vector.c new file mode 100644 index 0000000..0863908 --- a/dev/null +++ b/vector.c | |||
@@ -0,0 +1,38 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <string.h> | ||
3 | #include <errno.h> | ||
4 | #include "vector.h" | ||
5 | |||
6 | static int grow(struct vector *vec, int gently) | ||
7 | { | ||
8 | size_t new_alloc; | ||
9 | void *new_data; | ||
10 | |||
11 | new_alloc = vec->alloc * 3 / 2; | ||
12 | if (!new_alloc) | ||
13 | new_alloc = 8; | ||
14 | new_data = realloc(vec->data, new_alloc * vec->size); | ||
15 | if (!new_data) { | ||
16 | if (gently) | ||
17 | return ENOMEM; | ||
18 | perror("vector.c:grow()"); | ||
19 | exit(1); | ||
20 | } | ||
21 | vec->data = new_data; | ||
22 | vec->alloc = new_alloc; | ||
23 | return 0; | ||
24 | } | ||
25 | |||
26 | int vector_push(struct vector *vec, const void *data, int gently) | ||
27 | { | ||
28 | int rc; | ||
29 | |||
30 | if (vec->count == vec->alloc && (rc = grow(vec, gently))) | ||
31 | return rc; | ||
32 | if (data) | ||
33 | memmove(vec->data + vec->count * vec->size, data, vec->size); | ||
34 | else | ||
35 | memset(vec->data + vec->count * vec->size, 0, vec->size); | ||
36 | vec->count++; | ||
37 | return 0; | ||
38 | } | ||
diff --git a/vector.h b/vector.h new file mode 100644 index 0000000..c64eb1f --- a/dev/null +++ b/vector.h | |||
@@ -0,0 +1,17 @@ | |||
1 | #ifndef CGIT_VECTOR_H | ||
2 | #define CGIT_VECTOR_H | ||
3 | |||
4 | #include <stdlib.h> | ||
5 | |||
6 | struct vector { | ||
7 | size_t size; | ||
8 | size_t count; | ||
9 | size_t alloc; | ||
10 | void *data; | ||
11 | }; | ||
12 | |||
13 | #define VECTOR_INIT(type) {sizeof(type), 0, 0, NULL} | ||
14 | |||
15 | int vector_push(struct vector *vec, const void *data, int gently); | ||
16 | |||
17 | #endif /* CGIT_VECTOR_H */ | ||