* io.c (rb_io_mode_enc): do not set encoding unless explicitly
specified. * io.c (rb_io_check_readable): fill fptr->enc by default_external if it's empty. * io.c (io_enc_str): fptr->enc is always set for reading IO (by rb_io_check_readable(fptr)). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b83cbb0c7c
commit
e8a71bc853
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
Sun Dec 23 01:56:18 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* io.c (rb_io_mode_enc): do not set encoding unless explicitly
|
||||||
|
specified.
|
||||||
|
|
||||||
|
* io.c (rb_io_check_readable): fill fptr->enc by default_external
|
||||||
|
if it's empty.
|
||||||
|
|
||||||
|
* io.c (io_enc_str): fptr->enc is always set for reading IO (by
|
||||||
|
rb_io_check_readable(fptr)).
|
||||||
|
|
||||||
Sun Dec 23 01:18:06 2007 David Flanagan <david@davidflanagan.com>
|
Sun Dec 23 01:18:06 2007 David Flanagan <david@davidflanagan.com>
|
||||||
|
|
||||||
* io.c, io.h: temporary patch to partially implement
|
* io.c, io.h: temporary patch to partially implement
|
||||||
|
20
io.c
20
io.c
@ -347,8 +347,10 @@ rb_io_check_readable(rb_io_t *fptr)
|
|||||||
if (fptr->wbuf_len) {
|
if (fptr->wbuf_len) {
|
||||||
io_fflush(fptr);
|
io_fflush(fptr);
|
||||||
}
|
}
|
||||||
if (!fptr->enc && fptr->fd == 0) {
|
if (!fptr->enc) {
|
||||||
fptr->enc = rb_default_external_encoding();
|
fptr->enc = (fptr->fd == 0)
|
||||||
|
? rb_default_external_encoding()
|
||||||
|
: rb_ascii_encoding();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -627,7 +629,7 @@ io_fwrite(VALUE str, rb_io_t *fptr)
|
|||||||
* the strings encoding then we must transcode before writing.
|
* the strings encoding then we must transcode before writing.
|
||||||
* We must also transcode if two encodings were specified
|
* We must also transcode if two encodings were specified
|
||||||
*/
|
*/
|
||||||
if (fptr->enc && (fptr->enc2 || fptr->enc != rb_enc_get(str))) {
|
if (fptr->enc) {
|
||||||
/* transcode str before output */
|
/* transcode str before output */
|
||||||
/* the methods in transcode.c are static, so call indirectly */
|
/* the methods in transcode.c are static, so call indirectly */
|
||||||
/* Can't use encode! because puts writes a frozen newline */
|
/* Can't use encode! because puts writes a frozen newline */
|
||||||
@ -1298,7 +1300,6 @@ static VALUE
|
|||||||
io_enc_str(VALUE str, rb_io_t *fptr)
|
io_enc_str(VALUE str, rb_io_t *fptr)
|
||||||
{
|
{
|
||||||
OBJ_TAINT(str);
|
OBJ_TAINT(str);
|
||||||
if (fptr->enc) {
|
|
||||||
if (fptr->enc2) {
|
if (fptr->enc2) {
|
||||||
/* two encodings, so transcode from enc2 to enc */
|
/* two encodings, so transcode from enc2 to enc */
|
||||||
/* the methods in transcode.c are static, so call indirectly */
|
/* the methods in transcode.c are static, so call indirectly */
|
||||||
@ -1310,7 +1311,6 @@ io_enc_str(VALUE str, rb_io_t *fptr)
|
|||||||
/* just one encoding, so associate it with the string */
|
/* just one encoding, so associate it with the string */
|
||||||
rb_enc_associate(str, fptr->enc);
|
rb_enc_associate(str, fptr->enc);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2175,7 +2175,7 @@ rb_io_getc(VALUE io)
|
|||||||
GetOpenFile(io, fptr);
|
GetOpenFile(io, fptr);
|
||||||
rb_io_check_readable(fptr);
|
rb_io_check_readable(fptr);
|
||||||
|
|
||||||
enc = fptr->enc ? fptr->enc : rb_default_external_encoding();
|
enc = fptr->enc;
|
||||||
READ_CHECK(fptr);
|
READ_CHECK(fptr);
|
||||||
if (io_fillbuf(fptr) < 0) {
|
if (io_fillbuf(fptr) < 0) {
|
||||||
return Qnil;
|
return Qnil;
|
||||||
@ -2327,7 +2327,7 @@ rb_io_ungetc(VALUE io, VALUE c)
|
|||||||
GetOpenFile(io, fptr);
|
GetOpenFile(io, fptr);
|
||||||
rb_io_check_readable(fptr);
|
rb_io_check_readable(fptr);
|
||||||
if (NIL_P(c)) return Qnil;
|
if (NIL_P(c)) return Qnil;
|
||||||
enc = fptr->enc ? fptr->enc : rb_default_external_encoding();
|
enc = fptr->enc;
|
||||||
if (FIXNUM_P(c)) {
|
if (FIXNUM_P(c)) {
|
||||||
int cc = FIX2INT(c);
|
int cc = FIX2INT(c);
|
||||||
char buf[16];
|
char buf[16];
|
||||||
@ -3123,12 +3123,6 @@ rb_io_mode_enc(rb_io_t *fptr, const char *mode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (fptr->mode & FMODE_BINMODE) {
|
|
||||||
fptr->enc = rb_ascii_encoding();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fptr->enc = rb_default_external_encoding();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sysopen_struct {
|
struct sysopen_struct {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#define RUBY_VERSION "1.9.0"
|
#define RUBY_VERSION "1.9.0"
|
||||||
#define RUBY_RELEASE_DATE "2007-12-22"
|
#define RUBY_RELEASE_DATE "2007-12-23"
|
||||||
#define RUBY_VERSION_CODE 190
|
#define RUBY_VERSION_CODE 190
|
||||||
#define RUBY_RELEASE_CODE 20071222
|
#define RUBY_RELEASE_CODE 20071223
|
||||||
#define RUBY_PATCHLEVEL 0
|
#define RUBY_PATCHLEVEL 0
|
||||||
|
|
||||||
#define RUBY_VERSION_MAJOR 1
|
#define RUBY_VERSION_MAJOR 1
|
||||||
@ -9,7 +9,7 @@
|
|||||||
#define RUBY_VERSION_TEENY 0
|
#define RUBY_VERSION_TEENY 0
|
||||||
#define RUBY_RELEASE_YEAR 2007
|
#define RUBY_RELEASE_YEAR 2007
|
||||||
#define RUBY_RELEASE_MONTH 12
|
#define RUBY_RELEASE_MONTH 12
|
||||||
#define RUBY_RELEASE_DAY 22
|
#define RUBY_RELEASE_DAY 23
|
||||||
|
|
||||||
#ifdef RUBY_EXTERN
|
#ifdef RUBY_EXTERN
|
||||||
RUBY_EXTERN const char ruby_version[];
|
RUBY_EXTERN const char ruby_version[];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user