[前][次][番号順一覧][スレッド一覧]

ruby-changes:7337

From: akr <ko1@a...>
Date: Tue, 26 Aug 2008 02:45:46 +0900 (JST)
Subject: [ruby-changes:7337] Ruby:r18856 (trunk): * include/ruby/io.h (rb_io_t): new field: writeconv_pre_opts.

akr	2008-08-26 02:45:30 +0900 (Tue, 26 Aug 2008)

  New Revision: 18856

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=18856

  Log:
    * 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.

  Modified files:
    trunk/ChangeLog
    trunk/include/ruby/io.h
    trunk/io.c

Index: include/ruby/io.h
===================================================================
--- include/ruby/io.h	(revision 18855)
+++ include/ruby/io.h	(revision 18856)
@@ -69,6 +69,7 @@
 
     rb_econv_t *writeconv;
     VALUE writeconv_stateless;
+    rb_econv_option_t writeconv_pre_opts;
     int writeconv_initialized;
 
 } rb_io_t;
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 18855)
+++ ChangeLog	(revision 18856)
@@ -1,3 +1,10 @@
+Tue Aug 26 02:43:50 2008  Tanaka Akira  <akr@f...>
+
+	* 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@f...>
 
 	* io.c: test _WIN32 for CRLF platform.  (cygwin defines O_BINARY.)
Index: io.c
===================================================================
--- io.c	(revision 18855)
+++ io.c	(revision 18856)
@@ -696,6 +696,8 @@
 
         fptr->writeconv_initialized = 1;
 
+        rb_econv_opts(Qnil, &fptr->writeconv_pre_opts);
+
         ecopts = fptr->encs.opts;
 
 #ifdef TEXTMODE_NEWLINE_ENCODER
@@ -716,18 +718,18 @@
         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 @@
         }
 
         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) {

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]