From a55e167b68d123866b44a14f31411eafdcb56037 Mon Sep 17 00:00:00 2001 From: akr Date: Fri, 15 Aug 2008 23:13:01 +0000 Subject: [PATCH] * transcode_data.h (rb_transcoder_stateful_type_t): defined. (rb_transcoder): add field: stateful_type. * tool/transcode-tblgen.rb: generate stateful_type field as stateless_converter. * enc/trans/iso2022.trans: follow rb_transcoder change. * enc/trans/newline.trans: ditto. * enc/trans/utf_16_32.trans: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 14 ++++++++++++++ enc/trans/iso2022.trans | 2 ++ enc/trans/newline.trans | 3 +++ enc/trans/utf_16_32.trans | 8 ++++++++ tool/transcode-tblgen.rb | 1 + transcode_data.h | 8 ++++++++ 6 files changed, 36 insertions(+) diff --git a/ChangeLog b/ChangeLog index 2c3c18ea14..7c74f8427f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Sat Aug 16 08:11:04 2008 Tanaka Akira + + * transcode_data.h (rb_transcoder_stateful_type_t): defined. + (rb_transcoder): add field: stateful_type. + + * tool/transcode-tblgen.rb: generate stateful_type field as + stateless_converter. + + * enc/trans/iso2022.trans: follow rb_transcoder change. + + * enc/trans/newline.trans: ditto. + + * enc/trans/utf_16_32.trans: ditto. + Fri Aug 15 23:07:48 2008 Tanaka Akira * transcode.c (econv_just_convert): extracted from rb_econv_output. diff --git a/enc/trans/iso2022.trans b/enc/trans/iso2022.trans index 0414493635..76a68d95d8 100644 --- a/enc/trans/iso2022.trans +++ b/enc/trans/iso2022.trans @@ -61,6 +61,7 @@ rb_ISO_2022_JP_to_EUC_JP = { 1, /* input_unit_length */ 3, /* max_input */ 3, /* max_output */ + stateful_decoder, /* stateful_type */ NULL, fun_si_iso2022jp_to_eucjp, NULL, fun_so_iso2022jp_to_eucjp }; @@ -144,6 +145,7 @@ rb_EUC_JP_to_ISO_2022_JP = { 1, /* input_unit_length */ 3, /* max_input */ 5, /* max_output */ + stateful_encoder, /* stateful_type */ NULL, NULL, NULL, fun_so_eucjp_to_iso2022jp, finish_eucjp_to_iso2022jp, iso2022jp_reset_sequence_size, finish_eucjp_to_iso2022jp diff --git a/enc/trans/newline.trans b/enc/trans/newline.trans index 3b70712612..409da1dc33 100644 --- a/enc/trans/newline.trans +++ b/enc/trans/newline.trans @@ -44,6 +44,7 @@ rb_universal_newline = { 1, /* input_unit_length */ 1, /* max_input */ 1, /* max_output */ + stateful_decoder, /* stateful_type */ NULL, NULL, NULL, fun_so_universal_newline }; @@ -61,6 +62,7 @@ rb_crlf_newline = { 1, /* input_unit_length */ 1, /* max_input */ 2, /* max_output */ + stateless_converter, /* stateful_type */ NULL, NULL, NULL, NULL }; @@ -78,6 +80,7 @@ rb_cr_newline = { 1, /* input_unit_length */ 1, /* max_input */ 1, /* max_output */ + stateless_converter, /* stateful_type */ NULL, NULL, NULL, NULL }; diff --git a/enc/trans/utf_16_32.trans b/enc/trans/utf_16_32.trans index aea2ab50a8..3b11654305 100644 --- a/enc/trans/utf_16_32.trans +++ b/enc/trans/utf_16_32.trans @@ -235,6 +235,7 @@ rb_from_UTF_16BE = { 2, /* input_unit_length */ 4, /* max_input */ 4, /* max_output */ + stateless_converter, /* stateful_type */ NULL, NULL, NULL, &fun_so_from_utf_16be }; @@ -259,6 +260,7 @@ rb_to_UTF_16BE = { 1, /* input_unit_length */ 4, /* max_input */ 4, /* max_output */ + stateless_converter, /* stateful_type */ NULL, NULL, NULL, &fun_so_to_utf_16be }; @@ -275,6 +277,7 @@ rb_from_UTF_16LE = { 2, /* input_unit_length */ 4, /* max_input */ 4, /* max_output */ + stateless_converter, /* stateful_type */ NULL, NULL, NULL, &fun_so_from_utf_16le }; @@ -284,6 +287,7 @@ rb_to_UTF_16LE = { 1, /* input_unit_length */ 4, /* max_input */ 4, /* max_output */ + stateless_converter, /* stateful_type */ NULL, NULL, NULL, &fun_so_to_utf_16le }; @@ -300,6 +304,7 @@ rb_from_UTF_32BE = { 4, /* input_unit_length */ 4, /* max_input */ 4, /* max_output */ + stateless_converter, /* stateful_type */ NULL, NULL, NULL, &fun_so_from_utf_32be }; @@ -309,6 +314,7 @@ rb_to_UTF_32BE = { 1, /* input_unit_length */ 4, /* max_input */ 4, /* max_output */ + stateless_converter, /* stateful_type */ NULL, NULL, NULL, &fun_so_to_utf_32be }; @@ -325,6 +331,7 @@ rb_from_UTF_32LE = { 4, /* input_unit_length */ 4, /* max_input */ 4, /* max_output */ + stateless_converter, /* stateful_type */ NULL, NULL, NULL, &fun_so_from_utf_32le }; @@ -334,6 +341,7 @@ rb_to_UTF_32LE = { 1, /* input_unit_length */ 4, /* max_input */ 4, /* max_output */ + stateless_converter, /* stateful_type */ NULL, NULL, NULL, &fun_so_to_utf_32le }; diff --git a/tool/transcode-tblgen.rb b/tool/transcode-tblgen.rb index 87bb29c885..f79fc551ec 100644 --- a/tool/transcode-tblgen.rb +++ b/tool/transcode-tblgen.rb @@ -449,6 +449,7 @@ static const rb_transcoder #{input_unit_length}, /* input_unit_length */ #{max_input}, /* max_input */ #{max_output}, /* max_output */ + stateless_converter, /* stateful_type */ NULL, NULL, NULL, NULL, NULL, NULL, NULL }; diff --git a/transcode_data.h b/transcode_data.h index 69f3048124..1b8eeae379 100644 --- a/transcode_data.h +++ b/transcode_data.h @@ -56,6 +56,13 @@ typedef struct byte_lookup { #define TWOTRAIL /* legal but undefined if two more trailing UTF-8 */ #define THREETRAIL /* legal but undefined if three more trailing UTF-8 */ +typedef enum { + stateless_converter, /* stateless -> stateless */ + stateful_decoder, /* stateful -> stateless */ + stateful_encoder /* stateless -> stateful */ + /* stateful -> stateful is intentionally ommitted. */ +} rb_transcoder_stateful_type_t; + typedef struct rb_transcoder rb_transcoder; /* dynamic structure, one per conversion (similar to iconv_t) */ @@ -103,6 +110,7 @@ struct rb_transcoder { int input_unit_length; int max_input; int max_output; + rb_transcoder_stateful_type_t stateful_type; VALUE (*func_ii)(rb_transcoding*, VALUE); /* info -> info */ VALUE (*func_si)(rb_transcoding*, const unsigned char*, size_t); /* start -> info */ int (*func_io)(rb_transcoding*, VALUE, const unsigned char*); /* info -> output */