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

ruby-changes:7137

From: akr <ko1@a...>
Date: Sat, 16 Aug 2008 15:25:58 +0900 (JST)
Subject: [ruby-changes:7137] Ruby:r18655 (trunk): * include/ruby/encoding.h (rb_econv_elem_t): fields removed: from and

akr	2008-08-16 15:25:38 +0900 (Sat, 16 Aug 2008)

  New Revision: 18655

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

  Log:
    * include/ruby/encoding.h (rb_econv_elem_t): fields removed: from and
      to.
      (rb_econv_t): new fields: source_encoding_name and
      destination_encoding_name.
    
    * transcode.c (rb_econv_open_by_transcoder_entries): initialize the
      new fields.
      (rb_econv_open): set up the new fields.
      (econv_inspect): use the new fields.

  Modified files:
    trunk/ChangeLog
    trunk/include/ruby/encoding.h
    trunk/transcode.c

Index: include/ruby/encoding.h
===================================================================
--- include/ruby/encoding.h	(revision 18654)
+++ include/ruby/encoding.h	(revision 18655)
@@ -208,8 +208,6 @@
 } rb_econv_result_t;
 
 typedef struct {
-    const char *from;
-    const char *to;
     struct rb_transcoding *tc;
     unsigned char *out_buf_start;
     unsigned char *out_data_start;
@@ -219,6 +217,9 @@
 } rb_econv_elem_t;
 
 typedef struct {
+    const char *source_encoding_name;
+    const char *destination_encoding_name;
+
     unsigned char *in_buf_start;
     unsigned char *in_data_start;
     unsigned char *in_data_end;
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 18654)
+++ ChangeLog	(revision 18655)
@@ -1,3 +1,15 @@
+Sat Aug 16 15:23:16 2008  Tanaka Akira  <akr@f...>
+
+	* include/ruby/encoding.h (rb_econv_elem_t): fields removed: from and
+	  to.
+	  (rb_econv_t): new fields: source_encoding_name and
+	  destination_encoding_name.
+
+	* transcode.c (rb_econv_open_by_transcoder_entries): initialize the
+	  new fields.
+	  (rb_econv_open): set up the new fields.
+	  (econv_inspect): use the new fields.
+
 Sat Aug 16 14:22:04 2008  Tanaka Akira  <akr@f...>
 
 	* include/ruby/encoding.h (rb_econv_t): add fields: in_buf_start,
Index: transcode.c
===================================================================
--- transcode.c	(revision 18654)
+++ transcode.c	(revision 18655)
@@ -677,6 +677,8 @@
     }
 
     ec = ALLOC(rb_econv_t);
+    ec->source_encoding_name = NULL;
+    ec->destination_encoding_name = NULL;
     ec->in_buf_start = NULL;
     ec->in_data_start = NULL;
     ec->in_data_end = NULL;
@@ -690,8 +692,6 @@
     ec->destination_encoding = NULL;
     for (i = 0; i < ec->num_trans; i++) {
         const rb_transcoder *tr = load_transcoder_entry(entries[i]);
-        ec->elems[i].from = tr->from_encoding;
-        ec->elems[i].to = tr->to_encoding;
         ec->elems[i].tc = rb_transcoding_open_by_transcoder(tr, 0);
         ec->elems[i].out_buf_start = NULL;
         ec->elems[i].out_data_start = NULL;
@@ -761,7 +761,12 @@
     }
 
     ec = rb_econv_open_by_transcoder_entries(num_trans, entries);
+    if (!ec)
+        rb_raise(rb_eArgError, "encoding conversion not supported (from %s to %s)", from, to);
 
+    ec->source_encoding_name = from;
+    ec->destination_encoding_name = to;
+
     if (flags & ECONV_UNIVERSAL_NEWLINE_DECODER) {
         ec->last_tc = ec->elems[ec->num_trans-2].tc;
         ec->last_trans_index = ec->num_trans-2;
@@ -1687,6 +1692,9 @@
     ec->source_encoding = senc;
     ec->destination_encoding = denc;
 
+    ec->source_encoding_name = ec->elems[0].tc->transcoder->from_encoding;
+    ec->destination_encoding_name = ec->last_tc->transcoder->to_encoding;
+
     DATA_PTR(self) = ec;
 
     return self;
@@ -1702,8 +1710,8 @@
         return rb_sprintf("#<%s: uninitialized>", cname);
     else
         return rb_sprintf("#<%s: %s to %s>", cname,
-            ec->elems[0].from,
-            ec->last_tc->transcoder->to_encoding);
+            ec->source_encoding_name,
+            ec->destination_encoding_name);
 }
 
 #define IS_ECONV(obj) (RDATA(obj)->dfree == (RUBY_DATA_FUNC)econv_free)

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

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