diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2012-05-14 23:07:13 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2012-05-14 23:08:59 -0700 |
commit | 3549f733b9cd2c7fd5dd1e4a273151e2da01a00b (patch) | |
tree | dae7ccaa474f677c43c47b7f92e9b5ff37deef50 /src/diff3.c | |
parent | de512b8345de9d501b21a5c1bc446e28d50ebf8c (diff) | |
download | diffutils-3549f733b9cd2c7fd5dd1e4a273151e2da01a00b.tar.gz |
main: port subcommands to mingw
Problem reported by Eli Zaretskii in
<http://lists.gnu.org/archive/html/bug-gnu-utils/2012-05/msg00013.html>.
Approach suggested by Bruno Haible as option (4) in
<http://lists.gnu.org/archive/html/bug-gnu-utils/2012-05/msg00036.html>.
* bootstrap.conf (gnulib_modules): Add system-quote.
* src/diff3.c, src/sdiff.c, src/util.c:
Include <system-quote.h>, not <sh-quote.h>.
* src/diff3.c (read_diff):
* src/sdiff.c (main, edit):
* src/util.c (begin_output):
Use system_quote_argv, for portability to Mingw.
* src/sdiff.c (NUM_SIGS, handler_index_of_SIGINT): Now enum
values, not macros; this is cleaner and avoids a GCC warning if
!HAVE_WORKING_VFORK.
* src/util.c (begin_output) [! HAVE_WORKING_FORK]: Do not use -f,
for consistency with the HAVE_WORKING_FORK code.
Diffstat (limited to 'src/diff3.c')
-rw-r--r-- | src/diff3.c | 39 |
1 files changed, 9 insertions, 30 deletions
diff --git a/src/diff3.c b/src/diff3.c index 3b01071..e234401 100644 --- a/src/diff3.c +++ b/src/diff3.c @@ -29,7 +29,7 @@ #include <file-type.h> #include <getopt.h> #include <progname.h> -#include <sh-quote.h> +#include <system-quote.h> #include <version-etc.h> #include <xalloc.h> #include <xfreopen.h> @@ -1161,13 +1161,15 @@ read_diff (char const *filea, int fd, wstatus, status; int werrno = 0; struct stat pipestat; - -#if HAVE_WORKING_FORK - char const *argv[9]; char const **ap; +#if HAVE_WORKING_FORK int fds[2]; pid_t pid; +#else + FILE *fpipe; + char *command; +#endif ap = argv; *ap++ = diff_program; @@ -1181,6 +1183,8 @@ read_diff (char const *filea, *ap++ = fileb; *ap = 0; +#if HAVE_WORKING_FORK + if (pipe (fds) != 0) perror_with_exit ("pipe"); @@ -1210,32 +1214,7 @@ read_diff (char const *filea, #else - FILE *fpipe; - char const args[] = " --horizon-lines=100 -- "; - char *command = xmalloc (shell_quote_length (diff_program) - + sizeof "-a" - + sizeof "--strip-trailing-cr" - + sizeof args - 1 - + shell_quote_length (filea) + 1 - + shell_quote_length (fileb) + 1); - char *p = command; - p = shell_quote_copy (p, diff_program); - if (text) - { - strcpy (p, " -a"); - p += 3; - } - if (strip_trailing_cr) - { - strcpy (p, " --strip-trailing-cr"); - p += 20; - } - strcpy (p, args); - p += sizeof args - 1; - p = shell_quote_copy (p, filea); - *p++ = ' '; - p = shell_quote_copy (p, fileb); - *p = 0; + command = system_quote_argv (SCI_SYSTEM, (char **) argv); errno = 0; fpipe = popen (command, "r"); if (!fpipe) |