From: Lars Hjemli Date: Mon, 23 May 2011 21:28:38 +0000 (+0200) Subject: Merge branch 'fh/filter-api' X-Git-Tag: v0.9.1~65 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ab350a77b1d3b0e251cc28329f2e16f0566e521e;p=cgit Merge branch 'fh/filter-api' Conflicts: cgit.c --- ab350a77b1d3b0e251cc28329f2e16f0566e521e diff --cc cgit.c index eb964ac,5d6e488..6be3754 --- a/cgit.c +++ b/cgit.c @@@ -26,20 -26,31 +26,33 @@@ void add_mimetype(const char *name, con item->util = xstrdup(value); } - struct cgit_filter *new_filter(const char *cmd, int extra_args) + struct cgit_filter *new_filter(const char *cmd, filter_type filtertype) { struct cgit_filter *f; + int args_size = 0; + int extra_args; if (!cmd || !cmd[0]) return NULL; + switch (filtertype) { + case SOURCE: + extra_args = 1; + break; + + case ABOUT: + case COMMIT: + default: + extra_args = 0; + break; + } + f = xmalloc(sizeof(struct cgit_filter)); f->cmd = xstrdup(cmd); - f->argv = xmalloc((2 + extra_args) * sizeof(char *)); + args_size = (2 + extra_args) * sizeof(char *); + f->argv = xmalloc(args_size); + memset(f->argv, 0, args_size); f->argv[0] = f->cmd; - f->argv[1] = NULL; return f; } diff --cc ui-tree.c index 442b6be,835c166..2d8d2f3 --- a/ui-tree.c +++ b/ui-tree.c @@@ -45,11 -45,9 +45,11 @@@ static void print_text_buffer(const cha if (ctx.repo->source_filter) { html("
");
  		ctx.repo->source_filter->argv[1] = xstrdup(name);
- 		cgit_open_filter(ctx.repo->source_filter);
+ 		cgit_open_filter(ctx.repo->source_filter, ctx.repo);
  		html_raw(buf, size);
  		cgit_close_filter(ctx.repo->source_filter);
 +		free(ctx.repo->source_filter->argv[1]);
 +		ctx.repo->source_filter->argv[1] = NULL;
  		html("
\n"); return; }