ruby-changes:7013
From: akr <ko1@a...>
Date: Tue, 12 Aug 2008 18:43:08 +0900 (JST)
Subject: [ruby-changes:7013] Ruby:r18531 (trunk): * transcode_data.h (rb_trans_elem_t): new field: from and to.
akr 2008-08-12 18:42:49 +0900 (Tue, 12 Aug 2008) New Revision: 18531 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=18531 Log: * 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. Modified files: trunk/ChangeLog trunk/transcode.c trunk/transcode_data.h Index: ChangeLog =================================================================== --- ChangeLog (revision 18530) +++ ChangeLog (revision 18531) @@ -1,3 +1,10 @@ +Tue Aug 12 18:32:33 2008 Tanaka Akira <akr@f...> + + * 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 <knu@i...> * ext/syslog/syslog.c (mSyslog_open): Use of Check_SafeStr() is Index: transcode_data.h =================================================================== --- transcode_data.h (revision 18530) +++ transcode_data.h (revision 18531) @@ -108,6 +108,8 @@ } 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; Index: transcode.c =================================================================== --- transcode.c (revision 18530) +++ transcode.c (revision 18531) @@ -608,7 +608,6 @@ 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 @@ 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 @@ 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; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/