mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* transcode.c (rb_transcoding, str_transcoding_resize): fixed
types. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25289 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
89154445fb
commit
5d4b63d2fd
2 changed files with 37 additions and 34 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,8 @@
|
||||||
|
Sat Oct 10 23:51:22 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* transcode.c (rb_transcoding, str_transcoding_resize): fixed
|
||||||
|
types.
|
||||||
|
|
||||||
Sat Oct 10 20:35:27 2009 Yuki Sonoda (Yugui) <yugui@yugui.jp>
|
Sat Oct 10 20:35:27 2009 Yuki Sonoda (Yugui) <yugui@yugui.jp>
|
||||||
|
|
||||||
* math.c (math_atanh): reverted r25279.
|
* math.c (math_atanh): reverted r25279.
|
||||||
|
@ -50,11 +55,6 @@ Sat Oct 10 14:09:40 2009 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
|
||||||
* eval.c (get_errinfo, rb_rubylevel_thread_errinfo): Getter for
|
* eval.c (get_errinfo, rb_rubylevel_thread_errinfo): Getter for
|
||||||
current exception for a given thread
|
current exception for a given thread
|
||||||
|
|
||||||
Sat Oct 10 12:21:31 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
|
||||||
|
|
||||||
* transcode.c (rb_transcoding, str_transcoding_resize): fixed
|
|
||||||
types.
|
|
||||||
|
|
||||||
Fri Oct 9 23:10:04 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Fri Oct 9 23:10:04 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* vm_method.c (rb_method_boundp): should exclude NOEX_RESPONDS.
|
* vm_method.c (rb_method_boundp): should exclude NOEX_RESPONDS.
|
||||||
|
|
61
transcode.c
61
transcode.c
|
@ -55,15 +55,15 @@ typedef struct rb_transcoding {
|
||||||
unsigned char next_byte;
|
unsigned char next_byte;
|
||||||
unsigned int output_index;
|
unsigned int output_index;
|
||||||
|
|
||||||
int recognized_len; /* already interpreted */
|
ssize_t recognized_len; /* already interpreted */
|
||||||
int readagain_len; /* not yet interpreted */
|
ssize_t readagain_len; /* not yet interpreted */
|
||||||
union {
|
union {
|
||||||
unsigned char ary[8]; /* max_input <= sizeof(ary) */
|
unsigned char ary[8]; /* max_input <= sizeof(ary) */
|
||||||
unsigned char *ptr; /* length: max_input */
|
unsigned char *ptr; /* length: max_input */
|
||||||
} readbuf; /* recognized_len + readagain_len used */
|
} readbuf; /* recognized_len + readagain_len used */
|
||||||
|
|
||||||
int writebuf_off;
|
ssize_t writebuf_off;
|
||||||
int writebuf_len;
|
ssize_t writebuf_len;
|
||||||
union {
|
union {
|
||||||
unsigned char ary[8]; /* max_output <= sizeof(ary) */
|
unsigned char ary[8]; /* max_output <= sizeof(ary) */
|
||||||
unsigned char *ptr; /* length: max_output */
|
unsigned char *ptr; /* length: max_output */
|
||||||
|
@ -76,20 +76,20 @@ typedef struct rb_transcoding {
|
||||||
} state;
|
} state;
|
||||||
} rb_transcoding;
|
} rb_transcoding;
|
||||||
#define TRANSCODING_READBUF(tc) \
|
#define TRANSCODING_READBUF(tc) \
|
||||||
((tc)->transcoder->max_input <= sizeof((tc)->readbuf.ary) ? \
|
((tc)->transcoder->max_input <= (int)sizeof((tc)->readbuf.ary) ? \
|
||||||
(tc)->readbuf.ary : \
|
(tc)->readbuf.ary : \
|
||||||
(tc)->readbuf.ptr)
|
(tc)->readbuf.ptr)
|
||||||
#define TRANSCODING_WRITEBUF(tc) \
|
#define TRANSCODING_WRITEBUF(tc) \
|
||||||
((tc)->transcoder->max_output <= sizeof((tc)->writebuf.ary) ? \
|
((tc)->transcoder->max_output <= (int)sizeof((tc)->writebuf.ary) ? \
|
||||||
(tc)->writebuf.ary : \
|
(tc)->writebuf.ary : \
|
||||||
(tc)->writebuf.ptr)
|
(tc)->writebuf.ptr)
|
||||||
#define TRANSCODING_WRITEBUF_SIZE(tc) \
|
#define TRANSCODING_WRITEBUF_SIZE(tc) \
|
||||||
((tc)->transcoder->max_output <= sizeof((tc)->writebuf.ary) ? \
|
((tc)->transcoder->max_output <= (int)sizeof((tc)->writebuf.ary) ? \
|
||||||
sizeof((tc)->writebuf.ary) : \
|
sizeof((tc)->writebuf.ary) : \
|
||||||
(size_t)(tc)->transcoder->max_output)
|
(size_t)(tc)->transcoder->max_output)
|
||||||
#define TRANSCODING_STATE_EMBED_MAX sizeof(union rb_transcoding_state_t)
|
#define TRANSCODING_STATE_EMBED_MAX ((int)sizeof(union rb_transcoding_state_t))
|
||||||
#define TRANSCODING_STATE(tc) \
|
#define TRANSCODING_STATE(tc) \
|
||||||
((tc)->transcoder->state_size <= sizeof((tc)->state) ? \
|
((tc)->transcoder->state_size <= (int)sizeof((tc)->state) ? \
|
||||||
(tc)->state.ary : \
|
(tc)->state.ary : \
|
||||||
(tc)->state.ptr)
|
(tc)->state.ptr)
|
||||||
|
|
||||||
|
@ -362,7 +362,7 @@ load_transcoder_entry(transcoder_entry_t *entry)
|
||||||
|
|
||||||
if (entry->lib) {
|
if (entry->lib) {
|
||||||
const char *lib = entry->lib;
|
const char *lib = entry->lib;
|
||||||
int len = strlen(lib);
|
size_t len = strlen(lib);
|
||||||
char path[sizeof(transcoder_lib_prefix) + MAX_TRANSCODER_LIBNAME_LEN];
|
char path[sizeof(transcoder_lib_prefix) + MAX_TRANSCODER_LIBNAME_LEN];
|
||||||
|
|
||||||
entry->lib = NULL;
|
entry->lib = NULL;
|
||||||
|
@ -428,7 +428,7 @@ transcode_restartable0(const unsigned char **in_pos, unsigned char **out_pos,
|
||||||
{
|
{
|
||||||
const rb_transcoder *tr = tc->transcoder;
|
const rb_transcoder *tr = tc->transcoder;
|
||||||
int unitlen = tr->input_unit_length;
|
int unitlen = tr->input_unit_length;
|
||||||
int readagain_len = 0;
|
ssize_t readagain_len = 0;
|
||||||
|
|
||||||
const unsigned char *inchar_start;
|
const unsigned char *inchar_start;
|
||||||
const unsigned char *in_p;
|
const unsigned char *in_p;
|
||||||
|
@ -563,7 +563,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 = next_info;
|
next_table = (unsigned int)next_info;
|
||||||
goto follow_byte;
|
goto follow_byte;
|
||||||
case ZERObt: /* drop input */
|
case ZERObt: /* drop input */
|
||||||
continue;
|
continue;
|
||||||
|
@ -665,8 +665,8 @@ transcode_restartable0(const unsigned char **in_pos, unsigned char **out_pos,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int invalid_len; /* including the last byte which causes invalid */
|
ssize_t invalid_len; /* including the last byte which causes invalid */
|
||||||
int discard_len;
|
ssize_t discard_len;
|
||||||
invalid_len = tc->recognized_len + (in_p - inchar_start);
|
invalid_len = tc->recognized_len + (in_p - inchar_start);
|
||||||
discard_len = ((invalid_len - 1) / unitlen) * unitlen;
|
discard_len = ((invalid_len - 1) / unitlen) * unitlen;
|
||||||
readagain_len = invalid_len - discard_len;
|
readagain_len = invalid_len - discard_len;
|
||||||
|
@ -761,10 +761,10 @@ rb_transcoding_open_by_transcoder(const rb_transcoder *tr, int flags)
|
||||||
tc->readagain_len = 0;
|
tc->readagain_len = 0;
|
||||||
tc->writebuf_len = 0;
|
tc->writebuf_len = 0;
|
||||||
tc->writebuf_off = 0;
|
tc->writebuf_off = 0;
|
||||||
if (sizeof(tc->readbuf.ary) < tr->max_input) {
|
if ((int)sizeof(tc->readbuf.ary) < tr->max_input) {
|
||||||
tc->readbuf.ptr = xmalloc(tr->max_input);
|
tc->readbuf.ptr = xmalloc(tr->max_input);
|
||||||
}
|
}
|
||||||
if (sizeof(tc->writebuf.ary) < tr->max_output) {
|
if ((int)sizeof(tc->writebuf.ary) < tr->max_output) {
|
||||||
tc->writebuf.ptr = xmalloc(tr->max_output);
|
tc->writebuf.ptr = xmalloc(tr->max_output);
|
||||||
}
|
}
|
||||||
return tc;
|
return tc;
|
||||||
|
@ -791,9 +791,9 @@ rb_transcoding_close(rb_transcoding *tc)
|
||||||
}
|
}
|
||||||
if (TRANSCODING_STATE_EMBED_MAX < tr->state_size)
|
if (TRANSCODING_STATE_EMBED_MAX < tr->state_size)
|
||||||
xfree(tc->state.ptr);
|
xfree(tc->state.ptr);
|
||||||
if (sizeof(tc->readbuf.ary) < tr->max_input)
|
if ((int)sizeof(tc->readbuf.ary) < tr->max_input)
|
||||||
xfree(tc->readbuf.ptr);
|
xfree(tc->readbuf.ptr);
|
||||||
if (sizeof(tc->writebuf.ary) < tr->max_output)
|
if ((int)sizeof(tc->writebuf.ary) < tr->max_output)
|
||||||
xfree(tc->writebuf.ptr);
|
xfree(tc->writebuf.ptr);
|
||||||
xfree(tc);
|
xfree(tc);
|
||||||
}
|
}
|
||||||
|
@ -807,10 +807,10 @@ rb_transcoding_memsize(rb_transcoding *tc)
|
||||||
if (TRANSCODING_STATE_EMBED_MAX < tr->state_size) {
|
if (TRANSCODING_STATE_EMBED_MAX < tr->state_size) {
|
||||||
size += tr->state_size;
|
size += tr->state_size;
|
||||||
}
|
}
|
||||||
if (sizeof(tc->readbuf.ary) < tr->max_input) {
|
if ((int)sizeof(tc->readbuf.ary) < tr->max_input) {
|
||||||
size += tr->max_input;
|
size += tr->max_input;
|
||||||
}
|
}
|
||||||
if (sizeof(tc->writebuf.ary) < tr->max_output) {
|
if ((int)sizeof(tc->writebuf.ary) < tr->max_output) {
|
||||||
size += tr->max_output;
|
size += tr->max_output;
|
||||||
}
|
}
|
||||||
return size;
|
return size;
|
||||||
|
@ -1091,8 +1091,8 @@ trans_sweep(rb_econv_t *ec,
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (te->out_buf_start != te->out_data_start) {
|
if (te->out_buf_start != te->out_data_start) {
|
||||||
int len = te->out_data_end - te->out_data_start;
|
ssize_t len = te->out_data_end - te->out_data_start;
|
||||||
int off = te->out_data_start - te->out_buf_start;
|
ssize_t off = te->out_data_start - te->out_buf_start;
|
||||||
MEMMOVE(te->out_buf_start, te->out_data_start, unsigned char, len);
|
MEMMOVE(te->out_buf_start, te->out_data_start, unsigned char, len);
|
||||||
te->out_data_start = te->out_buf_start;
|
te->out_data_start = te->out_buf_start;
|
||||||
te->out_data_end -= off;
|
te->out_data_end -= off;
|
||||||
|
@ -1708,7 +1708,10 @@ rb_econv_putbackable(rb_econv_t *ec)
|
||||||
{
|
{
|
||||||
if (ec->num_trans == 0)
|
if (ec->num_trans == 0)
|
||||||
return 0;
|
return 0;
|
||||||
return ec->elems[0].tc->readagain_len;
|
#if SIZEOF_SIZE_T > SIZEOF_INT
|
||||||
|
if (ec->elems[0].tc->readagain_len > INT_MAX) return INT_MAX;
|
||||||
|
#endif
|
||||||
|
return (int)ec->elems[0].tc->readagain_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -2113,7 +2116,7 @@ make_econv_exception(rb_econv_t *ec)
|
||||||
static void
|
static void
|
||||||
more_output_buffer(
|
more_output_buffer(
|
||||||
VALUE destination,
|
VALUE destination,
|
||||||
unsigned char *(*resize_destination)(VALUE, int, int),
|
unsigned char *(*resize_destination)(VALUE, size_t, size_t),
|
||||||
int max_output,
|
int max_output,
|
||||||
unsigned char **out_start_ptr,
|
unsigned char **out_start_ptr,
|
||||||
unsigned char **out_pos,
|
unsigned char **out_pos,
|
||||||
|
@ -2213,7 +2216,7 @@ static void
|
||||||
transcode_loop(const unsigned char **in_pos, unsigned char **out_pos,
|
transcode_loop(const unsigned char **in_pos, unsigned char **out_pos,
|
||||||
const unsigned char *in_stop, unsigned char *out_stop,
|
const unsigned char *in_stop, unsigned char *out_stop,
|
||||||
VALUE destination,
|
VALUE destination,
|
||||||
unsigned char *(*resize_destination)(VALUE, int, int),
|
unsigned char *(*resize_destination)(VALUE, size_t, size_t),
|
||||||
const char *src_encoding,
|
const char *src_encoding,
|
||||||
const char *dst_encoding,
|
const char *dst_encoding,
|
||||||
int ecflags,
|
int ecflags,
|
||||||
|
@ -2258,7 +2261,7 @@ static void
|
||||||
transcode_loop(const unsigned char **in_pos, unsigned char **out_pos,
|
transcode_loop(const unsigned char **in_pos, unsigned char **out_pos,
|
||||||
const unsigned char *in_stop, unsigned char *out_stop,
|
const unsigned char *in_stop, unsigned char *out_stop,
|
||||||
VALUE destination,
|
VALUE destination,
|
||||||
unsigned char *(*resize_destination)(VALUE, int, int),
|
unsigned char *(*resize_destination)(VALUE, size_t, size_t),
|
||||||
const char *src_encoding,
|
const char *src_encoding,
|
||||||
const char *dst_encoding,
|
const char *dst_encoding,
|
||||||
int ecflags,
|
int ecflags,
|
||||||
|
@ -2331,7 +2334,7 @@ transcode_loop(const unsigned char **in_pos, unsigned char **out_pos,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static unsigned char *
|
static unsigned char *
|
||||||
str_transcoding_resize(VALUE destination, int len, int new_len)
|
str_transcoding_resize(VALUE destination, size_t len, size_t new_len)
|
||||||
{
|
{
|
||||||
rb_str_resize(destination, new_len);
|
rb_str_resize(destination, new_len);
|
||||||
return (unsigned char *)RSTRING_PTR(destination);
|
return (unsigned char *)RSTRING_PTR(destination);
|
||||||
|
@ -2893,7 +2896,7 @@ decorate_convpath(VALUE convpath, int ecflags)
|
||||||
if (num_decorators == -1)
|
if (num_decorators == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
len = n = RARRAY_LEN(convpath);
|
len = n = RARRAY_LENINT(convpath);
|
||||||
if (n != 0) {
|
if (n != 0) {
|
||||||
VALUE pair = RARRAY_PTR(convpath)[n-1];
|
VALUE pair = RARRAY_PTR(convpath)[n-1];
|
||||||
if (TYPE(pair) == T_ARRAY) {
|
if (TYPE(pair) == T_ARRAY) {
|
||||||
|
@ -3031,7 +3034,7 @@ rb_econv_init_by_convpath(VALUE self, VALUE convpath,
|
||||||
rb_encoding *senc = 0, *denc = 0;
|
rb_encoding *senc = 0, *denc = 0;
|
||||||
const char *sname, *dname;
|
const char *sname, *dname;
|
||||||
|
|
||||||
ec = rb_econv_alloc(RARRAY_LEN(convpath));
|
ec = rb_econv_alloc(RARRAY_LENINT(convpath));
|
||||||
DATA_PTR(self) = ec;
|
DATA_PTR(self) = ec;
|
||||||
|
|
||||||
for (i = 0; i < RARRAY_LEN(convpath); i++) {
|
for (i = 0; i < RARRAY_LEN(convpath); i++) {
|
||||||
|
|
Loading…
Reference in a new issue