зеркало из https://github.com/github/ruby.git
* rubyio.h: don't deprecate rb_read_check.
* io.c (STDIO_READ_DATA_PENDING): reverted from old READ_DATA_PENDING to check stdio read buffer. (rb_read_check): use STDIO_READ_DATA_PENDING. (rb_read_pending): ditto. (rb_getc): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7689 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
b4466a1084
Коммит
3b2de91dcf
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
Thu Dec 30 22:45:39 2004 Tanaka Akira <akr@m17n.org>
|
||||
|
||||
* rubyio.h: don't deprecate rb_read_check.
|
||||
|
||||
* io.c (STDIO_READ_DATA_PENDING): reverted from old READ_DATA_PENDING
|
||||
to check stdio read buffer.
|
||||
(rb_read_check): use STDIO_READ_DATA_PENDING.
|
||||
(rb_read_pending): ditto.
|
||||
(rb_getc): ditto.
|
||||
|
||||
Thu Dec 30 05:39:35 2004 Minero Aoki <aamine@loveruby.net>
|
||||
|
||||
* parse.y: eliminate unused members in struct parser_params.
|
||||
|
|
37
io.c
37
io.c
|
@ -118,6 +118,24 @@ static int gets_lineno;
|
|||
static int init_p = 0, next_p = 0;
|
||||
static VALUE lineno = INT2FIX(0);
|
||||
|
||||
#ifdef _STDIO_USES_IOSTREAM /* GNU libc */
|
||||
# ifdef _IO_fpos_t
|
||||
# define STDIO_READ_DATA_PENDING(fp) ((fp)->_IO_read_ptr != (fp)->_IO_read_end)
|
||||
# else
|
||||
# define STDIO_READ_DATA_PENDING(fp) ((fp)->_gptr < (fp)->_egptr)
|
||||
# endif
|
||||
#elif defined(FILE_COUNT)
|
||||
# define STDIO_READ_DATA_PENDING(fp) ((fp)->FILE_COUNT > 0)
|
||||
#elif defined(FILE_READEND)
|
||||
# define STDIO_READ_DATA_PENDING(fp) ((fp)->FILE_READPTR < (fp)->FILE_READEND)
|
||||
#elif defined(__BEOS__)
|
||||
# define STDIO_READ_DATA_PENDING(fp) (fp->_state._eof == 0)
|
||||
#elif defined(__VMS)
|
||||
# define STDIO_READ_DATA_PENDING(fp) (((unsigned int)(*(fp))->_cnt) > 0)
|
||||
#else
|
||||
# define STDIO_READ_DATA_PENDING(fp) (!feof(fp))
|
||||
#endif
|
||||
|
||||
#if defined(__VMS)
|
||||
#define fopen(file_spec, mode) fopen(file_spec, mode, "rfm=stmlf")
|
||||
#define open(file_spec, flags, mode) open(file_spec, flags, mode, "rfm=stmlf")
|
||||
|
@ -296,8 +314,7 @@ int
|
|||
rb_read_pending(fp)
|
||||
FILE *fp;
|
||||
{
|
||||
/* xxx: return READ_DATA_PENDING(fp); */
|
||||
return 1;
|
||||
return STDIO_READ_DATA_PENDING(fp);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -310,12 +327,9 @@ void
|
|||
rb_read_check(fp)
|
||||
FILE *fp;
|
||||
{
|
||||
/* xxx:
|
||||
if (!READ_DATA_PENDING(fp)) {
|
||||
if (!STDIO_READ_DATA_PENDING(fp)) {
|
||||
rb_thread_wait_fd(fileno(fp));
|
||||
}
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1829,10 +1843,9 @@ int
|
|||
rb_getc(f)
|
||||
FILE *f;
|
||||
{
|
||||
/*xxx
|
||||
int c;
|
||||
|
||||
if (!READ_DATA_PENDING(f)) {
|
||||
if (!STDIO_READ_DATA_PENDING(f)) {
|
||||
rb_thread_wait_fd(fileno(f));
|
||||
}
|
||||
TRAP_BEG;
|
||||
|
@ -1840,8 +1853,6 @@ rb_getc(f)
|
|||
TRAP_END;
|
||||
|
||||
return c;
|
||||
*/
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1937,14 +1948,16 @@ fptr_finalize(fptr, noraise)
|
|||
return;
|
||||
}
|
||||
if (fptr->stdio_file) {
|
||||
if (fclose(fptr->stdio_file) < 0 && !noraise) { /* fptr->stdio_file is freed anyway */
|
||||
if (fclose(fptr->stdio_file) < 0 && !noraise) {
|
||||
/* fptr->stdio_file is deallocated anyway */
|
||||
fptr->stdio_file = 0;
|
||||
fptr->fd = -1;
|
||||
rb_sys_fail(fptr->path);
|
||||
}
|
||||
}
|
||||
else if (0 <= fptr->fd) {
|
||||
if (close(fptr->fd) < 0 && !noraise) { /* fptr->fd is still not closed */
|
||||
if (close(fptr->fd) < 0 && !noraise) {
|
||||
/* fptr->fd is still not closed */
|
||||
rb_sys_fail(fptr->path);
|
||||
}
|
||||
}
|
||||
|
|
2
rubyio.h
2
rubyio.h
|
@ -97,6 +97,7 @@ NORETURN(void rb_eof_error _((void)));
|
|||
|
||||
void rb_io_read_check _((OpenFile*));
|
||||
int rb_io_read_pending _((OpenFile*));
|
||||
void rb_read_check _((FILE*));
|
||||
|
||||
#ifdef __GNUC__
|
||||
# if ( __GNUC__ == 3 && __GNUC_MINOR__ > 0 ) || __GNUC__ > 3
|
||||
|
@ -110,6 +111,5 @@ int rb_io_read_pending _((OpenFile*));
|
|||
DEPRECATED(int rb_getc _((FILE*)));
|
||||
DEPRECATED(long rb_io_fread _((char *, long, FILE *)));
|
||||
DEPRECATED(long rb_io_fwrite _((const char *, long, FILE *)));
|
||||
DEPRECATED(void rb_read_check _((FILE*)));
|
||||
DEPRECATED(int rb_read_pending _((FILE*)));
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче