[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-diffutils] [PATCH] use binary-io gnulib module instead of xfreo
From: |
Jim Meyering |
Subject: |
Re: [bug-diffutils] [PATCH] use binary-io gnulib module instead of xfreopen |
Date: |
Tue, 04 Oct 2011 13:58:42 +0200 |
Claudio Bley wrote:
> (I already posted a message yesterday, but apparently it didn't come
> through. Sorry, if this is a duplicate.)
>
> Using NULL as filename in xfreopen is non-portable. It doesn't work on
> MinGW, it crashes using MSVC.
>
> Here is a patch using the binary-io gnulib module instead, as suggested
> by Bruno Haible on the gnulib bugs ML.
...
> Subject: [PATCH] Use gnulib's binary-io module instead of xfreopen to change
> the translation mode.
>
> ---
> bootstrap.conf | 1 +
> src/cmp.c | 4 ++--
> src/diff.c | 6 +++---
> 3 files changed, 6 insertions(+), 5 deletions(-)
Thank you for the patch.
I have adjusted your commit log to conform to our style
guidelines (see HACKING) and will push this shortly.
>From 7508234eabe646abcea074baea83612f8115d3b9 Mon Sep 17 00:00:00 2001
From: Claudio Bley <address@hidden>
Date: Sun, 4 Sep 2011 18:01:57 +0200
Subject: [PATCH] portability: use SET_BINARY rather than xfreopen (NULL, ...
* src/diff.c: Include binary-io.h, not xfreopen.h.
(main): Use SET_BINARY (...) rather than xfreopen (NULL, X, ...),
because the latter doesn't work on MinGW and crashes using MSVC.
* src/cmp.c (main): Likewise.
---
bootstrap.conf | 1 +
src/cmp.c | 4 ++--
src/diff.c | 6 +++---
3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/bootstrap.conf b/bootstrap.conf
index cc6d88c..c4e340e 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -19,6 +19,7 @@
# gnulib modules used by this package.
gnulib_modules='
announce-gen
+binary-io
c-stack
config-h
diffseq
diff --git a/src/cmp.c b/src/cmp.c
index adf1cf9..2620b0f 100644
--- a/src/cmp.c
+++ b/src/cmp.c
@@ -33,7 +33,7 @@
#include <unlocked-io.h>
#include <version-etc.h>
#include <xalloc.h>
-#include <xfreopen.h>
+#include <binary-io.h>
#include <xstrtol.h>
/* The official name of this program (e.g., no `g' prefix). */
@@ -293,7 +293,7 @@ main (int argc, char **argv)
{
file_desc[f1] = STDIN_FILENO;
if (O_BINARY && ! isatty (STDIN_FILENO))
- xfreopen (NULL, "rb", stdin);
+ SET_BINARY (STDIN_FILENO);
}
else
file_desc[f1] = open (file[f1], O_RDONLY | O_BINARY, 0);
diff --git a/src/diff.c b/src/diff.c
index c096406..170d42f 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -39,7 +39,7 @@
#include <timespec.h>
#include <version-etc.h>
#include <xalloc.h>
-#include <xfreopen.h>
+#include <binary-io.h>
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "diff"
@@ -525,7 +525,7 @@ main (int argc, char **argv)
#if O_BINARY
binary = true;
if (! isatty (STDOUT_FILENO))
- xfreopen (NULL, "wb", stdout);
+ SET_BINARY (STDOUT_FILENO);
#endif
break;
@@ -1108,7 +1108,7 @@ compare_files (struct comparison const *parent,
{
cmp.file[f].desc = STDIN_FILENO;
if (O_BINARY && binary && ! isatty (STDIN_FILENO))
- xfreopen (NULL, "rb", stdin);
+ SET_BINARY (STDIN_FILENO);
if (fstat (STDIN_FILENO, &cmp.file[f].stat) != 0)
cmp.file[f].desc = ERRNO_ENCODE (errno);
else
--
1.7.7.rc0.362.g5a14
- Re: [bug-diffutils] [PATCH] use binary-io gnulib module instead of xfreopen,
Jim Meyering <=