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

ruby-changes:7769

From: akr <ko1@a...>
Date: Thu, 11 Sep 2008 03:03:17 +0900 (JST)
Subject: [ruby-changes:7769] Ruby:r19290 (trunk): * io.c (io_binwrite): extracted from io_fwrite.

akr	2008-09-11 03:00:36 +0900 (Thu, 11 Sep 2008)

  New Revision: 19290

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

  Log:
    * io.c (io_binwrite): extracted from io_fwrite.

  Modified files:
    trunk/ChangeLog
    trunk/io.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 19289)
+++ ChangeLog	(revision 19290)
@@ -1,3 +1,7 @@
+Thu Sep 11 02:59:47 2008  Tanaka Akira  <akr@f...>
+
+	* io.c (io_binwrite): extracted from io_fwrite.
+
 Thu Sep 11 02:25:34 2008  Tanaka Akira  <akr@f...>
 
 	* transcode.c (make_encoding): new function.
Index: io.c
===================================================================
--- io.c	(revision 19289)
+++ io.c	(revision 19290)
@@ -744,40 +744,12 @@
 }
 
 /* writing functions */
+
 static long
-io_fwrite(VALUE str, rb_io_t *fptr)
+io_binwrite(VALUE str, rb_io_t *fptr)
 {
     long len, n, r, l, offset = 0;
 
-    if (NEED_WRITECONV(fptr)) {
-        VALUE common_encoding = Qnil;
-        make_writeconv(fptr);
-
-        if (fptr->writeconv) {
-            if (!NIL_P(fptr->writeconv_asciicompat))
-                common_encoding = fptr->writeconv_asciicompat;
-            else if (!rb_enc_asciicompat(rb_enc_get(str))) {
-                rb_raise(rb_eArgError, "ASCII incompatible string written for text mode IO without encoding conversion: %s",
-                         rb_enc_name(rb_enc_get(str)));
-            }
-        }
-        else {
-            if (fptr->encs.enc2)
-                common_encoding = rb_enc_from_encoding(fptr->encs.enc2);
-            else
-                common_encoding = rb_enc_from_encoding(fptr->encs.enc);
-        }
-
-        if (!NIL_P(common_encoding)) {
-            str = rb_str_transcode(str, common_encoding,
-                fptr->writeconv_pre_ecflags, fptr->writeconv_pre_ecopts);
-        }
-
-        if (fptr->writeconv) {
-            str = rb_econv_str_convert(fptr->writeconv, str, ECONV_PARTIAL_INPUT);
-        }
-    }
-
     len = RSTRING_LEN(str);
     if ((n = len) <= 0) return n;
     if (fptr->wbuf == NULL && !(fptr->mode & FMODE_SYNC)) {
@@ -840,6 +812,41 @@
     return len;
 }
 
+static long
+io_fwrite(VALUE str, rb_io_t *fptr)
+{
+    if (NEED_WRITECONV(fptr)) {
+        VALUE common_encoding = Qnil;
+        make_writeconv(fptr);
+
+        if (fptr->writeconv) {
+            if (!NIL_P(fptr->writeconv_asciicompat))
+                common_encoding = fptr->writeconv_asciicompat;
+            else if (!rb_enc_asciicompat(rb_enc_get(str))) {
+                rb_raise(rb_eArgError, "ASCII incompatible string written for text mode IO without encoding conversion: %s",
+                         rb_enc_name(rb_enc_get(str)));
+            }
+        }
+        else {
+            if (fptr->encs.enc2)
+                common_encoding = rb_enc_from_encoding(fptr->encs.enc2);
+            else
+                common_encoding = rb_enc_from_encoding(fptr->encs.enc);
+        }
+
+        if (!NIL_P(common_encoding)) {
+            str = rb_str_transcode(str, common_encoding,
+                fptr->writeconv_pre_ecflags, fptr->writeconv_pre_ecopts);
+        }
+
+        if (fptr->writeconv) {
+            str = rb_econv_str_convert(fptr->writeconv, str, ECONV_PARTIAL_INPUT);
+        }
+    }
+
+    return io_binwrite(str, fptr);
+}
+
 long
 rb_io_fwrite(const char *ptr, long len, FILE *f)
 {

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

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