summaryrefslogtreecommitdiff
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
commit548b5143db2c3d701520671ef1413cf3c39fcedf (patch)
treef89e9e7746e75343a2886ee50fc23a37f9fe5886 /io.c
parentcfdf994071fac150246d54d65a66ddeba4d53a97 (diff)
2000-06-12
git-svn-id: svn+ssh://ci.ruby-lang.org/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 21d76994b5..a35f306b25 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;