Я думаю, что я решаю эту проблему.
Автор сказал: «Следующее непереносимо».
Так что, возможно, вам нужно что-то изменить.
Я считаю, чтоFILE (typedef _IO_FILE) в /usr/include/bits/types/struct_FILE.h
Мой _IO_FILE такой:
struct _IO_FILE
{
int _flags; /* High-order word is _IO_MAGIC; rest is flags. */
/* The following pointers correspond to the C++ streambuf protocol. */
char *_IO_read_ptr; /* Current read pointer */
char *_IO_read_end; /* End of get area. */
char *_IO_read_base; /* Start of putback+get area. */
char *_IO_write_base; /* Start of put area. */
char *_IO_write_ptr; /* Current put pointer. */
char *_IO_write_end; /* End of put area. */
char *_IO_buf_base; /* Start of reserve area. */
char *_IO_buf_end; /* End of reserve area. */
/* The following fields are used to support backing up and undo. */
char *_IO_save_base; /* Pointer to start of non-current get area. */
char *_IO_backup_base; /* Pointer to first valid character of backup area */
char *_IO_save_end; /* Pointer to end of non-current get area. */
struct _IO_marker *_markers;
struct _IO_FILE *_chain;
int _fileno;
int _flags2;
__off_t _old_offset; /* This used to be _offset but it's too small. */
/* 1+column number of pbase(); 0 is unknown. */
unsigned short _cur_column;
signed char _vtable_offset;
char _shortbuf[1];
_IO_lock_t *_lock;
#ifdef _IO_USE_OLD_IO_FILE
};
Затем я изменяю buf.c:
подробно я поменяю "flag" на "flags" и "return (fp -> _ base - fp -> _ ptr);""вернуть (fp -> _ IO_buf_end - fp -> _ IO_buf_base);"
#elif defined(_IONBF)
int
is_unbuffered(FILE *fp)
{
return(fp->_flags & _IONBF);
}
int
is_linebuffered(FILE *fp)
{
return(fp->_flags & _IOLBF);
}
int
buffer_size(FILE *fp)
{
#ifdef _LP64
return(fp->_IO_buf_end - fp->_IO_buf_base);
#else
return(BUFSIZ); /* just a guess */
#endif
}
Наконец-то я получил этот результат.
enter any character
a
one line to standard error
stream = stdin, fully buffered, buffer size = 1024
stream = stdout, fully buffered, buffer size = 1024
stream = stderr, unbuffered, buffer size = 1
stream = /etc/passwd, fully buffered, buffer size = 4096