mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
750cb61e65
commit
139234e1a0
6 changed files with 439 additions and 82 deletions
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue