* io.c (io_fread): need not to null terminate. [ruby-dev:24998]
* io.c (read_all): remove unnecessary rb_str_resize(). [ruby-dev:24996] * io.c (io_readpartial): ditto. * io.c (io_read): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7425 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ee6869c8d6
commit
e6e84eab64
@ -1,5 +1,7 @@
|
|||||||
Tue Nov 30 16:18:50 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Tue Nov 30 16:18:50 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* io.c (io_fread): need not to null terminate. [ruby-dev:24998]
|
||||||
|
|
||||||
* eval.c (rb_eval): should check previous frame for ZSUPER.
|
* eval.c (rb_eval): should check previous frame for ZSUPER.
|
||||||
|
|
||||||
* io.c (read_all): remove unnecessary rb_str_resize().
|
* io.c (read_all): remove unnecessary rb_str_resize().
|
||||||
|
14
io.c
14
io.c
@ -1009,7 +1009,6 @@ io_fread(ptr, len, fptr)
|
|||||||
}
|
}
|
||||||
if (len == n) return 0;
|
if (len == n) return 0;
|
||||||
}
|
}
|
||||||
*ptr = '\0';
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*ptr++ = c;
|
*ptr++ = c;
|
||||||
@ -1086,7 +1085,6 @@ read_all(fptr, siz, str)
|
|||||||
n = io_fread(RSTRING(str)->ptr+bytes, siz-bytes, fptr);
|
n = io_fread(RSTRING(str)->ptr+bytes, siz-bytes, fptr);
|
||||||
rb_str_unlocktmp(str);
|
rb_str_unlocktmp(str);
|
||||||
if (n == 0 && bytes == 0) {
|
if (n == 0 && bytes == 0) {
|
||||||
rb_str_resize(str,0);
|
|
||||||
if (!fptr->f) break;
|
if (!fptr->f) break;
|
||||||
if (feof(fptr->f)) break;
|
if (feof(fptr->f)) break;
|
||||||
if (!ferror(fptr->f)) break;
|
if (!ferror(fptr->f)) break;
|
||||||
@ -1203,7 +1201,6 @@ io_readpartial(argc, argv, io)
|
|||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
if (rb_io_wait_readable(fileno(fptr->f)))
|
if (rb_io_wait_readable(fileno(fptr->f)))
|
||||||
goto again;
|
goto again;
|
||||||
rb_str_resize(str, 0);
|
|
||||||
rb_sys_fail(fptr->path);
|
rb_sys_fail(fptr->path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1274,11 +1271,14 @@ io_read(argc, argv, io)
|
|||||||
n = io_fread(RSTRING(str)->ptr, len, fptr);
|
n = io_fread(RSTRING(str)->ptr, len, fptr);
|
||||||
rb_str_unlocktmp(str);
|
rb_str_unlocktmp(str);
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
rb_str_resize(str,0);
|
|
||||||
if (!fptr->f) return Qnil;
|
if (!fptr->f) return Qnil;
|
||||||
if (feof(fptr->f)) return Qnil;
|
if (feof(fptr->f)) {
|
||||||
|
rb_str_resize(str, 0);
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
if (len > 0) rb_sys_fail(fptr->path);
|
if (len > 0) rb_sys_fail(fptr->path);
|
||||||
}
|
}
|
||||||
|
rb_str_resize(str, n);
|
||||||
RSTRING(str)->len = n;
|
RSTRING(str)->len = n;
|
||||||
RSTRING(str)->ptr[n] = '\0';
|
RSTRING(str)->ptr[n] = '\0';
|
||||||
OBJ_TAINT(str);
|
OBJ_TAINT(str);
|
||||||
@ -2335,14 +2335,12 @@ rb_io_sysread(argc, argv, io)
|
|||||||
|
|
||||||
rb_str_unlocktmp(str);
|
rb_str_unlocktmp(str);
|
||||||
if (n == -1) {
|
if (n == -1) {
|
||||||
rb_str_resize(str, 0);
|
|
||||||
rb_sys_fail(fptr->path);
|
rb_sys_fail(fptr->path);
|
||||||
}
|
}
|
||||||
|
rb_str_resize(str, n);
|
||||||
if (n == 0 && ilen > 0) {
|
if (n == 0 && ilen > 0) {
|
||||||
rb_str_resize(str, 0);
|
|
||||||
rb_eof_error();
|
rb_eof_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
RSTRING(str)->len = n;
|
RSTRING(str)->len = n;
|
||||||
RSTRING(str)->ptr[n] = '\0';
|
RSTRING(str)->ptr[n] = '\0';
|
||||||
OBJ_TAINT(str);
|
OBJ_TAINT(str);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user