1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* io.c (rb_io_initialize): [ruby-dev:24963]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7385 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2004-11-26 06:27:45 +00:00
parent c97c359053
commit 6d0f22ebc6
2 changed files with 15 additions and 17 deletions

View file

@ -1,5 +1,7 @@
Fri Nov 26 14:29:39 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (rb_io_initialize): [ruby-dev:24963]
* io.c (rb_io_initialize): [ruby-dev:24962]
Fri Nov 26 13:49:06 2004 Yukihiro Matsumoto <matz@ruby-lang.org>

20
io.c
View file

@ -3970,14 +3970,6 @@ rb_io_initialize(argc, argv, io)
orig = rb_io_check_io(fnum);
if (NIL_P(orig)) {
fd = NUM2INT(fnum);
}
else {
GetOpenFile(orig, ofp);
if (ofp->refcnt == LONG_MAX) {
VALUE s = rb_inspect(orig);
rb_raise(rb_eIOError, "too many shared IO for %s", StringValuePtr(s));
}
}
if (argc != 2) {
#if defined(HAVE_FCNTL) && defined(F_GETFL)
flags = fcntl(fd, F_GETFL);
@ -3986,20 +3978,24 @@ rb_io_initialize(argc, argv, io)
flags = O_RDONLY;
#endif
}
fmode = rb_io_modenum_flags(flags);
if (!ofp) {
MakeOpenFile(io, fp);
fp->mode = fmode;
fp->mode = rb_io_modenum_flags(flags);
fp->f = rb_fdopen(fd, rb_io_modenum_mode(flags));
}
else {
GetOpenFile(orig, ofp);
if (ofp->refcnt == LONG_MAX) {
VALUE s = rb_inspect(orig);
rb_raise(rb_eIOError, "too many shared IO for %s", StringValuePtr(s));
}
if (argc == 2) {
fmode = rb_io_modenum_flags(flags);
if ((ofp->mode ^ fmode) & (FMODE_READWRITE|FMODE_BINMODE)) {
if (FIXNUM_P(mode)) {
rb_raise(rb_eArgError, "incompatible mode 0%o", flags);
}
else {
rb_raise(rb_eArgError, "incompatible mode %s", RSTRING(mode)->ptr);
rb_raise(rb_eArgError, "incompatible mode \"%s\"", RSTRING(mode)->ptr);
}
}
}