>From f5330d22155a1f77a16fee945e22d8ac23fbb142 Mon Sep 17 00:00:00 2001 From: Assaf Gordon
Date: Thu, 18 Oct 2018 14:42:41 -0600 Subject: [PATCH] sed: fix -b/--binary mode under windows/mingw * NEWS: Mention change. * doc/sed.texi (options): Mention -b/--binary option does not apply under cygwin. * sed/sed.h (WINDOWS_BINARY_MODE_SUPPORT): Define symbol under mingw. * sed/sed.c (main): Set stdin/stdout to binary mode if needed. --- NEWS | 3 +++ doc/sed.texi | 5 +++-- sed/sed.c | 23 +++++++++++++++++++++-- sed/sed.h | 5 +++++ 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index e25d26b..1766260 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,9 @@ GNU sed NEWS -*- outline -*- and other write commands. Buffering can be disabled (as before) with "sed -u". + sed in non-cygwin windows environments (e.g. mingw) now properly handles + '\n' newlines in -b/--binary mode. + ** Bug fixes sed no longer accesses invalid memory (heap overflow) when given invalid diff --git a/doc/sed.texi b/doc/sed.texi index 8fc9dbb..b6b0618 100644 --- a/doc/sed.texi +++ b/doc/sed.texi @@ -363,8 +363,9 @@ to a non-empty value. @opindex --binary This option is available on every platform, but is only effective where the operating system makes a distinction between text files and binary files. -When such a distinction is made---as is the case for MS-DOS, Windows, -Cygwin---text files are composed of lines separated by a carriage return +When such a distinction is made---as is the case for MS-DOS, Windows +(but not modern Cygwin)---text files are composed of lines separated by a +carriage return @emph{and} a line feed character, and @command{sed} does not see the ending CR. When this option is specified, @command{sed} will open input files in binary mode, thus not requesting this special processing diff --git a/sed/sed.c b/sed/sed.c index 1508f38..e3b3efd 100644 --- a/sed/sed.c +++ b/sed/sed.c @@ -31,6 +31,10 @@ #include "version-etc.h" +#ifdef WINDOWS_BINARY_MODE_SUPPORT +#include