summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a0ae35a)
raw | patch | inline | side by side (parent: a0ae35a)
author | Johannes Sixt <johannes.sixt@telecom.at> | |
Fri, 19 Oct 2007 19:48:05 +0000 (21:48 +0200) | ||
committer | Shawn O. Pearce <spearce@spearce.org> | |
Sun, 21 Oct 2007 05:30:42 +0000 (01:30 -0400) |
When apply_filter() runs the external (clean or smudge) filter program, it
needs to pass the writable end of a pipe as its stdout. For this purpose,
it used to dup2(2) the file descriptor explicitly to stdout. Now we use
the facilities of start_command() to do it for us.
Furthermore, the path argument of a subordinate function, filter_buffer(),
was not used, so here we replace it to pass the fd instead.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
needs to pass the writable end of a pipe as its stdout. For this purpose,
it used to dup2(2) the file descriptor explicitly to stdout. Now we use
the facilities of start_command() to do it for us.
Furthermore, the path argument of a subordinate function, filter_buffer(),
was not used, so here we replace it to pass the fd instead.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
convert.c | patch | blob | history |
diff --git a/convert.c b/convert.c
index d83c2fcc5e2afb9b9e19d232ce38f7bec91513ce..8dc9965081320c52152fb635354ee26a0ad693f7 100644 (file)
--- a/convert.c
+++ b/convert.c
return 1;
}
-static int filter_buffer(const char *path, const char *src,
+static int filter_buffer(int fd, const char *src,
unsigned long size, const char *cmd)
{
/*
memset(&child_process, 0, sizeof(child_process));
child_process.argv = argv;
child_process.in = -1;
+ child_process.out = fd;
if (start_command(&child_process))
return error("cannot fork to run external filter %s", cmd);
return 0;
}
if (!child_process.pid) {
- dup2(pipe_feed[1], 1);
close(pipe_feed[0]);
- close(pipe_feed[1]);
- exit(filter_buffer(path, src, len, cmd));
+ exit(filter_buffer(pipe_feed[1], src, len, cmd));
}
close(pipe_feed[1]);