diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-06-12 07:48:31 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-06-12 07:48:31 +0000 |
commit | 548b5143db2c3d701520671ef1413cf3c39fcedf (patch) | |
tree | f89e9e7746e75343a2886ee50fc23a37f9fe5886 /io.c | |
parent | cfdf994071fac150246d54d65a66ddeba4d53a97 (diff) | |
download | ruby-548b5143db2c3d701520671ef1413cf3c39fcedf.tar.gz |
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.c | 26 |
1 files changed, 17 insertions, 9 deletions
@@ -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; |