зеркало из https://github.com/github/ruby.git
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19038 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
2ae7b0328e
Коммит
752e053a1d
18
ChangeLog
18
ChangeLog
|
@ -1,3 +1,21 @@
|
||||||
|
Tue Sep 2 01:19:15 2008 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* 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@fsij.org>
|
Mon Sep 1 23:32:46 2008 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* transcode_data.h (BYTE_LOOKUP_BASE): abstract accessor for
|
* transcode_data.h (BYTE_LOOKUP_BASE): abstract accessor for
|
||||||
|
|
|
@ -33,7 +33,7 @@ fun_si_iso2022jp_to_eucjp(rb_transcoding* t, const unsigned char* s, size_t l)
|
||||||
if (t->stateful[0] == 0)
|
if (t->stateful[0] == 0)
|
||||||
return (VALUE)NOMAP;
|
return (VALUE)NOMAP;
|
||||||
else if (0x21 <= s[0] && s[0] <= 0x7e)
|
else if (0x21 <= s[0] && s[0] <= 0x7e)
|
||||||
return (VALUE)&iso2022jp_to_eucjp_jisx0208_rest;
|
return (VALUE)iso2022jp_to_eucjp_jisx0208_rest;
|
||||||
else
|
else
|
||||||
return (VALUE)INVALID;
|
return (VALUE)INVALID;
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ fun_so_iso2022jp_to_eucjp(rb_transcoding* t, const unsigned char* s, size_t l, u
|
||||||
|
|
||||||
static const rb_transcoder
|
static const rb_transcoder
|
||||||
rb_ISO_2022_JP_to_EUC_JP = {
|
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 */
|
1, /* input_unit_length */
|
||||||
3, /* max_input */
|
3, /* max_input */
|
||||||
3, /* max_output */
|
3, /* max_output */
|
||||||
|
@ -141,7 +141,7 @@ finish_eucjp_to_iso2022jp(rb_transcoding *t, unsigned char *o)
|
||||||
|
|
||||||
static const rb_transcoder
|
static const rb_transcoder
|
||||||
rb_EUC_JP_to_ISO_2022_JP = {
|
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 */
|
1, /* input_unit_length */
|
||||||
3, /* max_input */
|
3, /* max_input */
|
||||||
5, /* max_output */
|
5, /* max_output */
|
||||||
|
|
|
@ -54,7 +54,7 @@ fun_so_universal_newline(rb_transcoding* t, const unsigned char* s, size_t l, un
|
||||||
|
|
||||||
static const rb_transcoder
|
static const rb_transcoder
|
||||||
rb_universal_newline = {
|
rb_universal_newline = {
|
||||||
"universal_newline", "", &universal_newline,
|
"universal_newline", "", universal_newline,
|
||||||
1, /* input_unit_length */
|
1, /* input_unit_length */
|
||||||
1, /* max_input */
|
1, /* max_input */
|
||||||
1, /* max_output */
|
1, /* max_output */
|
||||||
|
@ -64,7 +64,7 @@ rb_universal_newline = {
|
||||||
|
|
||||||
static const rb_transcoder
|
static const rb_transcoder
|
||||||
rb_crlf_newline = {
|
rb_crlf_newline = {
|
||||||
"", "crlf_newline", &crlf_newline,
|
"", "crlf_newline", crlf_newline,
|
||||||
1, /* input_unit_length */
|
1, /* input_unit_length */
|
||||||
1, /* max_input */
|
1, /* max_input */
|
||||||
2, /* max_output */
|
2, /* max_output */
|
||||||
|
@ -74,7 +74,7 @@ rb_crlf_newline = {
|
||||||
|
|
||||||
static const rb_transcoder
|
static const rb_transcoder
|
||||||
rb_cr_newline = {
|
rb_cr_newline = {
|
||||||
"", "cr_newline", &cr_newline,
|
"", "cr_newline", cr_newline,
|
||||||
1, /* input_unit_length */
|
1, /* input_unit_length */
|
||||||
1, /* max_input */
|
1, /* max_input */
|
||||||
1, /* max_output */
|
1, /* max_output */
|
||||||
|
|
|
@ -261,82 +261,82 @@ fun_so_to_utf_32le(rb_transcoding* t, const unsigned char* s, size_t l, unsigned
|
||||||
|
|
||||||
static const rb_transcoder
|
static const rb_transcoder
|
||||||
rb_from_UTF_16BE = {
|
rb_from_UTF_16BE = {
|
||||||
"UTF-16BE", "UTF-8", &from_UTF_16BE,
|
"UTF-16BE", "UTF-8", from_UTF_16BE,
|
||||||
2, /* input_unit_length */
|
2, /* input_unit_length */
|
||||||
4, /* max_input */
|
4, /* max_input */
|
||||||
4, /* max_output */
|
4, /* max_output */
|
||||||
stateless_converter, /* stateful_type */
|
stateless_converter, /* stateful_type */
|
||||||
NULL, NULL, NULL, &fun_so_from_utf_16be
|
NULL, NULL, NULL, fun_so_from_utf_16be
|
||||||
};
|
};
|
||||||
|
|
||||||
static const rb_transcoder
|
static const rb_transcoder
|
||||||
rb_to_UTF_16BE = {
|
rb_to_UTF_16BE = {
|
||||||
"UTF-8", "UTF-16BE", &to_UTF_16BE,
|
"UTF-8", "UTF-16BE", to_UTF_16BE,
|
||||||
1, /* input_unit_length */
|
1, /* input_unit_length */
|
||||||
4, /* max_input */
|
4, /* max_input */
|
||||||
4, /* max_output */
|
4, /* max_output */
|
||||||
stateless_converter, /* stateful_type */
|
stateless_converter, /* stateful_type */
|
||||||
NULL, NULL, NULL, &fun_so_to_utf_16be
|
NULL, NULL, NULL, fun_so_to_utf_16be
|
||||||
};
|
};
|
||||||
|
|
||||||
static const rb_transcoder
|
static const rb_transcoder
|
||||||
rb_from_UTF_16LE = {
|
rb_from_UTF_16LE = {
|
||||||
"UTF-16LE", "UTF-8", &from_UTF_16LE,
|
"UTF-16LE", "UTF-8", from_UTF_16LE,
|
||||||
2, /* input_unit_length */
|
2, /* input_unit_length */
|
||||||
4, /* max_input */
|
4, /* max_input */
|
||||||
4, /* max_output */
|
4, /* max_output */
|
||||||
stateless_converter, /* stateful_type */
|
stateless_converter, /* stateful_type */
|
||||||
NULL, NULL, NULL, &fun_so_from_utf_16le
|
NULL, NULL, NULL, fun_so_from_utf_16le
|
||||||
};
|
};
|
||||||
|
|
||||||
static const rb_transcoder
|
static const rb_transcoder
|
||||||
rb_to_UTF_16LE = {
|
rb_to_UTF_16LE = {
|
||||||
"UTF-8", "UTF-16LE", &to_UTF_16BE,
|
"UTF-8", "UTF-16LE", to_UTF_16BE,
|
||||||
1, /* input_unit_length */
|
1, /* input_unit_length */
|
||||||
4, /* max_input */
|
4, /* max_input */
|
||||||
4, /* max_output */
|
4, /* max_output */
|
||||||
stateless_converter, /* stateful_type */
|
stateless_converter, /* stateful_type */
|
||||||
NULL, NULL, NULL, &fun_so_to_utf_16le
|
NULL, NULL, NULL, fun_so_to_utf_16le
|
||||||
};
|
};
|
||||||
|
|
||||||
static const rb_transcoder
|
static const rb_transcoder
|
||||||
rb_from_UTF_32BE = {
|
rb_from_UTF_32BE = {
|
||||||
"UTF-32BE", "UTF-8", &from_UTF_32BE,
|
"UTF-32BE", "UTF-8", from_UTF_32BE,
|
||||||
4, /* input_unit_length */
|
4, /* input_unit_length */
|
||||||
4, /* max_input */
|
4, /* max_input */
|
||||||
4, /* max_output */
|
4, /* max_output */
|
||||||
stateless_converter, /* stateful_type */
|
stateless_converter, /* stateful_type */
|
||||||
NULL, NULL, NULL, &fun_so_from_utf_32be
|
NULL, NULL, NULL, fun_so_from_utf_32be
|
||||||
};
|
};
|
||||||
|
|
||||||
static const rb_transcoder
|
static const rb_transcoder
|
||||||
rb_to_UTF_32BE = {
|
rb_to_UTF_32BE = {
|
||||||
"UTF-8", "UTF-32BE", &to_UTF_16BE,
|
"UTF-8", "UTF-32BE", to_UTF_16BE,
|
||||||
1, /* input_unit_length */
|
1, /* input_unit_length */
|
||||||
4, /* max_input */
|
4, /* max_input */
|
||||||
4, /* max_output */
|
4, /* max_output */
|
||||||
stateless_converter, /* stateful_type */
|
stateless_converter, /* stateful_type */
|
||||||
NULL, NULL, NULL, &fun_so_to_utf_32be
|
NULL, NULL, NULL, fun_so_to_utf_32be
|
||||||
};
|
};
|
||||||
|
|
||||||
static const rb_transcoder
|
static const rb_transcoder
|
||||||
rb_from_UTF_32LE = {
|
rb_from_UTF_32LE = {
|
||||||
"UTF-32LE", "UTF-8", &from_UTF_32LE,
|
"UTF-32LE", "UTF-8", from_UTF_32LE,
|
||||||
4, /* input_unit_length */
|
4, /* input_unit_length */
|
||||||
4, /* max_input */
|
4, /* max_input */
|
||||||
4, /* max_output */
|
4, /* max_output */
|
||||||
stateless_converter, /* stateful_type */
|
stateless_converter, /* stateful_type */
|
||||||
NULL, NULL, NULL, &fun_so_from_utf_32le
|
NULL, NULL, NULL, fun_so_from_utf_32le
|
||||||
};
|
};
|
||||||
|
|
||||||
static const rb_transcoder
|
static const rb_transcoder
|
||||||
rb_to_UTF_32LE = {
|
rb_to_UTF_32LE = {
|
||||||
"UTF-8", "UTF-32LE", &to_UTF_16BE,
|
"UTF-8", "UTF-32LE", to_UTF_16BE,
|
||||||
1, /* input_unit_length */
|
1, /* input_unit_length */
|
||||||
4, /* max_input */
|
4, /* max_input */
|
||||||
4, /* max_output */
|
4, /* max_output */
|
||||||
stateless_converter, /* stateful_type */
|
stateless_converter, /* stateful_type */
|
||||||
NULL, NULL, NULL, &fun_so_to_utf_32le
|
NULL, NULL, NULL, fun_so_to_utf_32le
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -273,7 +273,7 @@ class ActionMap
|
||||||
"o3(0x#$1,0x#$2,0x#$3)"
|
"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
|
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)"
|
"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
|
info.to_s
|
||||||
else
|
else
|
||||||
raise "unexpected action: #{info.inspect}"
|
raise "unexpected action: #{info.inspect}"
|
||||||
|
@ -347,8 +347,9 @@ End
|
||||||
else
|
else
|
||||||
infos_name = "#{name}_infos"
|
infos_name = "#{name}_infos"
|
||||||
infos_code = <<"End"
|
infos_code = <<"End"
|
||||||
static const struct byte_lookup* const
|
static const uintptr_t
|
||||||
#{infos_name}[#{infos.length}] = #{format_infos(infos)};
|
#{infos_name}[#{infos.length}] = #{format_infos(infos)};
|
||||||
|
\#define #{infos_name} ((uintptr_t)#{infos_name})
|
||||||
End
|
End
|
||||||
InfosMemo[infos] = infos_name
|
InfosMemo[infos] = infos_name
|
||||||
end
|
end
|
||||||
|
@ -356,9 +357,10 @@ End
|
||||||
r = infos_code + <<"End"
|
r = infos_code + <<"End"
|
||||||
static const BYTE_LOOKUP
|
static const BYTE_LOOKUP
|
||||||
#{name} = {
|
#{name} = {
|
||||||
#{offsets_name},
|
(uintptr_t)#{offsets_name},
|
||||||
#{infos_name}
|
#{infos_name}
|
||||||
};
|
};
|
||||||
|
\#define #{name} ((uintptr_t)#{name})
|
||||||
|
|
||||||
End
|
End
|
||||||
words_code << r
|
words_code << r
|
||||||
|
@ -380,7 +382,7 @@ End
|
||||||
else
|
else
|
||||||
name_hint2 = nil
|
name_hint2 = nil
|
||||||
name_hint2 = "#{name_hint}_#{'%02X' % byte}" if name_hint
|
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
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -572,7 +574,7 @@ def transcode_tblgen(from, to, map)
|
||||||
transcoder_code = <<"End"
|
transcoder_code = <<"End"
|
||||||
static const rb_transcoder
|
static const rb_transcoder
|
||||||
#{transcoder_name} = {
|
#{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 */
|
#{input_unit_length}, /* input_unit_length */
|
||||||
#{max_input}, /* max_input */
|
#{max_input}, /* max_input */
|
||||||
#{max_output}, /* max_output */
|
#{max_output}, /* max_output */
|
||||||
|
|
|
@ -513,7 +513,7 @@ transcode_restartable0(const unsigned char **in_pos, unsigned char **out_pos,
|
||||||
SUSPEND(econv_source_buffer_empty, 5);
|
SUSPEND(econv_source_buffer_empty, 5);
|
||||||
}
|
}
|
||||||
next_byte = (unsigned char)*in_p++;
|
next_byte = (unsigned char)*in_p++;
|
||||||
next_table = (const BYTE_LOOKUP *)next_info;
|
next_table = next_info;
|
||||||
goto follow_byte;
|
goto follow_byte;
|
||||||
case ZERObt: /* drop input */
|
case ZERObt: /* drop input */
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -16,17 +16,14 @@
|
||||||
|
|
||||||
typedef unsigned char base_element;
|
typedef unsigned char base_element;
|
||||||
|
|
||||||
typedef struct byte_lookup {
|
typedef uintptr_t BYTE_LOOKUP[2];
|
||||||
const base_element *base;
|
|
||||||
const struct byte_lookup *const *info;
|
|
||||||
} BYTE_LOOKUP;
|
|
||||||
|
|
||||||
#define BYTE_LOOKUP_BASE(bl) ((bl)->base)
|
#define BYTE_LOOKUP_BASE(bl) ((const base_element *)(((uintptr_t *)(bl))[0]))
|
||||||
#define BYTE_LOOKUP_INFO(bl) ((bl)->info)
|
#define BYTE_LOOKUP_INFO(bl) ((const struct byte_lookup *const *)(((uintptr_t *)(bl))[1]))
|
||||||
|
|
||||||
#ifndef PType
|
#ifndef PType
|
||||||
/* data file needs to treat this as a pointer, to remove warnings */
|
/* data file needs to treat this as a pointer, to remove warnings */
|
||||||
#define PType (const BYTE_LOOKUP *)
|
#define PType (uintptr_t)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define NOMAP (PType 0x01) /* single byte direct map */
|
#define NOMAP (PType 0x01) /* single byte direct map */
|
||||||
|
@ -76,7 +73,7 @@ typedef struct rb_transcoding {
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
int resume_position;
|
int resume_position;
|
||||||
const BYTE_LOOKUP *next_table;
|
uintptr_t next_table;
|
||||||
VALUE next_info;
|
VALUE next_info;
|
||||||
unsigned char next_byte;
|
unsigned char next_byte;
|
||||||
|
|
||||||
|
@ -109,7 +106,7 @@ typedef struct rb_transcoding {
|
||||||
struct rb_transcoder {
|
struct rb_transcoder {
|
||||||
const char *from_encoding;
|
const char *from_encoding;
|
||||||
const char *to_encoding;
|
const char *to_encoding;
|
||||||
const BYTE_LOOKUP *conv_tree_start;
|
uintptr_t conv_tree_start;
|
||||||
int input_unit_length;
|
int input_unit_length;
|
||||||
int max_input;
|
int max_input;
|
||||||
int max_output;
|
int max_output;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче