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

2000-04-17

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_4@669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2000-04-17 06:24:48 +00:00
parent 57c75615b9
commit cf520dda16
4 changed files with 26 additions and 9 deletions

View file

@ -1,3 +1,8 @@
Mon Apr 17 15:16:31 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* io.c (rb_io_close): to detect some exceptional status, writable
IO should be flushed before close;
Fri Apr 14 23:29:45 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* stable version 1.4.4 released.

20
io.c
View file

@ -211,7 +211,7 @@ io_write(io, str)
}
#endif
if (fptr->mode & FMODE_SYNC) {
fflush(f);
if (fflush(f) == EOF) rb_sys_fail(fptr->path);
}
return INT2FIX(n);
@ -243,7 +243,7 @@ rb_io_flush(io)
rb_io_check_writable(fptr);
f = GetWriteFile(fptr);
if (fflush(f) == EOF) rb_sys_fail(0);
if (fflush(f) == EOF) rb_sys_fail(fptr->path);
return io;
}
@ -958,6 +958,9 @@ rb_io_close(io)
OpenFile *fptr;
fptr = RFILE(io)->fptr;
if (fptr->mode & FMODE_WRITABLE) {
rb_io_flush(io);
}
rb_io_fptr_close(fptr);
if (fptr->pid) {
rb_syswait(fptr->pid);
@ -1698,10 +1701,10 @@ rb_io_reopen(io, nfile)
if (fptr == orig) return io;
if (orig->f2) {
fflush(orig->f2);
if (fflush(orig->f2) == EOF) rb_sys_fail(orig->path);
}
else if (orig->mode & FMODE_WRITABLE) {
fflush(orig->f);
if (fflush(orig->f) == EOF) rb_sys_fail(orig->path);
}
rb_thread_fd_close(fileno(fptr->f));
@ -1814,10 +1817,10 @@ rb_io_clone(io)
MakeOpenFile(obj, fptr);
if (orig->f2) {
fflush(orig->f2);
if (fflush(orig->f2) == EOF) rb_sys_fail(orig->path);
}
else if (orig->mode & FMODE_WRITABLE) {
fflush(orig->f);
if (fflush(orig->f) == EOF) rb_sys_fail(orig->path);
}
/* copy OpenFile structure */
@ -1941,8 +1944,9 @@ rb_io_putc(io, ch)
if (fputc(c, f) == EOF)
rb_sys_fail(fptr->path);
if (fptr->mode & FMODE_SYNC)
fflush(f);
if (fptr->mode & FMODE_SYNC) {
if (fflush(f) == EOF) rb_sys_fail(fptr->path);
}
return ch;
}

View file

@ -671,7 +671,11 @@ $x.each_byte {|i|
}
ok(!$bad)
check "asignment"
s = "a string"
s[0..s.size]="another string"
ok(s == "another string")
check "assignment"
a = nil
ok(defined?(a))
ok(a == nil)

View file

@ -855,6 +855,10 @@ rb_str_replace(str, beg, len, val)
int beg;
int len;
{
if (RSTRING(str)->len < beg + len) {
len = RSTRING(str)->len - beg;
}
if (len < RSTRING(val)->len) {
/* expand string */
REALLOC_N(RSTRING(str)->ptr, char, RSTRING(str)->len+RSTRING(val)->len-len+1);