summaryrefslogtreecommitdiff
path: root/transcode_data.h
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-09 06:02:01 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-09 06:02:01 +0000
commit139234e1a091ac3167d3bebdfcd29b3952665334 (patch)
treec1f7be47d34829813983af23e46340bf806d4ff4 /transcode_data.h
parent750cb61e65f35feb70ad855ab3353485cfd75b0c (diff)
downloadruby-139234e1a091ac3167d3bebdfcd29b3952665334.tar.gz
* transcode_data.h (rb_transcoding): add fields for restartable
transcoding. (rb_transcoder): add max_input field. from_unit_length field is renamed to input_unit_length. * tool/transcode-tblgen.rb: generate max_input field. * enc/trans/iso2022.erb.c: follow rb_transcoder change. * enc/trans/utf_16_32.erb.c: ditto. * transcode.c (PARTIAL_INPUT): new constant. (transcode_char_start): new function. (transcode_result_t): new type. (transcode_restartable): new function. (more_output_buffer): new function. (transcode_loop): use transcode_restartable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'transcode_data.h')
-rw-r--r--transcode_data.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/transcode_data.h b/transcode_data.h
index ba2e6e99b3..3801c38ec8 100644
--- a/transcode_data.h
+++ b/transcode_data.h
@@ -64,15 +64,28 @@ typedef struct rb_transcoding {
or NULL if something else is being converted */
unsigned char *(*flush_func)(struct rb_transcoding*, int, int);
+ int resume_position;
+ const BYTE_LOOKUP *next_table;
+ int readlen;
+ union {
+ unsigned char ary[8]; /* max_input <= sizeof(ary) */
+ unsigned char *ptr; /* length is max_input */
+ } readbuf;
+
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)
/* static structure, one per supported encoding pair */
typedef struct rb_transcoder {
const char *from_encoding;
const char *to_encoding;
const BYTE_LOOKUP *conv_tree_start;
- int from_unit_length;
+ int input_unit_length;
+ int max_input;
int max_output;
VALUE (*func_ii)(rb_transcoding*, VALUE); /* info -> info */
VALUE (*func_si)(rb_transcoding*, const unsigned char*, size_t); /* start -> info */