- 论坛徽章:
- 0
|
哦 这样啊 我找到了
int
getchar ()
{
int result;
_IO_acquire_lock (_IO_stdin);
result = _IO_getc_unlocked (_IO_stdin);
_IO_release_lock (_IO_stdin);
return result;
}
查看_IO_getc_unlocked
#define _IO_getc_unlocked(_fp) \
(_IO_BE ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end, 0) \
? __uflow (_fp) : *(unsigned char *) (_fp)->_IO_read_ptr++)
查看__uflow
int
__uflow (fp)
_IO_FILE *fp;
{
#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
return EOF;
#endif
if (fp->_mode == 0)
_IO_fwide (fp, -1);
if (_IO_in_put_mode (fp))
if (INTUSE(_IO_switch_to_get_mode) (fp) == EOF)
return EOF;
。。。。。
查看INTUSE(_IO_switch_to_get_mode) (fp)
int
_IO_switch_to_get_mode (fp)
_IO_FILE *fp;
{
if (fp->_IO_write_ptr > fp->_IO_write_base)//如果有输出数据
if (_IO_OVERFLOW (fp, EOF) == EOF)
查看 _IO_OVERFLOW
/* The 'overflow' hook flushes the buffer.
The second argument is a character, or EOF.
It matches the streambuf: verflow virtual function. */
typedef int (*_IO_overflow_t) (_IO_FILE *, int);
#define _IO_OVERFLOW(FP, CH) JUMP1 (__overflow, FP, CH)
#define _IO_WOVERFLOW(FP, CH) WJUMP1 (__overflow, FP, CH)
就不往下了
原来是这么回事 |
|