|
From: Hartmut B. <har...@te...> - 2002-05-01 15:40:35
|
I think, getchar can not use getc for getting one character. Getchar must set the console to non line buffered mode, wait for one character and read it, and restore the old console mode. - Hartmut > -----Ursprungliche Nachricht----- > Von: Phillip Susi [SMTP:ps...@cf...] > Gesendet am: Mittwoch, 1. Mai 2002 01:50 > An: rea...@li... > Betreff: [ros-kernel] Re: gets and console input > > Consoles by default are line buffered, so they only return an entire line > when \n is hit. If you want to, you can change the console mode to not be > line buffered with SetConsoleMode(), but I don't think that CRTs usually do > this: they just leave it as line buffered. > > At 12:30 AM 5/1/2002 +0200, you wrote: > >Hey all > > > >I'm trying to track down a bug in gets (in msvcrt). Here's the problem, > >based on the calls made: > > > >1: gets calls getchar to get each character, checking for \n or EOF > >2: getchar calls getc, using STDIN as the file handle > >3: getc calls _filbuf, again passing the file handle (STDIN) > >4: _filbuf calls _read > >5: _read calls ReadFile > >6: ReadFile calls ReadConsoleA because IsConsoleHandle returns true > > > >ReadConsoleA gets a series of characters from the keyboard and only > >returns when it gets a \n. So in effect, getchar is getting an entire > >string from the console instead of a single character. > > > >At which point is the fault? Should ReadFile call ReadConsoleA? Or perhaps > >is the fault in calling _filbuf? I don't know... I really need some advice > >on this. > > > >Thanks!! > > > >- Jason > |