ruby-changes:7518
From: akr <ko1@a...>
Date: Tue, 2 Sep 2008 01:23:14 +0900 (JST)
Subject: [ruby-changes:7518] Ruby:r19038 (trunk): * transcode_data.h (BYTE_LOOKUP): change to uintptr_t array.
akr 2008-09-02 01:22:49 +0900 (Tue, 02 Sep 2008) New Revision: 19038 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=19038 Log: * transcode_data.h (BYTE_LOOKUP): change to uintptr_t array. (BYTE_LOOKUP_BASE): follow the type change. (BYTE_LOOKUP_INFO): ditto. (PType): ditto. (rb_transcoding): ditto. * tool/transcode-tblgen.rb: follow the type change. * transcode.c: ditto. * enc/trans/newline.trans: ditto. * enc/trans/iso2022.trans: ditto. * enc/trans/utf_16_32.trans: ditto. Modified files: trunk/ChangeLog trunk/enc/trans/iso2022.trans trunk/enc/trans/newline.trans trunk/enc/trans/utf_16_32.trans trunk/tool/transcode-tblgen.rb trunk/transcode.c trunk/transcode_data.h Index: ChangeLog =================================================================== --- ChangeLog (revision 19037) +++ ChangeLog (revision 19038) @@ -1,3 +1,21 @@ +Tue Sep 2 01:19:15 2008 Tanaka Akira <akr@f...> + + * transcode_data.h (BYTE_LOOKUP): change to uintptr_t array. + (BYTE_LOOKUP_BASE): follow the type change. + (BYTE_LOOKUP_INFO): ditto. + (PType): ditto. + (rb_transcoding): ditto. + + * tool/transcode-tblgen.rb: follow the type change. + + * transcode.c: ditto. + + * enc/trans/newline.trans: ditto. + + * enc/trans/iso2022.trans: ditto. + + * enc/trans/utf_16_32.trans: ditto. + Mon Sep 1 23:32:46 2008 Tanaka Akira <akr@f...> * transcode_data.h (BYTE_LOOKUP_BASE): abstract accessor for Index: enc/trans/iso2022.trans =================================================================== --- enc/trans/iso2022.trans (revision 19037) +++ enc/trans/iso2022.trans (revision 19038) @@ -33,7 +33,7 @@ if (t->stateful[0] == 0) return (VALUE)NOMAP; else if (0x21 <= s[0] && s[0] <= 0x7e) - return (VALUE)&iso2022jp_to_eucjp_jisx0208_rest; + return (VALUE)iso2022jp_to_eucjp_jisx0208_rest; else return (VALUE)INVALID; } @@ -69,7 +69,7 @@ static const rb_transcoder rb_ISO_2022_JP_to_EUC_JP = { - "ISO-2022-JP", "EUC-JP", &iso2022jp_to_eucjp, + "ISO-2022-JP", "EUC-JP", iso2022jp_to_eucjp, 1, /* input_unit_length */ 3, /* max_input */ 3, /* max_output */ @@ -141,7 +141,7 @@ static const rb_transcoder rb_EUC_JP_to_ISO_2022_JP = { - "EUC-JP", "ISO-2022-JP", &eucjp_to_iso2022jp, + "EUC-JP", "ISO-2022-JP", eucjp_to_iso2022jp, 1, /* input_unit_length */ 3, /* max_input */ 5, /* max_output */ Index: enc/trans/newline.trans =================================================================== --- enc/trans/newline.trans (revision 19037) +++ enc/trans/newline.trans (revision 19038) @@ -54,7 +54,7 @@ static const rb_transcoder rb_universal_newline = { - "universal_newline", "", &universal_newline, + "universal_newline", "", universal_newline, 1, /* input_unit_length */ 1, /* max_input */ 1, /* max_output */ @@ -64,7 +64,7 @@ static const rb_transcoder rb_crlf_newline = { - "", "crlf_newline", &crlf_newline, + "", "crlf_newline", crlf_newline, 1, /* input_unit_length */ 1, /* max_input */ 2, /* max_output */ @@ -74,7 +74,7 @@ static const rb_transcoder rb_cr_newline = { - "", "cr_newline", &cr_newline, + "", "cr_newline", cr_newline, 1, /* input_unit_length */ 1, /* max_input */ 1, /* max_output */ Index: enc/trans/utf_16_32.trans =================================================================== --- enc/trans/utf_16_32.trans (revision 19037) +++ enc/trans/utf_16_32.trans (revision 19038) @@ -261,82 +261,82 @@ static const rb_transcoder rb_from_UTF_16BE = { - "UTF-16BE", "UTF-8", &from_UTF_16BE, + "UTF-16BE", "UTF-8", 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 + NULL, NULL, NULL, fun_so_from_utf_16be }; static const rb_transcoder rb_to_UTF_16BE = { - "UTF-8", "UTF-16BE", &to_UTF_16BE, + "UTF-8", "UTF-16BE", 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 + NULL, NULL, NULL, fun_so_to_utf_16be }; static const rb_transcoder rb_from_UTF_16LE = { - "UTF-16LE", "UTF-8", &from_UTF_16LE, + "UTF-16LE", "UTF-8", 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 + NULL, NULL, NULL, fun_so_from_utf_16le }; static const rb_transcoder rb_to_UTF_16LE = { - "UTF-8", "UTF-16LE", &to_UTF_16BE, + "UTF-8", "UTF-16LE", to_UTF_16BE, 1, /* input_unit_length */ 4, /* max_input */ 4, /* max_output */ stateless_converter, /* stateful_type */ - NULL, NULL, NULL, &fun_so_to_utf_16le + NULL, NULL, NULL, fun_so_to_utf_16le }; static const rb_transcoder rb_from_UTF_32BE = { - "UTF-32BE", "UTF-8", &from_UTF_32BE, + "UTF-32BE", "UTF-8", 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 + NULL, NULL, NULL, fun_so_from_utf_32be }; static const rb_transcoder rb_to_UTF_32BE = { - "UTF-8", "UTF-32BE", &to_UTF_16BE, + "UTF-8", "UTF-32BE", to_UTF_16BE, 1, /* input_unit_length */ 4, /* max_input */ 4, /* max_output */ stateless_converter, /* stateful_type */ - NULL, NULL, NULL, &fun_so_to_utf_32be + NULL, NULL, NULL, fun_so_to_utf_32be }; static const rb_transcoder rb_from_UTF_32LE = { - "UTF-32LE", "UTF-8", &from_UTF_32LE, + "UTF-32LE", "UTF-8", 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 + NULL, NULL, NULL, fun_so_from_utf_32le }; static const rb_transcoder rb_to_UTF_32LE = { - "UTF-8", "UTF-32LE", &to_UTF_16BE, + "UTF-8", "UTF-32LE", to_UTF_16BE, 1, /* input_unit_length */ 4, /* max_input */ 4, /* max_output */ stateless_converter, /* stateful_type */ - NULL, NULL, NULL, &fun_so_to_utf_32le + NULL, NULL, NULL, fun_so_to_utf_32le }; void Index: transcode_data.h =================================================================== --- transcode_data.h (revision 19037) +++ transcode_data.h (revision 19038) @@ -16,17 +16,14 @@ typedef unsigned char base_element; -typedef struct byte_lookup { - const base_element *base; - const struct byte_lookup *const *info; -} BYTE_LOOKUP; +typedef uintptr_t BYTE_LOOKUP[2]; -#define BYTE_LOOKUP_BASE(bl) ((bl)->base) -#define BYTE_LOOKUP_INFO(bl) ((bl)->info) +#define BYTE_LOOKUP_BASE(bl) ((const base_element *)(((uintptr_t *)(bl))[0])) +#define BYTE_LOOKUP_INFO(bl) ((const struct byte_lookup *const *)(((uintptr_t *)(bl))[1])) #ifndef PType /* data file needs to treat this as a pointer, to remove warnings */ -#define PType (const BYTE_LOOKUP *) +#define PType (uintptr_t) #endif #define NOMAP (PType 0x01) /* single byte direct map */ @@ -76,7 +73,7 @@ int flags; int resume_position; - const BYTE_LOOKUP *next_table; + uintptr_t next_table; VALUE next_info; unsigned char next_byte; @@ -109,7 +106,7 @@ struct rb_transcoder { const char *from_encoding; const char *to_encoding; - const BYTE_LOOKUP *conv_tree_start; + uintptr_t conv_tree_start; int input_unit_length; int max_input; int max_output; Index: tool/transcode-tblgen.rb =================================================================== --- tool/transcode-tblgen.rb (revision 19037) +++ tool/transcode-tblgen.rb (revision 19038) @@ -273,7 +273,7 @@ "o3(0x#$1,0x#$2,0x#$3)" when /\A([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])\z/i "o4(0x#$1,0x#$2,0x#$3,0x#$4)" - when /\A&/ # pointer to BYTE_LOOKUP structure + when /\A\/\*BYTE_LOOKUP\*\// # pointer to BYTE_LOOKUP structure info.to_s else raise "unexpected action: #{info.inspect}" @@ -347,8 +347,9 @@ else infos_name = "#{name}_infos" infos_code = <<"End" -static const struct byte_lookup* const +static const uintptr_t #{infos_name}[#{infos.length}] = #{format_infos(infos)}; +\#define #{infos_name} ((uintptr_t)#{infos_name}) End InfosMemo[infos] = infos_name end @@ -356,9 +357,10 @@ r = infos_code + <<"End" static const BYTE_LOOKUP #{name} = { - #{offsets_name}, + (uintptr_t)#{offsets_name}, #{infos_name} }; +\#define #{name} ((uintptr_t)#{name}) End words_code << r @@ -380,7 +382,7 @@ else name_hint2 = nil name_hint2 = "#{name_hint}_#{'%02X' % byte}" if name_hint - table[byte] = "&" + rest.generate_node(bytes_code, words_code, name_hint2, rest_valid_encoding) + table[byte] = "/*BYTE_LOOKUP*/" + rest.generate_node(bytes_code, words_code, name_hint2, rest_valid_encoding) end } @@ -572,7 +574,7 @@ transcoder_code = <<"End" static const rb_transcoder #{transcoder_name} = { - #{c_esc from}, #{c_esc to}, &#{real_tree_name}, + #{c_esc from}, #{c_esc to}, #{real_tree_name}, #{input_unit_length}, /* input_unit_length */ #{max_input}, /* max_input */ #{max_output}, /* max_output */ Index: transcode.c =================================================================== --- transcode.c (revision 19037) +++ transcode.c (revision 19038) @@ -513,7 +513,7 @@ SUSPEND(econv_source_buffer_empty, 5); } next_byte = (unsigned char)*in_p++; - next_table = (const BYTE_LOOKUP *)next_info; + next_table = next_info; goto follow_byte; case ZERObt: /* drop input */ continue; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/