1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* io.c (argf_forward): should not use frame->argv.

[ruby-core:07358]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2006-02-14 02:23:34 +00:00
parent e4b39849f7
commit a43c264f80
2 changed files with 26 additions and 19 deletions

View file

@ -1,3 +1,8 @@
Tue Feb 14 11:21:38 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (argf_forward): should not use frame->argv.
[ruby-core:07358]
Mon Feb 13 18:08:12 2006 Yukihiro Matsumoto <matz@ruby-lang.org> Mon Feb 13 18:08:12 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_call0): argument update propagation. [ruby-dev:28044] * eval.c (rb_call0): argument update propagation. [ruby-dev:28044]

40
io.c
View file

@ -4198,16 +4198,18 @@ rb_io_s_for_fd(argc, argv, klass)
static int binmode = 0; static int binmode = 0;
static VALUE static VALUE
argf_forward() argf_forward(int argc, VALUE *argv)
{ {
return rb_funcall3(current_file, ruby_frame->last_func, return rb_funcall3(current_file, ruby_frame->last_func, argc, argv);
ruby_frame->argc, ruby_frame->argv);
} }
#define ARGF_FORWARD() do { if (TYPE(current_file) != T_FILE) return argf_forward(); } while (0) #define ARGF_FORWARD(argc, argv) do {\
#define NEXT_ARGF_FORWARD() do {\ if (TYPE(current_file) != T_FILE)\
return argf_forward(argc, argv);\
} while (0)
#define NEXT_ARGF_FORWARD(argc, argv) do {\
if (!next_argv()) return Qnil;\ if (!next_argv()) return Qnil;\
ARGF_FORWARD();\ ARGF_FORWARD(argc, argv);\
} while (0) } while (0)
static void static void
@ -4465,7 +4467,7 @@ rb_f_readline(argc, argv)
VALUE line; VALUE line;
if (!next_argv()) rb_eof_error(); if (!next_argv()) rb_eof_error();
ARGF_FORWARD(); ARGF_FORWARD(argc, argv);
line = rb_f_gets(argc, argv); line = rb_f_gets(argc, argv);
if (NIL_P(line)) { if (NIL_P(line)) {
rb_eof_error(); rb_eof_error();
@ -4503,7 +4505,7 @@ rb_f_readlines(argc, argv)
{ {
VALUE line, ary; VALUE line, ary;
NEXT_ARGF_FORWARD(); NEXT_ARGF_FORWARD(argc, argv);
ary = rb_ary_new(); ary = rb_ary_new();
while (!NIL_P(line = argf_getline(argc, argv))) { while (!NIL_P(line = argf_getline(argc, argv))) {
rb_ary_push(ary, line); rb_ary_push(ary, line);
@ -5208,7 +5210,7 @@ argf_tell()
if (!next_argv()) { if (!next_argv()) {
rb_raise(rb_eArgError, "no stream to tell"); rb_raise(rb_eArgError, "no stream to tell");
} }
ARGF_FORWARD(); ARGF_FORWARD(0, 0);
return rb_io_tell(current_file); return rb_io_tell(current_file);
} }
@ -5221,7 +5223,7 @@ argf_seek_m(argc, argv, self)
if (!next_argv()) { if (!next_argv()) {
rb_raise(rb_eArgError, "no stream to seek"); rb_raise(rb_eArgError, "no stream to seek");
} }
ARGF_FORWARD(); ARGF_FORWARD(argc, argv);
return rb_io_seek_m(argc, argv, current_file); return rb_io_seek_m(argc, argv, current_file);
} }
@ -5232,7 +5234,7 @@ argf_set_pos(self, offset)
if (!next_argv()) { if (!next_argv()) {
rb_raise(rb_eArgError, "no stream to set position"); rb_raise(rb_eArgError, "no stream to set position");
} }
ARGF_FORWARD(); ARGF_FORWARD(1, &offset);
return rb_io_set_pos(current_file, offset); return rb_io_set_pos(current_file, offset);
} }
@ -5242,7 +5244,7 @@ argf_rewind()
if (!next_argv()) { if (!next_argv()) {
rb_raise(rb_eArgError, "no stream to rewind"); rb_raise(rb_eArgError, "no stream to rewind");
} }
ARGF_FORWARD(); ARGF_FORWARD(0, 0);
return rb_io_rewind(current_file); return rb_io_rewind(current_file);
} }
@ -5252,7 +5254,7 @@ argf_fileno()
if (!next_argv()) { if (!next_argv()) {
rb_raise(rb_eArgError, "no stream"); rb_raise(rb_eArgError, "no stream");
} }
ARGF_FORWARD(); ARGF_FORWARD(0, 0);
return rb_io_fileno(current_file); return rb_io_fileno(current_file);
} }
@ -5260,7 +5262,7 @@ static VALUE
argf_to_io() argf_to_io()
{ {
next_argv(); next_argv();
ARGF_FORWARD(); ARGF_FORWARD(0, 0);
return current_file; return current_file;
} }
@ -5269,7 +5271,7 @@ argf_eof()
{ {
if (current_file) { if (current_file) {
if (init_p == 0) return Qtrue; if (init_p == 0) return Qtrue;
ARGF_FORWARD(); ARGF_FORWARD(0, 0);
if (rb_io_eof(current_file)) { if (rb_io_eof(current_file)) {
return Qtrue; return Qtrue;
} }
@ -5300,7 +5302,7 @@ argf_read(argc, argv)
return str; return str;
} }
if (TYPE(current_file) != T_FILE) { if (TYPE(current_file) != T_FILE) {
tmp = argf_forward(); tmp = argf_forward(argc, argv);
} }
else { else {
tmp = io_read(argc, argv, current_file); tmp = io_read(argc, argv, current_file);
@ -5351,7 +5353,7 @@ argf_readchar()
{ {
VALUE c; VALUE c;
NEXT_ARGF_FORWARD(); NEXT_ARGF_FORWARD(0, 0);
c = argf_getc(); c = argf_getc();
if (NIL_P(c)) { if (NIL_P(c)) {
rb_eof_error(); rb_eof_error();
@ -5410,7 +5412,7 @@ argf_binmode()
{ {
binmode = 1; binmode = 1;
next_argv(); next_argv();
ARGF_FORWARD(); ARGF_FORWARD(0, 0);
rb_io_binmode(current_file); rb_io_binmode(current_file);
return argf; return argf;
} }
@ -5441,7 +5443,7 @@ static VALUE
argf_closed() argf_closed()
{ {
next_argv(); next_argv();
ARGF_FORWARD(); ARGF_FORWARD(0, 0);
return rb_io_closed(current_file); return rb_io_closed(current_file);
} }