1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* array.c, bignum.c, dln.c, error.c, gc.c, io.c, marshal.c,

numeric.c, pack.c, strftime.c, string.c, thread.c, transcode.c,
  transcode_data.h, util.c, variable.c, vm_dump.c,
  include/ruby/encoding.h, missing/crypt.c, missing/vsnprintf.c:
  suppress VC type warnings.  [ruby-core:22726]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-03-12 09:16:15 +00:00
parent 080525aa68
commit d1abc53721
21 changed files with 132 additions and 121 deletions

View file

@ -1,4 +1,10 @@
Thu Mar 12 18:09:14 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
Thu Mar 12 18:16:12 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* array.c, bignum.c, dln.c, error.c, gc.c, io.c, marshal.c,
numeric.c, pack.c, strftime.c, string.c, thread.c, transcode.c,
transcode_data.h, util.c, variable.c, vm_dump.c,
include/ruby/encoding.h, missing/crypt.c, missing/vsnprintf.c:
suppress VC type warnings. [ruby-core:22726]
* marshal.c (div0), numeric.c (infinite_value): new functions to
get rid of VC divion by 0 warnings.

View file

@ -25,7 +25,7 @@ VALUE rb_cArray;
static ID id_cmp;
#define ARY_DEFAULT_SIZE 16
#define ARY_MAX_SIZE (LONG_MAX / sizeof(VALUE))
#define ARY_MAX_SIZE (LONG_MAX / (int)sizeof(VALUE))
void
rb_mem_clear(register VALUE *mem, register long size)
@ -3089,7 +3089,7 @@ rb_ary_uniq_bang(VALUE ary)
}
else {
hash = ary_make_hash(ary);
if (RARRAY_LEN(ary) == RHASH_SIZE(hash)) {
if (RARRAY_LEN(ary) == (long)RHASH_SIZE(hash)) {
return Qnil;
}
for (i=j=0; i<RARRAY_LEN(ary); i++) {
@ -3460,7 +3460,7 @@ rb_ary_sample(int argc, VALUE *argv, VALUE ary)
}
return rb_ary_new3(3, ptr[i], ptr[j], ptr[k]);
}
if (n < sizeof(idx)/sizeof(idx[0])) {
if ((size_t)n < sizeof(idx)/sizeof(idx[0])) {
long sorted[sizeof(idx)/sizeof(idx[0])];
sorted[0] = idx[0] = (long)(rb_genrand_real()*len);
for (i=1; i<n; i++) {

View file

@ -69,10 +69,11 @@ rb_cmpint(VALUE val, VALUE a, VALUE b)
}
#define RBIGNUM_SET_LEN(b,l) \
((RBASIC(b)->flags & RBIGNUM_EMBED_FLAG) ? \
(RBASIC(b)->flags = (RBASIC(b)->flags & ~RBIGNUM_EMBED_LEN_MASK) | \
((l) << RBIGNUM_EMBED_LEN_SHIFT)) : \
(RBIGNUM(b)->as.heap.len = (l)))
((RBASIC(b)->flags & RBIGNUM_EMBED_FLAG) ? \
(void)(RBASIC(b)->flags = \
(RBASIC(b)->flags & ~RBIGNUM_EMBED_LEN_MASK) | \
((l) << RBIGNUM_EMBED_LEN_SHIFT)) : \
(void)(RBIGNUM(b)->as.heap.len = (l)))
static void
rb_big_realloc(VALUE big, long len)
@ -190,17 +191,21 @@ bigfixize(VALUE x)
long len = RBIGNUM_LEN(x);
BDIGIT *ds = BDIGITS(x);
if (len*SIZEOF_BDIGITS <= sizeof(long)) {
if (len > 0 && len*SIZEOF_BDIGITS <= sizeof(long)) {
long num = 0;
#if 2*SIZEOF_BDIGITS > SIZEOF_LONG
num = (long)ds[0];
#else
while (len--) {
num = BIGUP(num) + ds[len];
num = (long)(BIGUP(num) + ds[len]);
}
#endif
if (num >= 0) {
if (RBIGNUM_SIGN(x)) {
if (POSFIXABLE(num)) return LONG2FIX(num);
}
else {
if (NEGFIXABLE(-(long)num)) return LONG2FIX(-(long)num);
if (NEGFIXABLE(-num)) return LONG2FIX(-num);
}
}
}
@ -1017,7 +1022,7 @@ big2ulong(VALUE x, const char *type, int check)
num = BIGUP(num);
num += ds[len];
}
return num;
return (VALUE)num;
}
VALUE
@ -1581,7 +1586,7 @@ bigmul1_normal(VALUE x, VALUE y)
n = BIGDN(n);
}
if (n) {
zds[i + j] = n;
zds[i + j] = (BDIGIT)n;
}
}
rb_thread_check_ints();
@ -1770,7 +1775,7 @@ bigsqr_fast(VALUE x)
zds[i + len] = BIGLO(c);
c = BIGDN(c);
}
if (c) zds[i + len + 1] += c;
if (c) zds[i + len + 1] += (BDIGIT)c;
}
return z;
}
@ -1889,7 +1894,7 @@ bigdivrem1(void *ptr)
for (nyzero = 0; !yds[nyzero]; nyzero++);
do {
if (bds->stop) return Qnil;
if (zds[j] == yds[ny-1]) q = BIGRAD-1;
if (zds[j] == yds[ny-1]) q = (BDIGIT)BIGRAD-1;
else q = (BDIGIT)((BIGUP(zds[j]) + zds[j-1])/yds[ny-1]);
if (q) {
i = nyzero; num = 0; t2 = 0;
@ -2480,7 +2485,7 @@ rb_big_or(VALUE xx, VALUE yy)
zds[i] = ds1[i] | ds2[i];
}
for (; i<l2; i++) {
zds[i] = sign?ds2[i]:(BIGRAD-1);
zds[i] = sign?ds2[i]:(BDIGIT)(BIGRAD-1);
}
if (!RBIGNUM_SIGN(z)) get2comp(z);

6
dln.c
View file

@ -1475,7 +1475,7 @@ dln_load(const char *file)
return 0; /* dummy return */
}
static char *dln_find_1(const char *fname, const char *path, char *buf, int size, int exe_flag);
static char *dln_find_1(const char *fname, const char *path, char *buf, size_t size, int exe_flag);
char *
dln_find_exe_r(const char *fname, const char *path, char *buf, int size)
@ -1516,14 +1516,14 @@ dln_find_file(const char *fname, const char *path)
}
static char *
dln_find_1(const char *fname, const char *path, char *fbuf, int size,
dln_find_1(const char *fname, const char *path, char *fbuf, size_t size,
int exe_flag /* non 0 if looking for executable. */)
{
register const char *dp;
register const char *ep;
register char *bp;
struct stat st;
int i, fspace;
size_t i, fspace;
#ifdef DOSISH
int is_abs = 0, has_path = 0, has_ext = 0;
const char *p = fname;

View file

@ -205,8 +205,8 @@ report_bug(const char *file, int line, const char *fmt, va_list args)
FILE *out = stderr;
int len = err_position_0(buf, BUFSIZ, file, line);
if (fwrite(buf, 1, len, out) == len ||
fwrite(buf, 1, len, (out = stdout)) == len) {
if ((ssize_t)fwrite(buf, 1, len, out) == (ssize_t)len ||
(ssize_t)fwrite(buf, 1, len, (out = stdout)) == (ssize_t)len) {
fputs("[BUG] ", out);
vfprintf(out, fmt, args);

8
gc.c
View file

@ -1090,12 +1090,12 @@ rb_data_object_alloc(VALUE klass, void *datap, RUBY_DATA_FUNC dmark, RUBY_DATA_F
#define STACK_LEVEL_MAX (th->machine_stack_maxsize/sizeof(VALUE))
#if STACK_GROW_DIRECTION < 0
# define STACK_LENGTH (STACK_START - STACK_END)
# define STACK_LENGTH (size_t)(STACK_START - STACK_END)
#elif STACK_GROW_DIRECTION > 0
# define STACK_LENGTH (STACK_END - STACK_START + 1)
# define STACK_LENGTH (size_t)(STACK_END - STACK_START + 1)
#else
# define STACK_LENGTH ((STACK_END < STACK_START) ? STACK_START - STACK_END\
: STACK_END - STACK_START + 1)
# define STACK_LENGTH ((STACK_END < STACK_START) ? (size_t)(STACK_START - STACK_END) \
: (size_t)(STACK_END - STACK_START + 1))
#endif
#if !STACK_GROW_DIRECTION
int ruby_stack_grow_direction;

View file

@ -32,7 +32,7 @@
rb_enc_set_index(rb_encoding_set_obj, encoding_set_enc_index); \
} while (0)
#define ENCODING_GET_INLINED(obj) ((RBASIC(obj)->flags & ENCODING_MASK)>>ENCODING_SHIFT)
#define ENCODING_GET_INLINED(obj) (int)((RBASIC(obj)->flags & ENCODING_MASK)>>ENCODING_SHIFT)
#define ENCODING_GET(obj) \
(ENCODING_GET_INLINED(obj) != ENCODING_INLINE_MAX ? \
ENCODING_GET_INLINED(obj) : \

4
io.c
View file

@ -7669,7 +7669,7 @@ nogvl_copy_stream_read_write(struct copy_stream_struct *stp)
while (use_eof || 0 < copy_length) {
if (!use_eof && copy_length < sizeof(buf)) {
len = copy_length;
len = (size_t)copy_length;
}
else {
len = sizeof(buf);
@ -7862,7 +7862,7 @@ copy_stream_body(VALUE arg)
long len = src_fptr->rbuf_len;
VALUE str;
if (stp->copy_length != (off_t)-1 && stp->copy_length < len) {
len = stp->copy_length;
len = (size_t)stp->copy_length;
}
str = rb_str_buf_new(len);
rb_str_resize(str,len);

View file

@ -246,7 +246,7 @@ w_long(long x, struct dump_arg *arg)
return;
}
for (i=1;i<sizeof(long)+1;i++) {
buf[i] = x & 0xff;
buf[i] = (char)(x & 0xff);
x = RSHIFT(x,8);
if (x == 0) {
buf[0] = i;
@ -290,15 +290,15 @@ save_mantissa(double d, char *buf)
d = modf(ldexp(d, MANT_BITS), &n);
m = (unsigned long)n;
#if MANT_BITS > 24
buf[i++] = m >> 24;
buf[i++] = (char)(m >> 24);
#endif
#if MANT_BITS > 16
buf[i++] = m >> 16;
buf[i++] = (char)(m >> 16);
#endif
#if MANT_BITS > 8
buf[i++] = m >> 8;
buf[i++] = (char)(m >> 8);
#endif
buf[i++] = m;
buf[i++] = (char)m;
} while (d > 0);
while (!buf[i - 1]) --i;
}

View file

@ -257,10 +257,10 @@ typedef union {
*/
#define TO_SIX_BIT(rslt, src) { \
C_block cvt; \
cvt.b[0] = src; src >>= 6; \
cvt.b[1] = src; src >>= 6; \
cvt.b[2] = src; src >>= 6; \
cvt.b[3] = src; \
cvt.b[0] = (unsigned char)src; src >>= 6; \
cvt.b[1] = (unsigned char)src; src >>= 6; \
cvt.b[2] = (unsigned char)src; src >>= 6; \
cvt.b[3] = (unsigned char)src; \
rslt = (cvt.b32.i0 & 0x3f3f3f3fL) << 2; \
}
@ -784,7 +784,7 @@ init_des()
k = (k|07) - (k&07);
k++;
}
perm[i] = k;
perm[i] = (unsigned char)k;
}
#ifdef DEBUG
prtab("pc1tab", perm, 8);
@ -831,7 +831,7 @@ init_des()
k = (k|07) - (k&07);
k++;
}
perm[i*8+j] = k;
perm[i*8+j] = (unsigned char)k;
}
}
#ifdef DEBUG
@ -877,7 +877,7 @@ init_des()
for (i = 0; i < 32; i++)
tmp32[i] = 0;
for (i = 0; i < 4; i++)
tmp32[4 * tableno + i] = (k >> i) & 01;
tmp32[4 * tableno + i] = (unsigned char)(k >> i) & 01;
k = 0;
for (i = 24; --i >= 0; )
k = (k<<1) | tmp32[perm[i]-1];

