|
From: Jason F. <jas...@ya...> - 2002-05-02 08:29:21
|
Ok the rational behind this fix:
- the console cannot be in line mode to get a single char (and return
immediately after, which is what getchar requires)
- the console mode setting shouldn't be done in getc() or any lower
because they work with any kind of file (getchar is specific towards
stdin)
Ok.. awaiting comments..
- Jason
int
getchar(void)
{
int c;
DWORD oldStdinMode;
WINBOOL consoleResult, hadIONBF = FALSE;
HANDLE hStdin = _get_osfhandle(stdin->_file);
GetConsoleMode(hStdin, &oldStdinMode);
SetConsoleMode(hStdin, ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT);
if(!(stdin->_flag & _IONBF))
{
hadIONBF = TRUE;
stdin->_flag |= _IONBF;
}
c = getc(stdin);
if(hadIONBF)
{
stdin->_flag |= _IONBF;
}
SetConsoleMode(hStdin, oldStdinMode);
return c;
}
__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com
|