* 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
This commit is contained in:
akr 2008-08-12 09:42:49 +00:00
Родитель d04cc54add
Коммит 6d87cec02c
3 изменённых файлов: 33 добавлений и 14 удалений

Просмотреть файл

@ -1,3 +1,10 @@
Tue Aug 12 18:32:33 2008 Tanaka Akira <akr@fsij.org>
* 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@iDaemons.org>
* ext/syslog/syslog.c (mSyslog_open): Use of Check_SafeStr() is

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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;