View file

@ -240,7 +240,7 @@ static int BSD__sfvwrite(fp, uio)
register size_t len;
register const char *p;
register struct __siov *iov;
register int w;
register size_t w;
if ((len = uio->uio_resid) == 0)
return (0);
@ -347,7 +347,7 @@ BSD__sbprintf(register FILE *fp, const char *fmt, va_list ap)
*/
#define to_digit(c) ((c) - '0')
#define is_digit(c) ((unsigned)to_digit(c) <= 9)
#define to_char(n) ((n) + '0')
#define to_char(n) (char)((n) + '0')
#ifdef _HAVE_SANE_QUAD_
/*

View file

@ -1954,7 +1954,7 @@ int_chr(int argc, VALUE *argv, VALUE num)
out_of_range:
rb_raise(rb_eRangeError, "%"PRIdVALUE " out of char range", i);
}
c = i;
c = (char)i;
if (i < 0x80) {
return rb_usascii_str_new(&c, 1);
}

68
pack.c
View file

@ -690,7 +690,7 @@ pack_pack(VALUE ary, VALUE fmt)
char c;
from = NEXTFROM;
c = num2i32(from);
c = (char)num2i32(from);
rb_str_buf_cat(res, &c, sizeof(char));
}
break;
@ -701,7 +701,7 @@ pack_pack(VALUE ary, VALUE fmt)
short s;
from = NEXTFROM;
s = num2i32(from);
s = (short)num2i32(from);
rb_str_buf_cat(res, OFF16(&s), NATINT_LEN(short,2));
}
break;
@ -744,7 +744,7 @@ pack_pack(VALUE ary, VALUE fmt)
unsigned short s;
from = NEXTFROM;
s = num2i32(from);
s = (unsigned short)num2i32(from);
s = NATINT_HTONS(s);
rb_str_buf_cat(res, OFF16(&s), NATINT_LEN(short,2));
}
@ -766,7 +766,7 @@ pack_pack(VALUE ary, VALUE fmt)
unsigned short s;
from = NEXTFROM;
s = num2i32(from);
s = (unsigned short)num2i32(from);
s = NATINT_HTOVS(s);
rb_str_buf_cat(res, OFF16(&s), NATINT_LEN(short,2));
}
@ -789,7 +789,7 @@ pack_pack(VALUE ary, VALUE fmt)
float f;
from = NEXTFROM;
f = RFLOAT_VALUE(rb_to_float(from));
f = (float)RFLOAT_VALUE(rb_to_float(from));
rb_str_buf_cat(res, (char*)&f, sizeof(float));
}
break;
@ -800,7 +800,7 @@ pack_pack(VALUE ary, VALUE fmt)
FLOAT_CONVWITH(ftmp);
from = NEXTFROM;
f = RFLOAT_VALUE(rb_to_float(from));
f = (float)RFLOAT_VALUE(rb_to_float(from));
f = HTOVF(f,ftmp);
rb_str_buf_cat(res, (char*)&f, sizeof(float));
}
@ -835,7 +835,7 @@ pack_pack(VALUE ary, VALUE fmt)
FLOAT_CONVWITH(ftmp);
from = NEXTFROM;
f = RFLOAT_VALUE(rb_to_float(from));
f = (float)RFLOAT_VALUE(rb_to_float(from));
f = HTONF(f,ftmp);
rb_str_buf_cat(res, (char*)&f, sizeof(float));
}
@ -990,7 +990,7 @@ pack_pack(VALUE ary, VALUE fmt)
}
while (ul) {
c = ((ul & 0x7f) | 0x80);
c = (char)(ul & 0x7f) | 0x80;
rb_str_buf_cat(buf, &c, sizeof(char));
ul >>= 7;
}
@ -1050,7 +1050,7 @@ encodes(VALUE str, const char *s, long len, int type, int tail_lf)
int padding;
if (type == 'u') {
buff[i++] = len + ' ';
buff[i++] = (char)len + ' ';
padding = '`';
}
else {
@ -1162,7 +1162,7 @@ hex2num(char c)
#define PACK_LENGTH_ADJUST_SIZE(sz) do { \
tmp = 0; \
if (len > (send-s)/sz) { \
if (len > (long)((send-s)/sz)) { \
if (!star) { \
tmp = len-(send-s)/sz; \
} \
@ -1807,9 +1807,9 @@ pack_unpack(VALUE str, VALUE fmt)
d = (*s++ - ' ') & 077;
else
d = 0;
hunk[0] = a << 2 | b >> 4;
hunk[1] = b << 4 | c >> 2;
hunk[2] = c << 6 | d;
hunk[0] = (char)(a << 2 | b >> 4);
hunk[1] = (char)(b << 4 | c >> 2);
hunk[2] = (char)(c << 6 | d);
memcpy(ptr, hunk, mlen);
ptr += mlen;
len -= mlen;
@ -1990,7 +1990,7 @@ pack_unpack(VALUE str, VALUE fmt)
break;
case 'p':
if (len > (send - s) / sizeof(char *))
if (len > (long)((send - s) / sizeof(char *)))
len = (send - s) / sizeof(char *);
while (len-- > 0) {
if (send - s < sizeof(char *))
@ -2075,38 +2075,38 @@ rb_uv_to_utf8(char buf[6], unsigned long uv)
return 1;
}
if (uv <= 0x7ff) {
buf[0] = ((uv>>6)&0xff)|0xc0;
buf[1] = (uv&0x3f)|0x80;
buf[0] = (char)((uv>>6)&0xff)|0xc0;
buf[1] = (char)(uv&0x3f)|0x80;
return 2;
}
if (uv <= 0xffff) {
buf[0] = ((uv>>12)&0xff)|0xe0;
buf[1] = ((uv>>6)&0x3f)|0x80;
buf[2] = (uv&0x3f)|0x80;
buf[0] = (char)((uv>>12)&0xff)|0xe0;
buf[1] = (char)((uv>>6)&0x3f)|0x80;
buf[2] = (char)(uv&0x3f)|0x80;
return 3;
}
if (uv <= 0x1fffff) {
buf[0] = ((uv>>18)&0xff)|0xf0;
buf[1] = ((uv>>12)&0x3f)|0x80;
buf[2] = ((uv>>6)&0x3f)|0x80;
buf[3] = (uv&0x3f)|0x80;
buf[0] = (char)((uv>>18)&0xff)|0xf0;
buf[1] = (char)((uv>>12)&0x3f)|0x80;
buf[2] = (char)((uv>>6)&0x3f)|0x80;
buf[3] = (char)(uv&0x3f)|0x80;
return 4;
}
if (uv <= 0x3ffffff) {
buf[0] = ((uv>>24)&0xff)|0xf8;
buf[1] = ((uv>>18)&0x3f)|0x80;
buf[2] = ((uv>>12)&0x3f)|0x80;
buf[3] = ((uv>>6)&0x3f)|0x80;
buf[4] = (uv&0x3f)|0x80;
buf[0] = (char)((uv>>24)&0xff)|0xf8;
buf[1] = (char)((uv>>18)&0x3f)|0x80;
buf[2] = (char)((uv>>12)&0x3f)|0x80;
buf[3] = (char)((uv>>6)&0x3f)|0x80;
buf[4] = (char)(uv&0x3f)|0x80;
return 5;
}
if (uv <= 0x7fffffff) {
buf[0] = ((uv>>30)&0xff)|0xfc;
buf[1] = ((uv>>24)&0x3f)|0x80;
buf[2] = ((uv>>18)&0x3f)|0x80;
buf[3] = ((uv>>12)&0x3f)|0x80;
buf[4] = ((uv>>6)&0x3f)|0x80;
buf[5] = (uv&0x3f)|0x80;
buf[0] = (char)((uv>>30)&0xff)|0xfc;
buf[1] = (char)((uv>>24)&0x3f)|0x80;
buf[2] = (char)((uv>>18)&0x3f)|0x80;
buf[3] = (char)((uv>>12)&0x3f)|0x80;
buf[4] = (char)((uv>>6)&0x3f)|0x80;
buf[5] = (char)(uv&0x3f)|0x80;
return 6;
}
rb_raise(rb_eRangeError, "pack(U): value out of range");

View file

@ -515,7 +515,7 @@ rb_strftime(char *s, size_t maxsize, const char *format, const struct tm *timept
time_t now;
time(&now);
utc = *gmtime(&now);
off = (now - mktime(&utc)) / 60;
off = (long)((now - mktime(&utc)) / 60);
}
#endif
#endif /* !HAVE_VAR_TIMEZONE */

