diff --git a/ChangeLog b/ChangeLog index d90b777bb0..0fb9ab9b49 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Tue Dec 23 19:42:59 2003 Nobuyoshi Nakada + + * io.c (rb_io_ungetc): raise an exception at unread stream to + avoid unspecified behavior. [ruby-dev:22330] + + * test/ruby/test_system.rb (test_syntax): glob relatively from + __FILE__. + Tue Dec 23 18:09:40 2003 Yukihiro Matsumoto * pack.c (pack_pack): remove unnecessary negative value check. @@ -27,7 +35,7 @@ Tue Dec 23 14:13:51 2003 akira yamada * test/uri/test_generic.rb (TestGeneric::test_set_component): added tets. - + Tue Dec 23 11:08:34 2003 NAKAMURA, Hiroshi * test/xsd/test_noencoding.rb: rescue Errno::EINVAL and do not test. diff --git a/io.c b/io.c index 87caa7651f..8ecf0c1426 100644 --- a/io.c +++ b/io.c @@ -1314,8 +1314,9 @@ rb_io_ungetc(io, c) int cc = NUM2INT(c); GetOpenFile(io, fptr); + if (!(fptr->mode & FMODE_RBUF)) + rb_raise(rb_eIOError, "unread stream"); rb_io_check_readable(fptr); - flush_before_seek(fptr); if (ungetc(cc, fptr->f) == EOF && cc != EOF) rb_sys_fail(fptr->path); @@ -3456,7 +3457,7 @@ rb_io_ctl(io, req, arg, io_p) rb_raise(rb_eArgError, "return value overflowed string"); } - if (fptr->f2 && fileno(fptr->f) != fileno(fptr->f2)) { + if (fptr->f2 && fileno(fptr->f) != fileno(fptr->f2)) { /* call on f2 too; ignore result */ io_cntl(fileno(fptr->f2), cmd, narg, io_p); } diff --git a/test/ruby/test_system.rb b/test/ruby/test_system.rb index 71eb7ad183..a19f6ef9b7 100644 --- a/test/ruby/test_system.rb +++ b/test/ruby/test_system.rb @@ -54,15 +54,11 @@ class TestSystem < Test::Unit::TestCase File.unlink "script_tmp" or `/bin/rm -f "script_tmp"` File.unlink "script_tmp.bak" or `/bin/rm -f "script_tmp.bak"` + end - if (dir = File.dirname(File.dirname($0))) == '.' - dir = "" - else - dir << "/" - end - + def test_syntax assert_nothing_raised(Exception) do - for script in Dir["#{dir}{lib,sample,ext}/**/*.rb"] + for script in Dir[File.expand_path("../../../{lib,sample,ext}/**/*.rb", __FILE__)] valid_syntax? IO::read(script), script end end