summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2022-02-02 01:58:09 +0100
committerVladislav Vaintroub <wlad@mariadb.com>2022-07-18 13:18:03 +0200
commit016dd21371961700f1324f204acbc7252a8c1e76 (patch)
treed46d79e595078bab217a2318bf1f54ba4976623e /mysys
parent8ee93b9cb486c8323f298f9c4aa83f7ad037488f (diff)
downloadmariadb-git-016dd21371961700f1324f204acbc7252a8c1e76.tar.gz
MDEV-27142 disable text mode for Windows stdio by default
This avoids LF->CRLF conversion by the C runtime, which historically has been rather buggy (see MDEV-9409) Disabling text mode also fixes the --binary-mode in command line client to work the same on Windows, as it does elsewhere. The user-visible effect is that some text files, e.g output of mysqldump or mysqlbinlog will not have CRLF end-of-lines,but LF. That should be acceptable, as even Notepad can read this Unix EOLs since 2018 (on older Windows, Wordpad can) Leave error log in text(CRLF) mode for now, for the sake of old Windows.
Diffstat (limited to 'mysys')
-rw-r--r--mysys/my_init.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/mysys/my_init.c b/mysys/my_init.c
index 2f21bcb735f..44488e5848a 100644
--- a/mysys/my_init.c
+++ b/mysys/my_init.c
@@ -401,16 +401,15 @@ static void my_win_init(void)
_tzset();
- /*
- We do not want text translation (LF->CRLF)
- when stdout is console/terminal, it is buggy
- */
- if (fileno(stdout) >= 0 && isatty(fileno(stdout)))
- (void)setmode(fileno(stdout), O_BINARY);
-
- if (fileno(stderr) >= 0 && isatty(fileno(stderr)))
- (void) setmode(fileno(stderr), O_BINARY);
-
+ /* Disable automatic LF->CRLF translation. */
+ FILE* stdf[]= {stdin, stdout, stderr};
+ for (int i= 0; i < array_elements(stdf); i++)
+ {
+ int fd= fileno(stdf[i]);
+ if (fd >= 0)
+ (void) _setmode(fd, O_BINARY);
+ }
+ _set_fmode(O_BINARY);
setup_codepages();
DBUG_VOID_RETURN;
}