mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* transcode_data.h (base_element): removed.
(BYTE_LOOKUP): removed. (BYTE_LOOKUP_BASE): don't cast. (BYTE_LOOKUP_INFO): ditto. (PType): unsigned int, instead of uintptr_t. (rb_transcoding): change type of next_field, conv_tree_start and word_array. * tool/transcode-tblgen.rb: generate word_array as array of unsigned int. * transcode.c (transcode_restartable0): follow the above type change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19070 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
39f172f9d7
commit
41e1933fd8
4 changed files with 31 additions and 18 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
||||||
|
Tue Sep 2 22:20:26 2008 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* transcode_data.h (base_element): removed.
|
||||||
|
(BYTE_LOOKUP): removed.
|
||||||
|
(BYTE_LOOKUP_BASE): don't cast.
|
||||||
|
(BYTE_LOOKUP_INFO): ditto.
|
||||||
|
(PType): unsigned int, instead of uintptr_t.
|
||||||
|
(rb_transcoding): change type of next_field, conv_tree_start and
|
||||||
|
word_array.
|
||||||
|
|
||||||
|
* tool/transcode-tblgen.rb: generate word_array as array of unsigned
|
||||||
|
int.
|
||||||
|
|
||||||
|
* transcode.c (transcode_restartable0): follow the above type change.
|
||||||
|
|
||||||
Tue Sep 2 21:22:22 2008 Tanaka Akira <akr@fsij.org>
|
Tue Sep 2 21:22:22 2008 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* tool/transcode-tblgen.rb: add prefix for byte_array and word_array.
|
* tool/transcode-tblgen.rb: add prefix for byte_array and word_array.
|
||||||
|
|
|
@ -344,7 +344,7 @@ End
|
||||||
|
|
||||||
if words_code.empty?
|
if words_code.empty?
|
||||||
words_code << <<"End"
|
words_code << <<"End"
|
||||||
static const uintptr_t
|
static const unsigned int
|
||||||
#{OUTPUT_PREFIX}word_array[0] = {
|
#{OUTPUT_PREFIX}word_array[0] = {
|
||||||
};
|
};
|
||||||
End
|
End
|
||||||
|
@ -358,7 +358,7 @@ End
|
||||||
|
|
||||||
size = words_code[/\[\d+\]/][1...-1].to_i
|
size = words_code[/\[\d+\]/][1...-1].to_i
|
||||||
words_code.sub!(/^(\};\n\z)/) {
|
words_code.sub!(/^(\};\n\z)/) {
|
||||||
"\#define #{infos_name} (sizeof(uintptr_t)*#{size})\n" +
|
"\#define #{infos_name} (sizeof(unsigned int)*#{size})\n" +
|
||||||
format_infos(infos) + "\n" +
|
format_infos(infos) + "\n" +
|
||||||
$1
|
$1
|
||||||
}
|
}
|
||||||
|
@ -368,7 +368,7 @@ End
|
||||||
|
|
||||||
size = words_code[/\[\d+\]/][1...-1].to_i
|
size = words_code[/\[\d+\]/][1...-1].to_i
|
||||||
words_code.sub!(/^(\};\n\z)/) {
|
words_code.sub!(/^(\};\n\z)/) {
|
||||||
"\#define #{name} (sizeof(uintptr_t)*#{size})\n" +
|
"\#define #{name} (sizeof(unsigned int)*#{size})\n" +
|
||||||
<<"End" + "\n" + $1
|
<<"End" + "\n" + $1
|
||||||
#{offsets_name},
|
#{offsets_name},
|
||||||
#{infos_name},
|
#{infos_name},
|
||||||
|
@ -609,7 +609,7 @@ end
|
||||||
def transcode_generated_code
|
def transcode_generated_code
|
||||||
TRANSCODE_GENERATED_BYTES_CODE +
|
TRANSCODE_GENERATED_BYTES_CODE +
|
||||||
TRANSCODE_GENERATED_WORDS_CODE +
|
TRANSCODE_GENERATED_WORDS_CODE +
|
||||||
"\#define TRANSCODE_TABLE_INFO #{OUTPUT_PREFIX}byte_array, #{OUTPUT_PREFIX}word_array, sizeof(uintptr_t)\n" +
|
"\#define TRANSCODE_TABLE_INFO #{OUTPUT_PREFIX}byte_array, #{OUTPUT_PREFIX}word_array, sizeof(unsigned int)\n" +
|
||||||
TRANSCODE_GENERATED_TRANSCODER_CODE
|
TRANSCODE_GENERATED_TRANSCODER_CODE
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
10
transcode.c
10
transcode.c
|
@ -480,7 +480,7 @@ transcode_restartable0(const unsigned char **in_pos, unsigned char **out_pos,
|
||||||
while (1) {
|
while (1) {
|
||||||
inchar_start = in_p;
|
inchar_start = in_p;
|
||||||
tc->recognized_len = 0;
|
tc->recognized_len = 0;
|
||||||
next_table = ((uintptr_t)tr->word_array) + tr->conv_tree_start;
|
next_table = tr->conv_tree_start;
|
||||||
|
|
||||||
SUSPEND_OUTPUT_FOLLOWED_BY_INPUT(24);
|
SUSPEND_OUTPUT_FOLLOWED_BY_INPUT(24);
|
||||||
|
|
||||||
|
@ -493,12 +493,14 @@ transcode_restartable0(const unsigned char **in_pos, unsigned char **out_pos,
|
||||||
|
|
||||||
next_byte = (unsigned char)*in_p++;
|
next_byte = (unsigned char)*in_p++;
|
||||||
follow_byte:
|
follow_byte:
|
||||||
#define BL_BASE(next_table) (tr->byte_array + BYTE_LOOKUP_BASE(next_table))
|
#define BL_BASE(next_table) \
|
||||||
|
(tr->byte_array + BYTE_LOOKUP_BASE(tr->word_array + next_table/sizeof(*tr->word_array)))
|
||||||
if (next_byte < BL_BASE(next_table)[0] || BL_BASE(next_table)[1] < next_byte)
|
if (next_byte < BL_BASE(next_table)[0] || BL_BASE(next_table)[1] < next_byte)
|
||||||
next_info = INVALID;
|
next_info = INVALID;
|
||||||
else {
|
else {
|
||||||
unsigned int next_offset = BL_BASE(next_table)[2+next_byte-BL_BASE(next_table)[0]];
|
unsigned int next_offset = BL_BASE(next_table)[2+next_byte-BL_BASE(next_table)[0]];
|
||||||
#define BL_INFO(next_table) ((const struct byte_lookup *const *)(((uintptr_t)tr->word_array) + BYTE_LOOKUP_INFO(next_table)))
|
#define BL_INFO(next_table) \
|
||||||
|
(tr->word_array + BYTE_LOOKUP_INFO(tr->word_array + next_table/sizeof(*tr->word_array))/sizeof(*tr->word_array))
|
||||||
next_info = (VALUE)BL_INFO(next_table)[next_offset];
|
next_info = (VALUE)BL_INFO(next_table)[next_offset];
|
||||||
}
|
}
|
||||||
follow_info:
|
follow_info:
|
||||||
|
@ -515,7 +517,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 = ((uintptr_t)tr->word_array) + next_info;
|
next_table = next_info;
|
||||||
goto follow_byte;
|
goto follow_byte;
|
||||||
case ZERObt: /* drop input */
|
case ZERObt: /* drop input */
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -14,16 +14,12 @@
|
||||||
#ifndef RUBY_TRANSCODE_DATA_H
|
#ifndef RUBY_TRANSCODE_DATA_H
|
||||||
#define RUBY_TRANSCODE_DATA_H 1
|
#define RUBY_TRANSCODE_DATA_H 1
|
||||||
|
|
||||||
typedef unsigned char base_element;
|
#define BYTE_LOOKUP_BASE(bl) ((bl)[0])
|
||||||
|
#define BYTE_LOOKUP_INFO(bl) ((bl)[1])
|
||||||
typedef uintptr_t BYTE_LOOKUP[2];
|
|
||||||
|
|
||||||
#define BYTE_LOOKUP_BASE(bl) (((uintptr_t *)(bl))[0])
|
|
||||||
#define BYTE_LOOKUP_INFO(bl) (((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 (uintptr_t)
|
#define PType (unsigned int)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define NOMAP (PType 0x01) /* single byte direct map */
|
#define NOMAP (PType 0x01) /* single byte direct map */
|
||||||
|
@ -73,7 +69,7 @@ typedef struct rb_transcoding {
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
int resume_position;
|
int resume_position;
|
||||||
uintptr_t next_table;
|
unsigned int next_table;
|
||||||
VALUE next_info;
|
VALUE next_info;
|
||||||
unsigned char next_byte;
|
unsigned char next_byte;
|
||||||
|
|
||||||
|
@ -106,9 +102,9 @@ 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;
|
||||||
uintptr_t conv_tree_start;
|
unsigned int conv_tree_start;
|
||||||
const unsigned char *byte_array;
|
const unsigned char *byte_array;
|
||||||
const uintptr_t *word_array;
|
const unsigned int *word_array;
|
||||||
int word_size;
|
int word_size;
|
||||||
int input_unit_length;
|
int input_unit_length;
|
||||||
int max_input;
|
int max_input;
|
||||||
|
|
Loading…
Add table
Reference in a new issue