Subject: bug#25707: [PATCH] grep: don't forcefully strip carriage returns

From: Paul Eggert <[email-masked]>
Date: Mon, 13 Feb 2017 12:00:43 -0800

On 02/13/2017 11:23 AM, Eric Blake wrote:
> the use of fopen("rt") actively
> breaks assumptions on a binary mount by silently corrupting any
> carriage returns that are supposed to be preserved.

Surely it's more typical for trailing CRs to be ignored rather than be 
preserved, even on binary mounts.

The intent of that "rt" (introduced on 2014-04-11 in commit 
5c92a54ec36f176854f0b0cca83b5ff224f2d8e8) was to simplify the code, 
which formerly used undossify_input to guess whether a pattern file had 
trailing CRs. If we change "rt" to "r", surely we'd need to reintroduce 
undossify_input; and wouldn't undossify_input also "silently corrupt" 
carriage returns in most cases?

While we're on the topic, the undossify_input approach is just a 
heuristic and it sometimes guesses wrong. I wish the heuristic could be 
removed somehow, so that grep would behave more deterministically on 
MS-DOS/Windows.