From 6d87cec02ce763dd1c26b3ba026056c037d67704 Mon Sep 17 00:00:00 2001 From: akr Date: Tue, 12 Aug 2008 09:42:49 +0000 Subject: * transcode_data.h (rb_trans_elem_t): new field: from and to. * transcode.c (trans_open_i): just record from and to. (rb_trans_open): load transcodings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18531 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ transcode.c | 38 ++++++++++++++++++++++++-------------- transcode_data.h | 2 ++ 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 28b865b56c..e1079dd1dc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Tue Aug 12 18:32:33 2008 Tanaka Akira + + * transcode_data.h (rb_trans_elem_t): new field: from and to. + + * transcode.c (trans_open_i): just record from and to. + (rb_trans_open): load transcodings. + Tue Aug 12 18:32:03 2008 Akinori MUSHA * ext/syslog/syslog.c (mSyslog_open): Use of Check_SafeStr() is diff --git a/transcode.c b/transcode.c index c05bb7d823..bfc3382deb 100644 --- a/transcode.c +++ b/transcode.c @@ -608,7 +608,6 @@ trans_open_i(const char *from, const char *to, int depth, void *arg) rb_trans_t **tsp = (rb_trans_t **)arg; rb_trans_t *ts; int i; - rb_transcoding *tc; if (!*tsp) { ts = *tsp = ALLOC(rb_trans_t); @@ -616,6 +615,8 @@ trans_open_i(const char *from, const char *to, int depth, void *arg) ts->elems = ALLOC_N(rb_trans_elem_t, ts->num_trans); ts->num_finished = 0; for (i = 0; i < ts->num_trans; i++) { + ts->elems[i].from = NULL; + ts->elems[i].to = NULL; ts->elems[i].tc = NULL; ts->elems[i].out_buf_start = NULL; ts->elems[i].out_data_start = NULL; @@ -627,32 +628,41 @@ trans_open_i(const char *from, const char *to, int depth, void *arg) else { ts = *tsp; } + ts->elems[depth].from = from; + ts->elems[depth].to = to; - ts->elems[depth].tc = tc = rb_transcoding_open(from, to, 0); - if (!tc) { - rb_raise(rb_eArgError, "transcoding open failed (from %s to %s)", from, to); - } - if (depth < ts->num_trans-1) { - int bufsize = 4096; - unsigned char *p; - p = xmalloc(bufsize); - ts->elems[depth].out_buf_start = p; - ts->elems[depth].out_buf_end = p + bufsize; - ts->elems[depth].out_data_start = p; - ts->elems[depth].out_data_end = p; - } } static rb_trans_t * rb_trans_open(const char *from, const char *to, int flags) { rb_trans_t *ts = NULL; + int i; + rb_transcoding *tc; transcode_search_path(from, to, trans_open_i, (void *)&ts); if (!ts) return NULL; + for (i = 0; i < ts->num_trans; i++) { + tc = rb_transcoding_open(ts->elems[i].from, ts->elems[i].to, 0); + if (!tc) { + rb_raise(rb_eArgError, "converter open failed (from %s to %s)", from, to); + } + ts->elems[i].tc = tc; + } + + for (i = 0; i < ts->num_trans-1; i++) { + int bufsize = 4096; + unsigned char *p; + p = xmalloc(bufsize); + ts->elems[i].out_buf_start = p; + ts->elems[i].out_buf_end = p + bufsize; + ts->elems[i].out_data_start = p; + ts->elems[i].out_data_end = p; + } + return ts; } diff --git a/transcode_data.h b/transcode_data.h index 4a0199df0f..6b3ded4955 100644 --- a/transcode_data.h +++ b/transcode_data.h @@ -108,6 +108,8 @@ typedef enum { } rb_trans_result_t; typedef struct { + const char *from; + const char *to; rb_transcoding *tc; unsigned char *out_buf_start; unsigned char *out_data_start; -- cgit v1.2.3