* io.c (read_all): fptr->enc2 is 0 if no conversion.

(rb_io_getline_fast): ditto.
  (io_getc): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2008-08-23 01:14:33 +00:00
parent 895fd7ec5e
commit 341abd3f88
2 changed files with 11 additions and 9 deletions

View File

@ -1,3 +1,9 @@
Sat Aug 23 10:13:00 2008 Tanaka Akira <akr@fsij.org>
* io.c (read_all): fptr->enc2 is 0 if no conversion.
(rb_io_getline_fast): ditto.
(io_getc): ditto.
Sat Aug 23 09:45:35 2008 Tanaka Akira <akr@fsij.org> Sat Aug 23 09:45:35 2008 Tanaka Akira <akr@fsij.org>
* include/ruby/io.h (rb_io_t): remove path field and add pathv field. * include/ruby/io.h (rb_io_t): remove path field and add pathv field.

14
io.c
View File

@ -1564,7 +1564,7 @@ read_all(rb_io_t *fptr, long siz, VALUE str)
pos = 0; pos = 0;
enc = io_read_encoding(fptr); enc = io_read_encoding(fptr);
cr = fptr->enc2 ? ENC_CODERANGE_BROKEN : 0; cr = 0;
if (siz == 0) siz = BUFSIZ; if (siz == 0) siz = BUFSIZ;
if (NIL_P(str)) { if (NIL_P(str)) {
@ -1588,9 +1588,7 @@ read_all(rb_io_t *fptr, long siz, VALUE str)
} }
if (bytes != siz) rb_str_resize(str, bytes); if (bytes != siz) rb_str_resize(str, bytes);
str = io_enc_str(str, fptr); str = io_enc_str(str, fptr);
if (!fptr->enc2) { ENC_CODERANGE_SET(str, cr);
ENC_CODERANGE_SET(str, cr);
}
return str; return str;
} }
@ -2008,7 +2006,7 @@ rb_io_getline_fast(rb_io_t *fptr, rb_encoding *enc)
VALUE str = Qnil; VALUE str = Qnil;
int len = 0; int len = 0;
long pos = 0; long pos = 0;
int cr = fptr->enc2 ? ENC_CODERANGE_BROKEN : 0; int cr = 0;
for (;;) { for (;;) {
long pending = READ_DATA_PENDING_COUNT(fptr); long pending = READ_DATA_PENDING_COUNT(fptr);
@ -2044,7 +2042,7 @@ rb_io_getline_fast(rb_io_t *fptr, rb_encoding *enc)
} }
str = io_enc_str(str, fptr); str = io_enc_str(str, fptr);
if (!fptr->enc2) ENC_CODERANGE_SET(str, cr); ENC_CODERANGE_SET(str, cr);
fptr->lineno++; fptr->lineno++;
ARGF.lineno = INT2FIX(fptr->lineno); ARGF.lineno = INT2FIX(fptr->lineno);
return str; return str;
@ -2516,9 +2514,7 @@ io_getc(rb_io_t *fptr, rb_encoding *enc)
} }
if (!cr) cr = ENC_CODERANGE_BROKEN; if (!cr) cr = ENC_CODERANGE_BROKEN;
str = io_enc_str(str, fptr); str = io_enc_str(str, fptr);
if (!fptr->enc2) { ENC_CODERANGE_SET(str, cr);
ENC_CODERANGE_SET(str, cr);
}
return str; return str;
} }