diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-25 17:45:30 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-25 17:45:30 +0000 |
commit | 75b2d7cbe8538c9414f579c3c56becf9b63986b6 (patch) | |
tree | 587648c2930f02467756fd26c91ad1a6f0f0320b | |
parent | 08911df3117cb9cf6625117c1c6a109cff64b1ad (diff) | |
download | ruby-75b2d7cbe8538c9414f579c3c56becf9b63986b6.tar.gz |
* include/ruby/io.h (rb_io_t): new field: writeconv_pre_opts.
* io.c (make_writeconv): initialize writeconv_pre_opts.
(io_fwrite): use writeconv_pre_opts.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18856 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | include/ruby/io.h | 1 | ||||
-rw-r--r-- | io.c | 21 |
3 files changed, 17 insertions, 12 deletions
@@ -1,3 +1,10 @@ +Tue Aug 26 02:43:50 2008 Tanaka Akira <akr@fsij.org> + + * include/ruby/io.h (rb_io_t): new field: writeconv_pre_opts. + + * io.c (make_writeconv): initialize writeconv_pre_opts. + (io_fwrite): use writeconv_pre_opts. + Tue Aug 26 01:48:31 2008 Tanaka Akira <akr@fsij.org> * io.c: test _WIN32 for CRLF platform. (cygwin defines O_BINARY.) diff --git a/include/ruby/io.h b/include/ruby/io.h index 189a5f211c..6d71edaec4 100644 --- a/include/ruby/io.h +++ b/include/ruby/io.h @@ -69,6 +69,7 @@ typedef struct rb_io_t { rb_econv_t *writeconv; VALUE writeconv_stateless; + rb_econv_option_t writeconv_pre_opts; int writeconv_initialized; } rb_io_t; @@ -696,6 +696,8 @@ make_writeconv(rb_io_t *fptr) fptr->writeconv_initialized = 1; + rb_econv_opts(Qnil, &fptr->writeconv_pre_opts); + ecopts = fptr->encs.opts; #ifdef TEXTMODE_NEWLINE_ENCODER @@ -716,18 +718,18 @@ make_writeconv(rb_io_t *fptr) if (senc) { denc = enc->name; fptr->writeconv_stateless = rb_str_new2(senc); - } - else { - denc = NULL; - fptr->writeconv_stateless = Qnil; - } - if (senc) { fptr->writeconv = rb_econv_open(senc, denc, &ecopts); if (!fptr->writeconv) rb_exc_raise(rb_econv_open_exc(senc, denc, &ecopts)); } else { + denc = NULL; + fptr->writeconv_stateless = Qnil; fptr->writeconv = NULL; +#ifdef TEXTMODE_NEWLINE_ENCODER + if (NEED_NEWLINE_ENCODER(fptr)) + fptr->writeconv_pre_opts.flags |= TEXTMODE_NEWLINE_ENCODER; +#endif } } } @@ -754,12 +756,7 @@ io_fwrite(VALUE str, rb_io_t *fptr) } if (!NIL_P(common_encoding)) { - rb_econv_option_t ecopts = fptr->encs.opts; -#ifdef TEXTMODE_NEWLINE_ENCODER - if (NEED_NEWLINE_ENCODER(fptr)) - ecopts.flags |= TEXTMODE_NEWLINE_ENCODER; -#endif - str = rb_str_transcode(str, common_encoding, &ecopts); + str = rb_str_transcode(str, common_encoding, &fptr->writeconv_pre_opts); } if (fptr->writeconv) { |