summaryrefslogtreecommitdiff
path: root/transcode.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-09 11:18:59 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-09 11:18:59 +0000
commit4fcb83c06cce321fedb150663a95b6345c1292e2 (patch)
treeead85001db3de29f375525e644db87ea996057d8 /transcode.c
parent6eef0808a5caea71f19ba8d6aaeb85044e746631 (diff)
* transcode.c (rb_econv_open0): num_encoders and num_decoders removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'transcode.c')
-rw-r--r--transcode.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/transcode.c b/transcode.c
index 12257813ec..a68558a78d 100644
--- a/transcode.c
+++ b/transcode.c
@@ -891,11 +891,6 @@ rb_econv_open0(const char *sname, const char *dname, int ecflags)
rb_encoding *senc, *denc;
int sidx, didx;
- int num_encoders, num_decoders;
-
- num_encoders = 0;
- num_decoders = 0;
-
senc = NULL;
if (*sname) {
sidx = rb_enc_find_index(sname);
@@ -914,23 +909,20 @@ rb_econv_open0(const char *sname, const char *dname, int ecflags)
if (*sname == '\0' && *dname == '\0') {
num_trans = 0;
- entries = ALLOC_N(transcoder_entry_t *, num_encoders+num_decoders);
+ entries = NULL;
}
else {
struct trans_open_t toarg;
toarg.entries = NULL;
- toarg.num_additional = num_encoders+num_decoders;
+ toarg.num_additional = 0;
num_trans = transcode_search_path(sname, dname, trans_open_i, (void *)&toarg);
entries = toarg.entries;
+ if (num_trans < 0) {
+ xfree(entries);
+ return NULL;
+ }
}
- if (num_trans < 0 || !entries) {
- xfree(entries);
- return NULL;
- }
-
- num_trans += num_encoders + num_decoders;
-
ec = rb_econv_open_by_transcoder_entries(num_trans, entries);
xfree(entries);
if (!ec)
@@ -940,12 +932,12 @@ rb_econv_open0(const char *sname, const char *dname, int ecflags)
ec->source_encoding_name = sname;
ec->destination_encoding_name = dname;
- if (num_trans == num_encoders + num_decoders) {
+ if (num_trans == 0) {
ec->last_tc = NULL;
ec->last_trans_index = -1;
}
else {
- ec->last_trans_index = ec->num_trans-1-num_decoders;
+ ec->last_trans_index = ec->num_trans-1;
ec->last_tc = ec->elems[ec->last_trans_index].tc;
}