mirror of
https://github.com/reactos/reactos.git
synced 2024-10-15 13:45:58 +00:00
[PING]
- Alexander Yastrebov: Properly write data into the standard output device depending whether it's a char or a block device. CORE-6628 #resolve #comment Patch committed in revision 59552, thank you Alexander and sorry that it took so long! svn path=/trunk/; revision=59553
This commit is contained in:
parent
26c0debfa3
commit
1ebd4c1b0c
|
@ -143,10 +143,13 @@ void FormatOutput(UINT uID, ...)
|
||||||
va_list valist;
|
va_list valist;
|
||||||
|
|
||||||
WCHAR Buf[1024];
|
WCHAR Buf[1024];
|
||||||
|
CHAR AnsiBuf[1024];
|
||||||
LPWSTR pBuf = Buf;
|
LPWSTR pBuf = Buf;
|
||||||
|
PCHAR pAnsiBuf = AnsiBuf;
|
||||||
LPWSTR Format;
|
LPWSTR Format;
|
||||||
DWORD written;
|
DWORD written;
|
||||||
UINT DataLength;
|
UINT DataLength;
|
||||||
|
int AnsiLength;
|
||||||
|
|
||||||
va_start(valist, uID);
|
va_start(valist, uID);
|
||||||
|
|
||||||
|
@ -169,7 +172,28 @@ void FormatOutput(UINT uID, ...)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(GetFileType(hStdOutput) == FILE_TYPE_CHAR)
|
||||||
|
{
|
||||||
|
/* Is a console or a printer */
|
||||||
WriteConsole(hStdOutput, pBuf, DataLength, &written, NULL);
|
WriteConsole(hStdOutput, pBuf, DataLength, &written, NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Is a pipe, socket, file or other */
|
||||||
|
AnsiLength = WideCharToMultiByte(CP_ACP, 0, pBuf, DataLength,\
|
||||||
|
NULL, 0, NULL, NULL);
|
||||||
|
|
||||||
|
if(AnsiLength >= sizeof(AnsiBuf))
|
||||||
|
pAnsiBuf = (PCHAR)HeapAlloc(GetProcessHeap(), 0, AnsiLength);
|
||||||
|
|
||||||
|
AnsiLength = WideCharToMultiByte(CP_OEMCP, 0, pBuf, DataLength,\
|
||||||
|
pAnsiBuf, AnsiLength, " ", NULL);
|
||||||
|
|
||||||
|
WriteFile(hStdOutput, pAnsiBuf, AnsiLength, &written, NULL);
|
||||||
|
|
||||||
|
if(pAnsiBuf != AnsiBuf)
|
||||||
|
HeapFree(NULL, 0, pAnsiBuf);
|
||||||
|
}
|
||||||
|
|
||||||
if(pBuf != Buf)
|
if(pBuf != Buf)
|
||||||
LocalFree(pBuf);
|
LocalFree(pBuf);
|
||||||
|
|
Loading…
Reference in a new issue