From 548b5143db2c3d701520671ef1413cf3c39fcedf Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 12 Jun 2000 07:48:31 +0000 Subject: 2000-06-12 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- io.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'io.c') 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; -- cgit v1.2.3