From 04f7390ca828ee6c2482036b0d6834ca6d86ded9 Mon Sep 17 00:00:00 2001 From: akr Date: Wed, 13 Aug 2008 08:28:39 +0000 Subject: * 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 --- transcode_data.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'transcode_data.h') diff --git a/transcode_data.h b/transcode_data.h index f49f796f3d..d8ced64d29 100644 --- a/transcode_data.h +++ b/transcode_data.h @@ -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 { -- cgit v1.2.3