summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2017-02-13 13:23:58 -0600
committerPaul Eggert <eggert@cs.ucla.edu>2017-02-16 08:54:41 -0800
commit5398777784b4455aa8466c1aef48b5738b8cd626 (patch)
treee610dd495112a668707ba331e67c04b1a961d0cb /src
parente1ca01be48cb64e5eaa6b5b29910e7eea1719f91 (diff)
downloadgrep-5398777784b4455aa8466c1aef48b5738b8cd626.tar.gz
grep: don't forcefully strip carriage returns
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") (Bug#25707).
Diffstat (limited to 'src')
-rw-r--r--src/grep.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/grep.c b/src/grep.c
index 5bc4cd5e..437ae0a5 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -2582,7 +2582,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;