Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.build/
/.bundle/
/.yardoc
/Gemfile.lock
Expand Down
12 changes: 6 additions & 6 deletions ext/stringio/stringio.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ STRINGIO_VERSION = "3.2.1";
# define NUM2ULEN(num) NUM2ULONG(num)
# define LEN2NUM(num) LONG2NUM(num)
# define ULEN2NUM(num) ULONG2NUM(num)
# define PRIdLEN "ld"
typedef long rb_len_t;
typedef unsigned long rb_ulen_t;
#endif
Expand Down Expand Up @@ -959,15 +960,14 @@ strio_seek(int argc, VALUE *argv, VALUE self)
if (CLOSED(self)) {
rb_raise(rb_eIOError, "closed stream");
}
switch (whence) {
case Qnil:
case INT2FIX(0):
switch (NIL_P(whence) ? 0 : NUM2LONG(whence)) {
case 0:
offset = 0;
break;
case INT2FIX(1):
case 1:
offset = ptr->pos;
break;
case INT2FIX(2):
case 2:
if (NIL_P(ptr->string)) {
offset = 0;
}
Expand Down Expand Up @@ -1734,7 +1734,7 @@ strio_read(int argc, VALUE *argv, VALUE self)
if (!NIL_P(argv[0])) {
len = NUM2LEN(argv[0]);
if (len < 0) {
rb_raise(rb_eArgError, "negative length %ld given", len);
rb_raise(rb_eArgError, "negative length %"PRIdLEN" given", len);
}
if (eos_p(ptr)) {
if (!NIL_P(str)) rb_str_resize(str, 0);
Expand Down
2 changes: 2 additions & 0 deletions test/stringio/test_stringio.rb
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,8 @@ def test_seek
assert_raise(Errno::EINVAL) { f.seek(-1) }
f.seek(-1, 2)
assert_equal("4", f.getc)
f.seek(-2, 2.0)
assert_equal("3", f.getc)
assert_raise(Errno::EINVAL) { f.seek(1, 3) }
f.close
assert_raise(IOError) { f.seek(0) }
Expand Down
Loading