summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-11-30 14:38:26 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-11-30 14:38:26 +0000
commit05e5590ece1f0644d129a93801d711a9d298d02f (patch)
tree7fe8f7f73cb3c48272f5defa0a96cee10012fb31
parenta70f475dbbdd0e8f2b14d98aefc3d01fc5af3d17 (diff)
* io.c (io_fread): need not to null terminate. [ruby-dev:24998]
* io.c (read_all): remove unnecessary rb_str_resize(). [ruby-dev:24996] (backported from CVS HEAD) * io.c (io_readpartial): ditto. * io.c (io_read): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog11
-rw-r--r--io.c13
2 files changed, 17 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index f9e87ee9c7..51e686a280 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Tue Nov 30 23:38:18 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * io.c (io_fread): need not to null terminate. [ruby-dev:24998]
+
+ * io.c (read_all): remove unnecessary rb_str_resize().
+ [ruby-dev:24996] (backported from CVS HEAD)
+
+ * io.c (io_readpartial): ditto.
+
+ * io.c (io_read): ditto.
+
Mon Nov 29 16:06:04 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/stringio/stringio.c (strio_write): insufficiently filled string
diff --git a/io.c b/io.c
index ba7f4b08ec..04e8d572bf 100644
--- a/io.c
+++ b/io.c
@@ -988,7 +988,6 @@ io_fread(ptr, len, fptr)
}
if (len == n) return 0;
}
- *ptr = '\0';
break;
}
*ptr++ = c;
@@ -1064,7 +1063,6 @@ read_all(fptr, siz, str)
n = io_fread(RSTRING(str)->ptr+bytes, siz-bytes, fptr);
rb_str_unlocktmp(str);
if (n == 0 && bytes == 0) {
- rb_str_resize(str,0);
if (!fptr->f) break;
if (feof(fptr->f)) break;
if (!ferror(fptr->f)) break;
@@ -1140,11 +1138,14 @@ io_read(argc, argv, io)
n = io_fread(RSTRING(str)->ptr, len, fptr);
rb_str_unlocktmp(str);
if (n == 0) {
- rb_str_resize(str,0);
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);
}
+ rb_str_resize(str, n);
RSTRING(str)->len = n;
RSTRING(str)->ptr[n] = '\0';
OBJ_TAINT(str);
@@ -2184,14 +2185,12 @@ rb_io_sysread(argc, argv, io)
TRAP_END;
if (n == -1) {
- rb_str_resize(str, 0);
rb_sys_fail(fptr->path);
}
+ rb_str_resize(str, n);
if (n == 0 && ilen > 0) {
- rb_str_resize(str, 0);
rb_eof_error();
}
-
RSTRING(str)->len = n;
RSTRING(str)->ptr[n] = '\0';
OBJ_TAINT(str);