Commit a0ef8845 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Added unicode modes support _setmode function.

parent eeb7d0a6
...@@ -2233,12 +2233,29 @@ int CDECL MSVCRT__read(int fd, void *buf, unsigned int count) ...@@ -2233,12 +2233,29 @@ int CDECL MSVCRT__read(int fd, void *buf, unsigned int count)
int CDECL MSVCRT__setmode(int fd,int mode) int CDECL MSVCRT__setmode(int fd,int mode)
{ {
int ret = msvcrt_get_ioinfo(fd)->wxflag & WX_TEXT ? MSVCRT__O_TEXT : MSVCRT__O_BINARY; int ret = msvcrt_get_ioinfo(fd)->wxflag & WX_TEXT ? MSVCRT__O_TEXT : MSVCRT__O_BINARY;
if (mode & (~(MSVCRT__O_TEXT|MSVCRT__O_BINARY))) if(ret==MSVCRT__O_TEXT && (msvcrt_get_ioinfo(fd)->exflag & (EF_UTF8|EF_UTF16)))
FIXME("fd (%d) mode (0x%08x) unknown\n",fd,mode); ret = MSVCRT__O_WTEXT;
if ((mode & MSVCRT__O_TEXT) == MSVCRT__O_TEXT)
if(mode!=MSVCRT__O_TEXT && mode!=MSVCRT__O_BINARY && mode!=MSVCRT__O_WTEXT
&& mode!=MSVCRT__O_U16TEXT && mode!=MSVCRT__O_U8TEXT) {
*MSVCRT__errno() = MSVCRT_EINVAL;
return -1;
}
if(mode == MSVCRT__O_BINARY) {
msvcrt_get_ioinfo(fd)->wxflag &= ~WX_TEXT;
msvcrt_get_ioinfo(fd)->exflag &= ~(EF_UTF8|EF_UTF16);
return ret;
}
msvcrt_get_ioinfo(fd)->wxflag |= WX_TEXT; msvcrt_get_ioinfo(fd)->wxflag |= WX_TEXT;
if(mode == MSVCRT__O_TEXT)
msvcrt_get_ioinfo(fd)->exflag &= ~(EF_UTF8|EF_UTF16);
else if(mode == MSVCRT__O_U8TEXT)
msvcrt_get_ioinfo(fd)->exflag = (msvcrt_get_ioinfo(fd)->exflag & ~EF_UTF16) | EF_UTF8;
else else
msvcrt_get_ioinfo(fd)->wxflag &= ~WX_TEXT; msvcrt_get_ioinfo(fd)->exflag = (msvcrt_get_ioinfo(fd)->exflag & ~EF_UTF8) | EF_UTF16;
return ret; return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment