Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Oct 14, 2025. It is now read-only.

Conversation

@rossy
Copy link
Contributor

@rossy rossy commented Aug 22, 2015

The previous fix didn't work for me. I suspect because it changed the state of the fd back to _O_TEXT without flushing the file beforehand, so when the end of the file was flushed to the _O_TEXT fd, it got the \r\n conversion again. As mentioned at the end of #56, I don't think it's necessary to change the stream back to _O_TEXT, so this just removes that call.

This also removes a redundant comment (the code should work regardless of new-line conversion now) and indents another comment.

Tested with MSYS2/mingw-w64 on Windows 8.1 with a few small text files and one larger binary file.

The previous fix didn't work in all situations. I suspect it's because
it was changing the state of the fd back to _O_TEXT mode without
synchronising with fflush(). Changing the mode back to _O_TEXT isn't
actually needed (see discussion in google#56,) so just remove the call.
@rossy rossy mentioned this pull request Aug 22, 2015
lvandeve added a commit that referenced this pull request Aug 22, 2015
@lvandeve lvandeve merged commit 89cf773 into google:master Aug 22, 2015
@rossy rossy deleted the setmode-fix branch August 22, 2015 15:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants