From 0ab577bd85d0cc73a22b8ad697882aab09715604 Mon Sep 17 00:00:00 2001 From: Brandon Turner Date: Tue, 6 Dec 2005 19:11:08 +0000 Subject: [PATCH] Make sure that a CTRL+C doesn't carry over to another command. svn path=/trunk/; revision=19933 --- reactos/subsys/system/cmd/cmd.c | 37 ++++++++++++++++----------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/reactos/subsys/system/cmd/cmd.c b/reactos/subsys/system/cmd/cmd.c index e62a014078a..2ec8f3d28c6 100644 --- a/reactos/subsys/system/cmd/cmd.c +++ b/reactos/subsys/system/cmd/cmd.c @@ -681,8 +681,6 @@ DoCommand (LPTSTR line) } } } - /* Just in case a CTRL+C slipped through a command */ - bCtrlBreak = FALSE; free(com); } @@ -1449,7 +1447,7 @@ ProcessInput (BOOL bFlag) ConOutPuts (commandline); } - if (*commandline && !CheckCtrlBreak(BREAK_INPUT)) + if (!CheckCtrlBreak(BREAK_INPUT) && *commandline) { ParseCommandLine (commandline); if (bEcho && !bIgnoreEcho && (!bIsBatch || bEchoThisLine)) @@ -1473,22 +1471,7 @@ BOOL WINAPI BreakHandler (DWORD dwCtrlType) INPUT_RECORD rec; static BOOL SelfGenerated = FALSE; - rec.EventType = KEY_EVENT; - rec.Event.KeyEvent.bKeyDown = TRUE; - rec.Event.KeyEvent.wRepeatCount = 1; - rec.Event.KeyEvent.wVirtualKeyCode = _T('C'); - rec.Event.KeyEvent.wVirtualScanCode = _T('C') - 35; - rec.Event.KeyEvent.uChar.AsciiChar = _T('C'); - rec.Event.KeyEvent.uChar.UnicodeChar = _T('C'); - rec.Event.KeyEvent.dwControlKeyState = RIGHT_CTRL_PRESSED; - - WriteConsoleInput( - hIn, - &rec, - 1, - &dwWritten); - - if ((dwCtrlType != CTRL_C_EVENT) && + if ((dwCtrlType != CTRL_C_EVENT) && (dwCtrlType != CTRL_BREAK_EVENT)) { return FALSE; @@ -1509,6 +1492,22 @@ BOOL WINAPI BreakHandler (DWORD dwCtrlType) return TRUE; } + + rec.EventType = KEY_EVENT; + rec.Event.KeyEvent.bKeyDown = TRUE; + rec.Event.KeyEvent.wRepeatCount = 1; + rec.Event.KeyEvent.wVirtualKeyCode = _T('C'); + rec.Event.KeyEvent.wVirtualScanCode = _T('C') - 35; + rec.Event.KeyEvent.uChar.AsciiChar = _T('C'); + rec.Event.KeyEvent.uChar.UnicodeChar = _T('C'); + rec.Event.KeyEvent.dwControlKeyState = RIGHT_CTRL_PRESSED; + + WriteConsoleInput( + hIn, + &rec, + 1, + &dwWritten); + bCtrlBreak = TRUE; /* FIXME: Handle batch files */