diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-03 14:34:09 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-03 14:34:09 +0000 |
commit | 1afc1b7bc806c66786b90cc6c6a764f71b4c251f (patch) | |
tree | 5bb516e1817d569f2882329b9aab56d582bffcb2 /transcode.c | |
parent | f6441bf61cd4244aca5f465d262baf31b8872ac2 (diff) | |
download | ruby-1afc1b7bc806c66786b90cc6c6a764f71b4c251f.tar.gz |
* transcode.c (rb_transcoding): moved from transcode_data.h.
(TRANSCODING_READBUF): ditto.
(TRANSCODING_WRITEBUF): ditto.
(TRANSCODING_STATE_EMBED_MAX): ditto.
(TRANSCODING_STATE): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'transcode.c')
-rw-r--r-- | transcode.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/transcode.c b/transcode.c index ca772ce844..aa605f8302 100644 --- a/transcode.c +++ b/transcode.c @@ -31,6 +31,48 @@ static VALUE sym_finished; static VALUE sym_output_followed_by_input; static VALUE sym_incomplete_input; +/* dynamic structure, one per conversion (similar to iconv_t) */ +/* may carry conversion state (e.g. for iso-2022-jp) */ +typedef struct rb_transcoding { + const rb_transcoder *transcoder; + + int flags; + + int resume_position; + unsigned int next_table; + VALUE next_info; + unsigned char next_byte; + + int recognized_len; /* already interpreted */ + int readagain_len; /* not yet interpreted */ + union { + unsigned char ary[8]; /* max_input <= sizeof(ary) */ + unsigned char *ptr; /* length: max_input */ + } readbuf; /* recognized_len + readagain_len used */ + + int writebuf_off; + int writebuf_len; + union { + unsigned char ary[8]; /* max_output <= sizeof(ary) */ + unsigned char *ptr; /* length: max_output */ + } writebuf; + + void *state; /* opaque data for stateful encoding */ +} rb_transcoding; +#define TRANSCODING_READBUF(tc) \ + ((tc)->transcoder->max_input <= sizeof((tc)->readbuf.ary) ? \ + (tc)->readbuf.ary : \ + (tc)->readbuf.ptr) +#define TRANSCODING_WRITEBUF(tc) \ + ((tc)->transcoder->max_output <= sizeof((tc)->writebuf.ary) ? \ + (tc)->writebuf.ary : \ + (tc)->writebuf.ptr) +#define TRANSCODING_STATE_EMBED_MAX sizeof(void *) +#define TRANSCODING_STATE(tc) \ + ((tc)->transcoder->state_size <= sizeof((tc)->state) ? \ + (void *)&(tc)->state : \ + (tc)->state) + typedef struct { struct rb_transcoding *tc; unsigned char *out_buf_start; |