View file

@ -1279,7 +1279,7 @@ rb_string_value_cstr(volatile VALUE *ptr)
VALUE str = rb_string_value(ptr);
char *s = RSTRING_PTR(str);
if (!s || RSTRING_LEN(str) != strlen(s)) {
if (!s || RSTRING_LEN(str) != (long)strlen(s)) {
rb_raise(rb_eArgError, "string contains null byte");
}
return s;
@ -4794,8 +4794,8 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag)
str_modify_keep_cr(str);
s = RSTRING_PTR(str); send = RSTRING_END(str);
if (sflag) {
int clen, tlen, max = RSTRING_LEN(str);
int offset, save = -1;
int offset, clen, tlen, max = RSTRING_LEN(str);
unsigned int save = -1;
char *buf = ALLOC_N(char, max), *t = buf;
while (s < send) {
@ -5167,9 +5167,9 @@ rb_str_squeeze_bang(int argc, VALUE *argv, VALUE str)
rb_encoding *enc = 0;
VALUE del = 0, nodel = 0;
char *s, *send, *t;
int save, modify = 0;
int i;
int i, modify = 0;
int ascompat, singlebyte = single_byte_optimizable(str);
unsigned int save;
if (argc == 0) {
enc = STR_ENC_GET(str);
@ -7013,11 +7013,11 @@ sym_inspect(VALUE sym)
str = rb_enc_str_new(0, RSTRING_LEN(sym)+1, enc);
RSTRING_PTR(str)[0] = ':';
memcpy(RSTRING_PTR(str)+1, RSTRING_PTR(sym), RSTRING_LEN(sym));
if (RSTRING_LEN(sym) != strlen(RSTRING_PTR(sym)) ||
if (RSTRING_LEN(sym) != (long)strlen(RSTRING_PTR(sym)) ||
!rb_enc_symname_p(RSTRING_PTR(sym), enc) ||
!sym_printable(RSTRING_PTR(sym), RSTRING_END(sym), enc)) {
str = rb_str_inspect(str);
strncpy(RSTRING_PTR(str), ":\"", 2);
memcpy(RSTRING_PTR(str), ":\"", 2);
}
return str;
}

View file

@ -2280,7 +2280,7 @@ rb_fd_set(int fd, rb_fdset_t *set)
return;
}
}
if (set->fdset->fd_count >= set->capa) {
if (set->fdset->fd_count >= (unsigned)set->capa) {
set->capa = (set->fdset->fd_count / FD_SETSIZE + 1) * FD_SETSIZE;
set->fdset = xrealloc(set->fdset, sizeof(unsigned int) + sizeof(SOCKET) * set->capa);
}

View file

@ -86,7 +86,7 @@ typedef struct rb_transcoding {
#define TRANSCODING_WRITEBUF_SIZE(tc) \
((tc)->transcoder->max_output <= sizeof((tc)->writebuf.ary) ? \
sizeof((tc)->writebuf.ary) : \
(tc)->transcoder->max_output)
(size_t)(tc)->transcoder->max_output)
#define TRANSCODING_STATE_EMBED_MAX sizeof(union rb_transcoding_state_t)
#define TRANSCODING_STATE(tc) \
((tc)->transcoder->state_size <= sizeof((tc)->state) ? \
@ -1598,11 +1598,11 @@ rb_econv_insert_output(rb_econv_t *ec,
*data_end_p = buf;
*buf_end_p = buf+need;
}
else if (*buf_end_p - *data_end_p < need) {
else if ((size_t)(*buf_end_p - *data_end_p) < need) {
MEMMOVE(*buf_start_p, *data_start_p, unsigned char, *data_end_p - *data_start_p);
*data_end_p = *buf_start_p + (*data_end_p - *data_start_p);
*data_start_p = *buf_start_p;
if (*buf_end_p - *data_end_p < need) {
if ((size_t)(*buf_end_p - *data_end_p) < need) {
unsigned char *buf;
size_t s = (*data_end_p - *buf_start_p) + need;
if (s < need)
@ -2019,7 +2019,7 @@ make_econv_exception(rb_econv_t *ec)
end = start + ec->last_error.error_bytes_len;
n = rb_enc_precise_mbclen(start, end, utf8);
if (MBCLEN_CHARFOUND_P(n) &&
MBCLEN_CHARFOUND_LEN(n) == ec->last_error.error_bytes_len) {
(size_t)MBCLEN_CHARFOUND_LEN(n) == ec->last_error.error_bytes_len) {
unsigned int cc = rb_enc_codepoint(start, end, utf8);
dumped = rb_sprintf("U+%04X", cc);
}

View file

@ -37,7 +37,7 @@
#define STR1 (PType 0x11) /* string 4 <= len <= 259 bytes: 1byte length + content */
#define GB4bt (PType 0x12) /* GB18030 four bytes payload */
#define STR1_LENGTH(byte_addr) (*(byte_addr) + 4)
#define STR1_LENGTH(byte_addr) (unsigned int)(*(byte_addr) + 4)
#define STR1_BYTEINDEX(w) ((w) >> 6)
#define makeSTR1(bi) (((bi) << 6) | STR1)
#define makeSTR1LEN(len) ((len)-4)
@ -48,15 +48,15 @@
#define o4(b0,b1,b2,b3) (PType(((((unsigned char)(b1))<<8)|(((unsigned char)(b2))<<16)|(((unsigned char)(b3))<<24)|((((unsigned char)(b0))&0x07)<<5)|FOURbt)&0xffffffffU))
#define g4(b0,b1,b2,b3) (PType(((((unsigned char)(b0))<<8)|(((unsigned char)(b2))<<16)|((((unsigned char)(b1))&0x0f)<<24)|((((unsigned int)(unsigned char)(b3))&0x0f)<<28)|GB4bt)&0xffffffffU))
#define getBT1(a) (((a)>> 8)&0xFF)
#define getBT2(a) (((a)>>16)&0xFF)
#define getBT3(a) (((a)>>24)&0xFF)
#define getBT0(a) ((((a)>> 5)&0x07)|0xF0) /* for UTF-8 only!!! */
#define getBT1(a) ((unsigned char)((a)>> 8))
#define getBT2(a) ((unsigned char)((a)>>16))
#define getBT3(a) ((unsigned char)((a)>>24))
#define getBT0(a) (((unsigned char)((a)>> 5)&0x07)|0xF0) /* for UTF-8 only!!! */
#define getGB4bt0(a) (((a)>> 8)&0xFF)
#define getGB4bt1(a) (((a)>>24)&0x0F|0x30)
#define getGB4bt2(a) (((a)>>16)&0xFF)
#define getGB4bt3(a) (((a)>>28)&0x0F|0x30)
#define getGB4bt0(a) ((unsigned char)((a)>> 8))
#define getGB4bt1(a) ((unsigned char)((a)>>24)&0x0F|0x30)
#define getGB4bt2(a) ((unsigned char)((a)>>16))
#define getGB4bt3(a) ((unsigned char)((a)>>28)&0x0F|0x30)
#define o2FUNii(b1,b2) (PType((((unsigned char)(b1))<<8)|(((unsigned char)(b2))<<16)|FUNii))

24
util.c
View file

@ -1170,11 +1170,11 @@ static Bigint *
multadd(Bigint *b, int m, int a) /* multiply by m and add a */
{
int i, wds;
#ifdef ULLong
ULong *x;
#ifdef ULLong
ULLong carry, y;
#else
ULong carry, *x, y;
ULong carry, y;
#ifdef Pack_32
ULong xi, z;
#endif
@ -1189,7 +1189,7 @@ multadd(Bigint *b, int m, int a) /* multiply by m and add a */
#ifdef ULLong
y = *x * (ULLong)m + carry;
carry = y >> 32;
*x++ = y & FFFFFFFF;
*x++ = (ULong)y & FFFFFFFF;
#else
#ifdef Pack_32
xi = *x;
@ -1211,7 +1211,7 @@ multadd(Bigint *b, int m, int a) /* multiply by m and add a */
Bfree(b);
b = b1;
}
b->x[wds++] = carry;
b->x[wds++] = (ULong)carry;
b->wds = wds;
}
return b;
@ -1378,9 +1378,9 @@ mult(Bigint *a, Bigint *b)
do {
z = *x++ * (ULLong)y + *xc + carry;
carry = z >> 32;
*xc++ = z & FFFFFFFF;
*xc++ = (ULong)z & FFFFFFFF;
} while (x < xae);
*xc = carry;
*xc = (ULong)carry;
}
}
#else
@ -1397,7 +1397,7 @@ mult(Bigint *a, Bigint *b)
carry = z2 >> 16;
Storeinc(xc, z2, z);
} while (x < xae);
*xc = carry;
*xc = (ULong)carry;
}
if (y = *xb >> 16) {
x = xa;
@ -1425,7 +1425,7 @@ mult(Bigint *a, Bigint *b)
carry = z >> 16;
*xc++ = z & 0xffff;
} while (x < xae);
*xc = carry;
*xc = (ULong)carry;
}
}
#endif
@ -1616,12 +1616,12 @@ diff(Bigint *a, Bigint *b)
do {
y = (ULLong)*xa++ - *xb++ - borrow;
borrow = y >> 32 & (ULong)1;
*xc++ = y & FFFFFFFF;
*xc++ = (ULong)y & FFFFFFFF;
} while (xb < xbe);
while (xa < xae) {
y = *xa++ - borrow;
borrow = y >> 32 & (ULong)1;
*xc++ = y & FFFFFFFF;
*xc++ = (ULong)y & FFFFFFFF;
}
#else
#ifdef Pack_32
@ -2979,7 +2979,7 @@ quorem(Bigint *b, Bigint *S)
carry = ys >> 32;
y = *bx - (ys & FFFFFFFF) - borrow;
borrow = y >> 32 & (ULong)1;
*bx++ = y & FFFFFFFF;
*bx++ = (ULong)y & FFFFFFFF;
#else
#ifdef Pack_32
si = *sx++;
@ -3019,7 +3019,7 @@ quorem(Bigint *b, Bigint *S)
carry = ys >> 32;
y = *bx - (ys & FFFFFFFF) - borrow;
borrow = y >> 32 & (ULong)1;
*bx++ = y & FFFFFFFF;
*bx++ = (ULong)y & FFFFFFFF;
#else
#ifdef Pack_32
si = *sx++;

