bug-sed
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#25459: sed bug: native sed-4.3 appends excessive carriage-returns wh


From: Assaf Gordon
Subject: bug#25459: sed bug: native sed-4.3 appends excessive carriage-returns when run in binary mode on windows
Date: Tue, 17 Jan 2017 19:25:43 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1

Hello,

Thank you for the report.

I do not have access to MSVC, but I can see similar issues when building
with mingw on cygwin64.

Before jumping to the fix, I'd like to show what I'm experiencing,
because there might be a larger issue here.

I'm testing on a Windows R2008 with cygwin64.
I've compared 3 binaries (below):
  sed-4.2.2-cygwin.exe:
      The default that's installed by cygwin itself.

  sed-4.3-cygwin-gcc-5.4.0.exe:
      Built from tarball using cygwin's default gcc compiler.

  sed-4.3-mingw-64bit.exe:
      Built from tarball using:
      ./configure --host=x86_64-w64-mingw32 --disable-nls


First,
sed-4.2.2 seems to produce incorrect output without "-b":
The output file is not set to text mode, and only '\n' is written
(without '\r').

second,
It seems the new sed-4.3-mingw does output extra '\r',
but only if the input is a file (and not stdin).

So there's some unclear interplay here (unclear to me).

The proposed patch does produce the correct output,
but I'd like to verify it's for the right reasons.

Lastly,
There's also testing needed with in-place writing of files,
and adding tests.

I hope to get to all of these soon.

regards,
 - assaf

$ env printf '1\x0D\x0A' > test

$ ./sed-4.2.2-cygwin.exe -b "" < test | od -tx1 -An
 31 0d 0a
$ ./sed-4.2.2-cygwin.exe -b ""   test | od -tx1 -An
 31 0d 0a
$ ./sed-4.2.2-cygwin.exe    "" < test | od -tx1 -An
 31 0a
$ ./sed-4.2.2-cygwin.exe    ""   test | od -tx1 -An
 31 0a


$ ./sed-4.3-cygwin-gcc-5.4.0.exe -b "" < test | od -tx1 -An
 31 0d 0a
$ ./sed-4.3-cygwin-gcc-5.4.0.exe -b ""   test | od -tx1 -An
 31 0d 0a
$ ./sed-4.3-cygwin-gcc-5.4.0.exe    "" < test | od -tx1 -An
 31 0d 0a
$ ./sed-4.3-cygwin-gcc-5.4.0.exe    ""   test | od -tx1 -An
 31 0d 0a



$ ./sed-4.3-mingw-64bit.exe -b "" < test | od -tx1 -An
 31 0d 0a
$ ./sed-4.3-mingw-64bit.exe -b ""   test | od -tx1 -An
 31 0d 0d 0a
$ ./sed-4.3-mingw-64bit.exe    "" < test | od -tx1 -An
 31 0d 0a
$ ./sed-4.3-mingw-64bit.exe    ""   test | od -tx1 -An
 31 0d 0a






reply via email to

[Prev in Thread] Current Thread [Next in Thread]