summaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-06-12 07:48:31 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-06-12 07:48:31 +0000
commit2bc48ec00f2ee0028c1a5096aa676391820b87ec (patch)
treef89e9e7746e75343a2886ee50fc23a37f9fe5886 /io.c
parentce6c53d24d361f589169ffa49360e93be8c994a3 (diff)
downloadruby-2bc48ec00f2ee0028c1a5096aa676391820b87ec.tar.gz
ruby-2bc48ec00f2ee0028c1a5096aa676391820b87ec.tar.xz
ruby-2bc48ec00f2ee0028c1a5096aa676391820b87ec.zip
2000-06-12
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/io.c b/io.c
index 21d76994b..a35f306b2 100644
--- a/io.c
+++ b/io.c
@@ -281,27 +281,35 @@ rb_io_tell(io)
return rb_int2inum(pos);
}
+#ifndef SEEK_CUR
+# define SEEK_SET 0
+# define SEEK_CUR 1
+# define SEEK_END 2
+#endif
+
static VALUE
-rb_io_seek(io, offset, ptrname)
- VALUE io, offset, ptrname;
+rb_io_seek(argc, argv, io)
+ int argc;
+ VALUE *argv;
+ VALUE io;
{
+ VALUE offset, ptrname;
+ int whence;
OpenFile *fptr;
long pos;
+ rb_scan_args(argc, argv, "11", &offset, &ptrname);
+ if (argc == 1) whence = SEEK_SET;
+ else whence = NUM2INT(ptrname);
+
GetOpenFile(io, fptr);
- pos = fseek(fptr->f, NUM2INT(offset), NUM2INT(ptrname));
+ pos = fseek(fptr->f, NUM2INT(offset), whence);
if (pos != 0) rb_sys_fail(fptr->path);
clearerr(fptr->f);
return INT2FIX(0);
}
-#ifndef SEEK_CUR
-# define SEEK_SET 0
-# define SEEK_CUR 1
-# define SEEK_END 2
-#endif
-
static VALUE
rb_io_set_pos(io, offset)
VALUE io, offset;