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

* ext/stringio/stringio.c (strio_seek): consistent behavior with

IO#seek.  patch by sheepman in [ruby-dev:30710].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2007-04-16 07:48:50 +00:00
parent e7bab2a61b
commit ffa31c2645
2 changed files with 9 additions and 1 deletions

View file

@ -1,3 +1,8 @@
Mon Apr 16 16:49:32 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/stringio/stringio.c (strio_seek): consistent behavior with
IO#seek. patch by sheepman in [ruby-dev:30710].
Mon Apr 16 10:51:37 2007 Yukihiro Matsumoto <matz@ruby-lang.org> Mon Apr 16 10:51:37 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* enum.c (enum_each_with_index): each_with_index to forward * enum.c (enum_each_with_index): each_with_index to forward

View file

@ -597,6 +597,9 @@ strio_seek(int argc, VALUE *argv, VALUE self)
rb_scan_args(argc, argv, "11", NULL, &whence); rb_scan_args(argc, argv, "11", NULL, &whence);
offset = NUM2LONG(argv[0]); offset = NUM2LONG(argv[0]);
if (CLOSED(ptr)) {
rb_raise(rb_eIOError, "closed stream");
}
switch (NIL_P(whence) ? 0 : NUM2LONG(whence)) { switch (NIL_P(whence) ? 0 : NUM2LONG(whence)) {
case 0: case 0:
break; break;
@ -607,7 +610,7 @@ strio_seek(int argc, VALUE *argv, VALUE self)
offset += RSTRING_LEN(ptr->string); offset += RSTRING_LEN(ptr->string);
break; break;
default: default:
rb_raise(rb_eArgError, "invalid whence %ld", NUM2LONG(whence)); error_inval("invalid whence");
} }
if (offset < 0) { if (offset < 0) {
error_inval(0); error_inval(0);