mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7a0bea4fd3
commit
4dff8b2428
3 changed files with 27 additions and 6 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
Sat Aug 16 15:23:16 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* 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@fsij.org>
|
||||
|
||||
* include/ruby/encoding.h (rb_econv_t): add fields: in_buf_start,
|
||||
|
|
|
@ -208,8 +208,6 @@ typedef enum {
|
|||
} 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 @@ typedef struct {
|
|||
} 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;
|
||||
|
|
16
transcode.c
16
transcode.c
|
@ -677,6 +677,8 @@ rb_econv_open_by_transcoder_entries(int n, transcoder_entry_t **entries)
|
|||
}
|
||||
|
||||
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 @@ rb_econv_open_by_transcoder_entries(int n, transcoder_entry_t **entries)
|
|||
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,6 +761,11 @@ rb_econv_open(const char *from, const char *to, int flags)
|
|||
}
|
||||
|
||||
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;
|
||||
|
@ -1687,6 +1692,9 @@ econv_init(int argc, VALUE *argv, VALUE self)
|
|||
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 @@ econv_inspect(VALUE self)
|
|||
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)
|
||||
|
|
Loading…
Reference in a new issue