By default, C runtime when creating or opening files would use so-called text mode , which means translating LF to CRLF when writing, and CRLF to LF when reading.
This is because traditionally, Windows text files used CRLF to indicate end of line. For a while already, since Notepad gained ability to read text files with whatever ending , none of this is necessary. CRT and other libraries have supported reading and writing text files with LF, since very long time.
Yet, the added CRLF adds some obscurity whenever it comes to MariaDB (search for 'Win' in this test ported from MySQL.
Moreover, there had been subtle bugs in text mode over the years in the C runtime.
MDEV-9409 had been quit a pain, and recent one I came across,
Nobody benefits from having a extra character inserted and removed every line, at least not since Notepad was fixed. But I think MariaDB would benefit very much from removing obscure code fragments, where it reads "remove \r unconditionally on Windows" in the source code , without much explanation, and then many extra lines were added in the test case to compensate for platform differences (I actually doubt that --binary-mode works on Windows, at all)
- set binary mode on stdin,stdout,stderr, as well as set_fmode() to prevent text-mode by default, already during my_init.
- remove questionable code fragments (basically, search for '\r' mentioned in code, in conjunction with Windows)
- fix questionable tests that assume Windows would be different and handle \r in its special way.