tarsh / open-vcdiff

Automatically exported from code.google.com/p/open-vcdiff
Apache License 2.0
0 stars 0 forks source link

vcdiff incorrect binary I/O on Windows #7

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
On Windows, stdin and stdout are open in text mode, not binary mode, by 
default. This means, for example, that even data that were conceived as 
and seemingly being output as binary to stdout, are in fact processed by 
the runtime to perform CR LF translation. If it encounters unpaired LF, it 
outputs CR LF instead etc.

What steps will reproduce the problem?
vcdiff encode --dictionary test.dict < in.txt > diff.diff
vcdiff decode --dictionary test.dict < diff.diff > out.txt

Please find in.txt attached. (in.txt can be any binary file that contains 
a 0x0A without 0x0D. A UNIX text file, transferred to Windows in binary 
mode will be OK too.)

What is the expected output? What do you see instead?
out.txt has different content from in.txt (even different size), I expect 
them to be identical. (fc /b in.txt out.txt)

BTW when compared in text mode (fc in.txt out.txt), they are "identical".

What version of the product are you using? On what operating system?
Microsoft Visual Studio 2008 Version 9.0.21022.8 RTM
OS Name Microsoft Windows XP Professional   
Version 5.1.2600 Service Pack 2 Build 2600  

Please provide any additional information below.

Note, that this
vcdiff encode --dictionary test.dict --target in.txt --delta diff.diff
vcdiff decode --dictionary test.dict --delta diff.diff --target out.txt
works OK.

I suggest something of the sort to be inserted in vcdiff berore any I/O 
takes place:

#ifdef WIN32
   setmode(fileno(stdout), O_BINARY);
   setmode(fileno(stdin), O_BINARY);
#endif

Original issue reported on code.google.com by s...@sl.iae.nsk.su on 11 Sep 2008 at 11:02

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by lincoln1...@gmail.com on 22 Oct 2008 at 10:40

GoogleCodeExporter commented 9 years ago

Original comment by openvcd...@gmail.com on 23 Oct 2008 at 12:21

GoogleCodeExporter commented 9 years ago
Fixed in open-vcdiff v0.4.  Please let me know if you find that the problem 
still 
exists.  Thanks again.

Original comment by openvcd...@gmail.com on 24 Oct 2008 at 12:20