aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-12-30 13:49:56 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-12-30 13:49:56 +0000
commit3b2de91dcff9e794281917fd2f4f5f19fad7f348 (patch)
tree02e30c693dab409be9fcd95f88fdb49bd94076bd
parentb4466a1084ae89dd4dd96031048ca6d99f4c5bc6 (diff)
downloadruby-3b2de91dcff9e794281917fd2f4f5f19fad7f348.tar.gz
* 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
-rw-r--r--ChangeLog10
-rw-r--r--io.c37
-rw-r--r--rubyio.h2
3 files changed, 36 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 19e8caa49f..cf354c1807 100644
--- a/ChangeLog
+++ b/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.
diff --git a/io.c b/io.c
index 064d8b15e7..fd0b81dd1f 100644
--- a/io.c
+++ b/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);
}
}
diff --git a/rubyio.h b/rubyio.h
index d9e734fa12..7c6973f8e4 100644
--- a/rubyio.h
+++ b/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