View file

@ -963,7 +963,7 @@ ivar_get(VALUE obj, ID id, int warn)
iv_index_tbl = ROBJECT_IV_INDEX_TBL(obj);
if (!iv_index_tbl) break;
if (!st_lookup(iv_index_tbl, id, &index)) break;
if (len <= index) break;
if (len <= (long)index) break;
val = ptr[index];
if (val != Qundef)
return val;
@ -1024,7 +1024,7 @@ rb_ivar_set(VALUE obj, ID id, VALUE val)
ivar_extended = 1;
}
len = ROBJECT_NUMIV(obj);
if (len <= index) {
if (len <= (long)index) {
VALUE *ptr = ROBJECT_IVPTR(obj);
if (index < ROBJECT_EMBED_LEN_MAX) {
RBASIC(obj)->flags |= ROBJECT_EMBED;
@ -1037,7 +1037,7 @@ rb_ivar_set(VALUE obj, ID id, VALUE val)
VALUE *newptr;
long newsize = (index+1) + (index+1)/4; /* (index+1)*1.25 */
if (!ivar_extended &&
iv_index_tbl->num_entries < newsize) {
iv_index_tbl->num_entries < (st_index_t)newsize) {
newsize = iv_index_tbl->num_entries;
}
if (RBASIC(obj)->flags & ROBJECT_EMBED) {
@ -1081,7 +1081,7 @@ rb_ivar_defined(VALUE obj, ID id)
iv_index_tbl = ROBJECT_IV_INDEX_TBL(obj);
if (!iv_index_tbl) break;
if (!st_lookup(iv_index_tbl, id, &index)) break;
if (ROBJECT_NUMIV(obj) <= index) break;
if (ROBJECT_NUMIV(obj) <= (long)index) break;
val = ROBJECT_IVPTR(obj)[index];
if (val != Qundef)
return Qtrue;
@ -1108,7 +1108,7 @@ struct obj_ivar_tag {
static int
obj_ivar_i(ID key, VALUE index, struct obj_ivar_tag *data)
{
if (index < ROBJECT_NUMIV(data->obj)) {
if ((long)index < ROBJECT_NUMIV(data->obj)) {
VALUE val = ROBJECT_IVPTR(data->obj)[index];
if (val != Qundef) {
return (data->func)(key, val, data->arg);
@ -1238,7 +1238,7 @@ rb_obj_remove_instance_variable(VALUE obj, VALUE name)
iv_index_tbl = ROBJECT_IV_INDEX_TBL(obj);
if (!iv_index_tbl) break;
if (!st_lookup(iv_index_tbl, id, &index)) break;
if (ROBJECT_NUMIV(obj) <= index) break;
if (ROBJECT_NUMIV(obj) <= (long)index) break;
val = ROBJECT_IVPTR(obj)[index];
if (val != Qundef) {
ROBJECT_IVPTR(obj)[index] = Qundef;

View file

@ -34,11 +34,11 @@ control_frame_dump(rb_thread_t *th, rb_control_frame_t *cfp)
biseq_name = ""; /* RSTRING(cfp->block_iseq->name)->ptr; */
}
if (lfp < 0 || lfp > th->stack_size) {
if (lfp < 0 || (size_t)lfp > th->stack_size) {
lfp = (ptrdiff_t)cfp->lfp;
lfp_in_heap = 'p';
}
if (dfp < 0 || dfp > th->stack_size) {
if (dfp < 0 || (size_t)dfp > th->stack_size) {
dfp = (ptrdiff_t)cfp->dfp;
dfp_in_heap = 'p';
}
@ -338,9 +338,9 @@ rb_vmdebug_debug_print_register(rb_thread_t *th)
pc = cfp->pc - cfp->iseq->iseq_encoded;
}
if (lfp < 0 || lfp > th->stack_size)
if (lfp < 0 || (size_t)lfp > th->stack_size)
lfp = -1;
if (dfp < 0 || dfp > th->stack_size)
if (dfp < 0 || (size_t)dfp > th->stack_size)
dfp = -1;
cfpi = ((rb_control_frame_t *)(th->stack + th->stack_size)) - cfp;