* transcode_data.h (rb_transcoding): add fields: writebuf_off,

writebuf_len and writebuf.
  (TRANSCODING_WRITEBUF): new macro.

* transcode.c (transcode_restartable0): output until output buffer is
  really full.
  (rb_transcoding_open_by_transcoder): initialize writebuf_len,
  writebuf_off and writebuf.
  (rb_transcoding_close): finalize writebuf.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2008-08-13 08:28:39 +00:00
parent 8f1e7a37e5
commit 04f7390ca8
3 changed files with 106 additions and 35 deletions

View file

@ -69,19 +69,31 @@ typedef struct rb_transcoding {
const BYTE_LOOKUP *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 is max_input */
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;
unsigned char stateful[256]; /* 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)
/* static structure, one per supported encoding pair */
struct rb_transcoder {