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

* re.c (match_setter): it's OK to assign nil to $~.

* io.c (rb_io_fptr_cleanup): do not close IO created by for_fd().

* io.c (rb_io_initialize): mark IO created by for_fd

* ext/socket/socket.c (bsock_s_for_fd): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2312 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2002-04-01 07:39:09 +00:00
parent 1ecdc6a115
commit 1550277b34
4 changed files with 41 additions and 15 deletions

View file

@ -7,6 +7,18 @@ Mon Apr 1 15:11:40 2002 NAKAMURA Usaku <usa@ruby-lang.org>
* ext/tcltklib/tcltklib.c: prototypes; _timer_for_tcl() and ip_ruby(),
Nobu's patch at [ruby-dev:14483].
Mon Apr 1 10:56:40 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
* re.c (match_setter): it's OK to assign nil to $~.
Mon Apr 1 03:55:46 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (rb_io_fptr_cleanup): do not close IO created by for_fd().
* io.c (rb_io_initialize): mark IO created by for_fd
* ext/socket/socket.c (bsock_s_for_fd): ditto.
Fri Mar 29 20:21:58 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
* lib/mkmf.rb (create_makefile): default FLAGS to empty strings.

39
io.c
View file

@ -1194,6 +1194,7 @@ rb_io_fptr_cleanup(fptr, fin)
OpenFile *fptr;
int fin;
{
if (fptr->mode & FMODE_FDOPEN) return;
if (fptr->finalize) {
(*fptr->finalize)(fptr);
}
@ -1469,7 +1470,7 @@ rb_io_mode_flags(mode)
}
static int
rb_io_binmode_flags(mode)
rb_io_modenum_flags(mode)
int mode;
{
int flags;
@ -1496,7 +1497,7 @@ rb_io_binmode_flags(mode)
}
static int
rb_io_mode_binmode(mode)
rb_io_mode_modenum(mode)
const char *mode;
{
int flags = 0;
@ -1534,7 +1535,7 @@ rb_io_mode_binmode(mode)
}
static char*
rb_io_binmode_mode(flags, mode)
rb_io_modenum_mode(flags, mode)
int flags;
char *mode;
{
@ -1548,7 +1549,7 @@ rb_io_binmode_mode(flags, mode)
*p++ = 'w';
break;
case O_RDWR:
*p++ = 'w';
*p++ = 'r';
*p++ = '+';
break;
}
@ -1678,8 +1679,8 @@ rb_file_sysopen_internal(io, fname, flags, mode)
MakeOpenFile(io, fptr);
fd = rb_sysopen(fname, flags, mode);
m = rb_io_binmode_mode(flags, mbuf);
fptr->mode = rb_io_binmode_flags(flags);
m = rb_io_modenum_mode(flags, mbuf);
fptr->mode = rb_io_modenum_flags(flags);
fptr->f = rb_fdopen(fd, m);
fptr->path = strdup(fname);
@ -1923,7 +1924,7 @@ rb_io_popen(str, argc, argv, klass)
mode = "r";
}
else if (FIXNUM_P(pmode)) {
mode = rb_io_binmode_mode(FIX2INT(pmode), mbuf);
mode = rb_io_modenum_mode(FIX2INT(pmode), mbuf);
}
else {
mode = StringValuePtr(pmode);
@ -1976,7 +1977,7 @@ rb_open_file(argc, argv, io)
path = RSTRING(fname)->ptr;
if (FIXNUM_P(vmode) || !NIL_P(perm)) {
flags = FIXNUM_P(vmode) ? NUM2INT(vmode) : rb_io_mode_binmode(StringValuePtr(vmode));
flags = FIXNUM_P(vmode) ? NUM2INT(vmode) : rb_io_mode_modenum(StringValuePtr(vmode));
fmode = NIL_P(perm) ? 0666 : NUM2INT(perm);
file = rb_file_sysopen_internal(io, path, flags, fmode);
@ -2601,15 +2602,25 @@ rb_io_initialize(argc, argv, io)
{
VALUE fnum, mode;
OpenFile *fp;
char *m = "r";
int fd, flags;
char mbuf[4];
if (rb_scan_args(argc, argv, "11", &fnum, &mode) == 2) {
rb_scan_args(argc, argv, "11", &fnum, &mode);
fd = NUM2INT(fnum);
if (argc == 2) {
SafeStringValue(mode);
m = RSTRING(mode)->ptr;
flags = rb_io_mode_flags(RSTRING(mode)->ptr);
}
else {
#if defined(HAVE_FCNTL) && defined(F_GETFL)
flags = fcntl(fd, F_GETFL);
#else
flags = O_RDONLY;
#endif
}
MakeOpenFile(io, fp);
fp->f = rb_fdopen(NUM2INT(fnum), m);
fp->mode = rb_io_mode_flags(m);
fp->mode = rb_io_modenum_flags(flags) | FMODE_FDOPEN;
fp->f = rb_fdopen(fd, rb_io_modenum_mode(flags, mbuf));
return io;
}
@ -2647,7 +2658,7 @@ rb_io_s_new(argc, argv, klass)
if (rb_block_given_p()) {
char *cname = rb_class2name(klass);
rb_warn("%s::new() does not take block; use %::open() instead",
rb_warn("%s::new() does not take block; use %s::open() instead",
cname, cname);
}
return rb_class_new_instance(argc, argv, klass);

4
re.c
View file

@ -1392,7 +1392,9 @@ static void
match_setter(val)
VALUE val;
{
Check_Type(val, T_MATCH);
if (!NIL_P(val)) {
Check_Type(val, T_MATCH);
}
rb_backref_set(val);
}

View file

@ -32,6 +32,7 @@ typedef struct OpenFile {
#define FMODE_BINMODE 4
#define FMODE_SYNC 8
#define FMODE_WBUF 16
#define FMODE_FDOPEN 32
#define GetOpenFile(obj,fp) rb_io_check_closed((fp) = RFILE(rb_io_taint_check(obj))->fptr)