* transcode.c (rb_econv_asciicompat_encoding): check decoder.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19253 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
870a8b3903
commit
4106a7c067
@ -1,3 +1,7 @@
|
|||||||
|
Tue Sep 9 00:20:10 2008 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* transcode.c (rb_econv_asciicompat_encoding): check decoder.
|
||||||
|
|
||||||
Tue Sep 9 00:00:47 2008 Tanaka Akira <akr@fsij.org>
|
Tue Sep 9 00:00:47 2008 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* transcode.c (rb_econv_t): last_error.partial_input removed.
|
* transcode.c (rb_econv_t): last_error.partial_input removed.
|
||||||
|
48
transcode.c
48
transcode.c
@ -1639,24 +1639,15 @@ static int
|
|||||||
asciicompat_encoding_i(st_data_t key, st_data_t val, st_data_t arg)
|
asciicompat_encoding_i(st_data_t key, st_data_t val, st_data_t arg)
|
||||||
{
|
{
|
||||||
struct asciicompat_encoding_t *data = (struct asciicompat_encoding_t *)arg;
|
struct asciicompat_encoding_t *data = (struct asciicompat_encoding_t *)arg;
|
||||||
st_table *table2 = (st_table *)val;
|
transcoder_entry_t *entry = (transcoder_entry_t *)val;
|
||||||
st_data_t v;
|
const rb_transcoder *tr;
|
||||||
|
|
||||||
if (st_lookup(table2, (st_data_t)data->ascii_incompat_name, &v)) {
|
if (SUPPLEMENTAL_CONVERSION(entry->sname, entry->dname))
|
||||||
transcoder_entry_t *entry = (transcoder_entry_t *)v;
|
return ST_CONTINUE;
|
||||||
const rb_transcoder *tr;
|
tr = load_transcoder_entry(entry);
|
||||||
if (SUPPLEMENTAL_CONVERSION(entry->sname, entry->dname))
|
if (tr && tr->asciicompat_type == asciicompat_decoder) {
|
||||||
return ST_CONTINUE;
|
data->ascii_compat_name = tr->dst_encoding;
|
||||||
tr = load_transcoder_entry(entry);
|
return ST_STOP;
|
||||||
if (tr && tr->asciicompat_type == asciicompat_encoder) {
|
|
||||||
/*
|
|
||||||
* Assumption:
|
|
||||||
* There is only one transcoder for
|
|
||||||
* converting to ASCII incompatible encoding.
|
|
||||||
*/
|
|
||||||
data->ascii_compat_name = tr->src_encoding;
|
|
||||||
return ST_STOP;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return ST_CONTINUE;
|
return ST_CONTINUE;
|
||||||
}
|
}
|
||||||
@ -1664,13 +1655,28 @@ asciicompat_encoding_i(st_data_t key, st_data_t val, st_data_t arg)
|
|||||||
const char *
|
const char *
|
||||||
rb_econv_asciicompat_encoding(const char *ascii_incompat_name)
|
rb_econv_asciicompat_encoding(const char *ascii_incompat_name)
|
||||||
{
|
{
|
||||||
|
st_data_t v;
|
||||||
|
st_table *table2;
|
||||||
struct asciicompat_encoding_t data;
|
struct asciicompat_encoding_t data;
|
||||||
|
|
||||||
|
if (!st_lookup(transcoder_table, (st_data_t)ascii_incompat_name, &v))
|
||||||
|
return NULL;
|
||||||
|
table2 = (st_table *)v;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Assumption:
|
||||||
|
* There are at most one transcoder for
|
||||||
|
* converting from ASCII incompatible encoding.
|
||||||
|
*
|
||||||
|
* For ISO-2022-JP, there is ISO-2022-JP -> stateless-ISO-2022-JP and no others.
|
||||||
|
*/
|
||||||
|
if (table2->num_entries != 1)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
data.ascii_incompat_name = ascii_incompat_name;
|
data.ascii_incompat_name = ascii_incompat_name;
|
||||||
data.ascii_compat_name = NULL;
|
data.ascii_compat_name = NULL;
|
||||||
st_foreach(transcoder_table, asciicompat_encoding_i, (st_data_t)&data);
|
st_foreach(table2, asciicompat_encoding_i, (st_data_t)&data);
|
||||||
if (data.ascii_compat_name)
|
return data.ascii_compat_name;
|
||||||
return data.ascii_compat_name;
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user