aboutsummaryrefslogtreecommitdiffstats
path: root/ui-summary.c
diff options
context:
space:
mode:
authorJason A. Donenfeld2013-05-25 14:50:19 +0200
committerJason A. Donenfeld2013-05-25 20:33:28 +0200
commitc0dfaf1c281d0697ce43131343d7a9f170a61ff9 (patch)
treee52a47596e72d9a7f1ebb19fd4fe5b3a39d95567 /ui-summary.c
parent3cb5d86dc68bab4883bf5a7cbc90f3e266237355 (diff)
downloadcgit-c0dfaf1c281d0697ce43131343d7a9f170a61ff9.tar.gz
cgit-c0dfaf1c281d0697ce43131343d7a9f170a61ff9.tar.bz2
cgit-c0dfaf1c281d0697ce43131343d7a9f170a61ff9.zip
ui-summary: Pass filename to about-filter
This gives the about-filter API the same semantics as source-filter, where the filter receives the filename so it can decide what to do next with it. While we're at it, plug a memory leak. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui-summary.c')
-rw-r--r--ui-summary.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/ui-summary.c b/ui-summary.c
index abf914e..ffad4f2 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -98,6 +98,7 @@ void cgit_print_summary()
98void cgit_print_repo_readme(char *path) 98void cgit_print_repo_readme(char *path)
99{ 99{
100 char *slash, *tmp, *colon, *ref; 100 char *slash, *tmp, *colon, *ref;
101 int free_filename = 0;
101 102
102 if (!ctx.repo->readme || !(*ctx.repo->readme)) 103 if (!ctx.repo->readme || !(*ctx.repo->readme))
103 return; 104 return;
@@ -134,6 +135,7 @@ void cgit_print_repo_readme(char *path)
134 return; 135 return;
135 slash = colon; 136 slash = colon;
136 } 137 }
138 free_filename = 1;
137 tmp = xmalloc(slash - ctx.repo->readme + 1 + strlen(path) + 1); 139 tmp = xmalloc(slash - ctx.repo->readme + 1 + strlen(path) + 1);
138 strncpy(tmp, ctx.repo->readme, slash - ctx.repo->readme + 1); 140 strncpy(tmp, ctx.repo->readme, slash - ctx.repo->readme + 1);
139 strcpy(tmp + (slash - ctx.repo->readme + 1), path); 141 strcpy(tmp + (slash - ctx.repo->readme + 1), path);
@@ -144,13 +146,19 @@ void cgit_print_repo_readme(char *path)
144 * filesystem, while applying the about-filter. 146 * filesystem, while applying the about-filter.
145 */ 147 */
146 html("<div id='summary'>"); 148 html("<div id='summary'>");
147 if (ctx.repo->about_filter) 149 if (ctx.repo->about_filter) {
150 ctx.repo->about_filter->argv[1] = tmp;
148 cgit_open_filter(ctx.repo->about_filter); 151 cgit_open_filter(ctx.repo->about_filter);
152 }
149 if (ref) 153 if (ref)
150 cgit_print_file(tmp, ref); 154 cgit_print_file(tmp, ref);
151 else 155 else
152 html_include(tmp); 156 html_include(tmp);
153 if (ctx.repo->about_filter) 157 if (ctx.repo->about_filter) {
154 cgit_close_filter(ctx.repo->about_filter); 158 cgit_close_filter(ctx.repo->about_filter);
159 ctx.repo->about_filter->argv[1] = NULL;
160 }
155 html("</div>"); 161 html("</div>");
162 if (free_filename)
163 free(tmp);
156} 164}