Eric Pouech : kernel32: Properly manage ctrl-Z (and ctrl-D) in ReadFile when dealing with a console handle.
Alexandre Julliard
julliard at winehq.org
Mon Nov 29 13:38:37 CST 2010
Module: wine
Branch: master
Commit: ead4712606307bf92525e9aad1374a2cc0bc8fc0
URL: http://source.winehq.org/git/wine.git/?a=commit;h=ead4712606307bf92525e9aad1374a2cc0bc8fc0
Author: Eric Pouech <eric.pouech at orange.fr>
Date: Sun Nov 28 22:10:43 2010 +0100
kernel32: Properly manage ctrl-Z (and ctrl-D) in ReadFile when dealing with a console handle.
---
dlls/kernel32/file.c | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/dlls/kernel32/file.c b/dlls/kernel32/file.c
index e32d75d..67c886e 100644
--- a/dlls/kernel32/file.c
+++ b/dlls/kernel32/file.c
@@ -406,7 +406,23 @@ BOOL WINAPI ReadFile( HANDLE hFile, LPVOID buffer, DWORD bytesToRead,
if (!bytesToRead) return TRUE;
if (is_console_handle(hFile))
- return ReadConsoleA(hFile, buffer, bytesToRead, bytesRead, NULL);
+ {
+ DWORD conread, mode;
+ if (!ReadConsoleA(hFile, buffer, bytesToRead, &conread, NULL) ||
+ !GetConsoleMode(hFile, &mode))
+ return FALSE;
+ /* ctrl-Z (26) means end of file on window (if at beginning of buffer)
+ * but Unix uses ctrl-D (4), and ctrl-Z is a bad idea on Unix :-/
+ * So map both ctrl-D ctrl-Z to EOF.
+ */
+ if ((mode & ENABLE_PROCESSED_INPUT) && conread > 0 &&
+ (((char*)buffer)[0] == 26 || ((char*)buffer)[0] == 4))
+ {
+ conread = 0;
+ }
+ if (bytesRead) *bytesRead = conread;
+ return TRUE;
+ }
if (overlapped != NULL)
{
More information about the wine-cvs
mailing list