diff options
| author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-11-30 14:38:26 +0000 |
|---|---|---|
| committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-11-30 14:38:26 +0000 |
| commit | 093d6d33c0c23c4573f87e51af6f9adcfcc8d8ea (patch) | |
| tree | 7fe8f7f73cb3c48272f5defa0a96cee10012fb31 | |
| parent | d571f1ee694b4dc77e33db39b9c911add8853703 (diff) | |
| download | ruby-093d6d33c0c23c4573f87e51af6f9adcfcc8d8ea.tar.gz ruby-093d6d33c0c23c4573f87e51af6f9adcfcc8d8ea.tar.xz ruby-093d6d33c0c23c4573f87e51af6f9adcfcc8d8ea.zip | |
* 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: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@7426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 11 | ||||
| -rw-r--r-- | io.c | 13 |
2 files changed, 17 insertions, 7 deletions
@@ -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 @@ -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); |
