[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#25707: [PATCH] grep: don't forcefully strip carriage returns
From: |
Eric Blake |
Subject: |
bug#25707: [PATCH] grep: don't forcefully strip carriage returns |
Date: |
Mon, 13 Feb 2017 13:23:58 -0600 |
Commit 5c92a54 made the mistaken assumption that using fopen("rt")
on platforms where O_TEXT is non-zero makes sense. However, POSIX
already requires fopen("r") to open a file in text mode, vs.
fopen("rb") when binary mode is wanted, and at least on Cygwin,
where it is possible to control whether a mount point is binary
or text by default (using just "r"), the use of fopen("rt") actively
breaks assumptions on a binary mount by silently corrupting any
carriage returns that are supposed to be preserved.
* src/grep.c (main): Never use fopen("rt").
Signed-off-by: Eric Blake <address@hidden>
---
src/grep.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/grep.c b/src/grep.c
index 74acb0b..ce8859b 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -2586,7 +2586,7 @@ main (int argc, char **argv)
break;
case 'f':
- fp = STREQ (optarg, "-") ? stdin : fopen (optarg, O_TEXT ? "rt" : "r");
+ fp = STREQ (optarg, "-") ? stdin : fopen (optarg, "r");
if (!fp)
die (EXIT_TROUBLE, errno, "%s", optarg);
oldcc = keycc;
--
2.9.3