[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-diffutils] [PATCH 15/19] use xfreopen rather than freopen
From: |
Jim Meyering |
Subject: |
[bug-diffutils] [PATCH 15/19] use xfreopen rather than freopen |
Date: |
Fri, 20 Nov 2009 10:12:24 +0100 |
From: Jim Meyering <address@hidden>
* src/cmp.c: Include "xfreopen.h".
Use xfreopen in place of freopen.
* src/diff.c Likewise, and...
(main): Set exit_failure to EXIT_TROUBLE, rather than to 2.
* src/diff3.c: Likewise.
* bootstrap.conf (gnulib_modules): Add xfreopen.
---
bootstrap.conf | 1 +
src/cmp.c | 3 ++-
src/diff.c | 7 ++++---
src/diff3.c | 6 +++---
4 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/bootstrap.conf b/bootstrap.conf
index d89bd4d..d474aca 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -66,6 +66,7 @@ version-etc
version-etc-fsf
wcwidth
xalloc
+xfreopen
xstrtoumax
'
diff --git a/src/cmp.c b/src/cmp.c
index 0111e37..72b2690 100644
--- a/src/cmp.c
+++ b/src/cmp.c
@@ -33,6 +33,7 @@
#include <unlocked-io.h>
#include <version-etc.h>
#include <xalloc.h>
+#include <xfreopen.h>
#include <xstrtol.h>
/* The official name of this program (e.g., no `g' prefix). */
@@ -286,7 +287,7 @@ main (int argc, char **argv)
{
file_desc[f1] = STDIN_FILENO;
if (O_BINARY && ! isatty (STDIN_FILENO))
- freopen (NULL, "rb", stdin);
+ xfreopen (NULL, "rb", stdin);
}
else
file_desc[f1] = open (file[f1], O_RDONLY | O_BINARY, 0);
diff --git a/src/diff.c b/src/diff.c
index 5e82381..f7b3991 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -38,6 +38,7 @@
#include <timespec.h>
#include <version-etc.h>
#include <xalloc.h>
+#include <xfreopen.h>
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "diff"
@@ -271,7 +272,7 @@ main (int argc, char **argv)
char *numend;
/* Do our initializations. */
- exit_failure = 2;
+ exit_failure = EXIT_TROUBLE;
initialize_main (&argc, &argv);
set_program_name (argv[0]);
setlocale (LC_ALL, "");
@@ -517,7 +518,7 @@ main (int argc, char **argv)
#if O_BINARY
binary = true;
if (! isatty (STDOUT_FILENO))
- freopen (NULL, "wb", stdout);
+ xfreopen (NULL, "wb", stdout);
#endif
break;
@@ -1086,7 +1087,7 @@ compare_files (struct comparison const *parent,
{
cmp.file[f].desc = STDIN_FILENO;
if (binary && ! isatty (STDIN_FILENO))
- freopen (NULL, "rb", stdin);
+ xfreopen (NULL, "rb", stdin);
if (fstat (STDIN_FILENO, &cmp.file[f].stat) != 0)
cmp.file[f].desc = ERRNO_ENCODE (errno);
else
diff --git a/src/diff3.c b/src/diff3.c
index bd6a96e..01abdca 100644
--- a/src/diff3.c
+++ b/src/diff3.c
@@ -33,6 +33,7 @@
#include <sh-quote.h>
#include <version-etc.h>
#include <xalloc.h>
+#include <xfreopen.h>
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "diff3"
@@ -229,7 +230,7 @@ main (int argc, char **argv)
char **file;
struct stat statb;
- exit_failure = 2;
+ exit_failure = EXIT_TROUBLE;
initialize_main (&argc, &argv);
set_program_name (argv[0]);
setlocale (LC_ALL, "");
@@ -387,8 +388,7 @@ main (int argc, char **argv)
tag_strings[0], tag_strings[1], tag_strings[2]);
else if (merge)
{
- if (! freopen (file[rev_mapping[FILE0]], "r", stdin))
- perror_with_exit (file[rev_mapping[FILE0]]);
+ xfreopen (file[rev_mapping[FILE0]], "r", stdin);
conflicts_found
= output_diff3_merge (stdin, stdout, diff3, mapping, rev_mapping,
tag_strings[0], tag_strings[1], tag_strings[2]);
--
1.6.5.3.433.g11067
- [bug-diffutils] [PATCH 01/19] tests: add the first script; hook up gnulib-tests, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 06/19] build: avoid link failure when libsigsegv is used, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 05/19] maint: define/use PROGRAM_NAME and AUTHORS; use propername module, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 14/19] build: enable many warnings, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 02/19] sdiff, diff3: exec diff, not $(bindir)/diff, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 19/19] maint: remove hard-coded macro definitions provided by intprops.h, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 04/19] maint: no longer define *_FILENO constants, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 12/19] build: update gnulib submodule to latest, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 17/19] build: suppress warnings about bindtextdomain and textdomain, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 15/19] use xfreopen rather than freopen,
Jim Meyering <=
- [bug-diffutils] [PATCH 10/19] build: let automake generate better man-installation rules, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 11/19] maint: hide build commands behind $(AM_V_GEN), Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 18/19] maint: add gnulib's announce-gen module, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 16/19] build: use more gnulib modules, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 13/19] build: "make stable" emitted an invalid gnupload command, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 07/19] admin: ignore all of gnulib-tests, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 03/19] maint: address@hidden is the new bug-reporting address, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 09/19] maint: add an assertion to suppress clang-detected warning, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 08/19] maint: remove dead assignment from diff3.c, Jim Meyering, 2009/11/20