Skip to content

Commit 3b2de91

Browse files
committed
* 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
1 parent b4466a1 commit 3b2de91

File tree

3 files changed

+36
-13
lines changed

3 files changed

+36
-13
lines changed

ChangeLog

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
Thu Dec 30 22:45:39 2004 Tanaka Akira <[email protected]>
2+
3+
* rubyio.h: don't deprecate rb_read_check.
4+
5+
* io.c (STDIO_READ_DATA_PENDING): reverted from old READ_DATA_PENDING
6+
to check stdio read buffer.
7+
(rb_read_check): use STDIO_READ_DATA_PENDING.
8+
(rb_read_pending): ditto.
9+
(rb_getc): ditto.
10+
111
Thu Dec 30 05:39:35 2004 Minero Aoki <[email protected]>
212

313
* parse.y: eliminate unused members in struct parser_params.

io.c

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,24 @@ static int gets_lineno;
118118
static int init_p = 0, next_p = 0;
119119
static VALUE lineno = INT2FIX(0);
120120

121+
#ifdef _STDIO_USES_IOSTREAM /* GNU libc */
122+
# ifdef _IO_fpos_t
123+
# define STDIO_READ_DATA_PENDING(fp) ((fp)->_IO_read_ptr != (fp)->_IO_read_end)
124+
# else
125+
# define STDIO_READ_DATA_PENDING(fp) ((fp)->_gptr < (fp)->_egptr)
126+
# endif
127+
#elif defined(FILE_COUNT)
128+
# define STDIO_READ_DATA_PENDING(fp) ((fp)->FILE_COUNT > 0)
129+
#elif defined(FILE_READEND)
130+
# define STDIO_READ_DATA_PENDING(fp) ((fp)->FILE_READPTR < (fp)->FILE_READEND)
131+
#elif defined(__BEOS__)
132+
# define STDIO_READ_DATA_PENDING(fp) (fp->_state._eof == 0)
133+
#elif defined(__VMS)
134+
# define STDIO_READ_DATA_PENDING(fp) (((unsigned int)(*(fp))->_cnt) > 0)
135+
#else
136+
# define STDIO_READ_DATA_PENDING(fp) (!feof(fp))
137+
#endif
138+
121139
#if defined(__VMS)
122140
#define fopen(file_spec, mode) fopen(file_spec, mode, "rfm=stmlf")
123141
#define open(file_spec, flags, mode) open(file_spec, flags, mode, "rfm=stmlf")
@@ -296,8 +314,7 @@ int
296314
rb_read_pending(fp)
297315
FILE *fp;
298316
{
299-
/* xxx: return READ_DATA_PENDING(fp); */
300-
return 1;
317+
return STDIO_READ_DATA_PENDING(fp);
301318
}
302319

303320
int
@@ -310,12 +327,9 @@ void
310327
rb_read_check(fp)
311328
FILE *fp;
312329
{
313-
/* xxx:
314-
if (!READ_DATA_PENDING(fp)) {
330+
if (!STDIO_READ_DATA_PENDING(fp)) {
315331
rb_thread_wait_fd(fileno(fp));
316332
}
317-
*/
318-
return;
319333
}
320334

321335
void
@@ -1829,19 +1843,16 @@ int
18291843
rb_getc(f)
18301844
FILE *f;
18311845
{
1832-
/*xxx
18331846
int c;
18341847

1835-
if (!READ_DATA_PENDING(f)) {
1848+
if (!STDIO_READ_DATA_PENDING(f)) {
18361849
rb_thread_wait_fd(fileno(f));
18371850
}
18381851
TRAP_BEG;
18391852
c = getc(f);
18401853
TRAP_END;
18411854

18421855
return c;
1843-
*/
1844-
return -1;
18451856
}
18461857

18471858
/*
@@ -1937,14 +1948,16 @@ fptr_finalize(fptr, noraise)
19371948
return;
19381949
}
19391950
if (fptr->stdio_file) {
1940-
if (fclose(fptr->stdio_file) < 0 && !noraise) { /* fptr->stdio_file is freed anyway */
1951+
if (fclose(fptr->stdio_file) < 0 && !noraise) {
1952+
/* fptr->stdio_file is deallocated anyway */
19411953
fptr->stdio_file = 0;
19421954
fptr->fd = -1;
19431955
rb_sys_fail(fptr->path);
19441956
}
19451957
}
19461958
else if (0 <= fptr->fd) {
1947-
if (close(fptr->fd) < 0 && !noraise) { /* fptr->fd is still not closed */
1959+
if (close(fptr->fd) < 0 && !noraise) {
1960+
/* fptr->fd is still not closed */
19481961
rb_sys_fail(fptr->path);
19491962
}
19501963
}

rubyio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ NORETURN(void rb_eof_error _((void)));
9797

9898
void rb_io_read_check _((OpenFile*));
9999
int rb_io_read_pending _((OpenFile*));
100+
void rb_read_check _((FILE*));
100101

101102
#ifdef __GNUC__
102103
# if ( __GNUC__ == 3 && __GNUC_MINOR__ > 0 ) || __GNUC__ > 3
@@ -110,6 +111,5 @@ int rb_io_read_pending _((OpenFile*));
110111
DEPRECATED(int rb_getc _((FILE*)));
111112
DEPRECATED(long rb_io_fread _((char *, long, FILE *)));
112113
DEPRECATED(long rb_io_fwrite _((const char *, long, FILE *)));
113-
DEPRECATED(void rb_read_check _((FILE*)));
114114
DEPRECATED(int rb_read_pending _((FILE*)));
115115
#endif

0 commit comments

Comments
 (0)