Add proper casts to silence VC warnings.

parent f1523d24
......@@ -30,7 +30,7 @@
#ifdef _WIN32
#include <windows.h>
#define sleep(x) Sleep(x * 1000)
#define usleep(x) Sleep((DWORD)((x)<1000) ? 1 : ((x)/1000))
#define usleep(x) Sleep((DWORD)(((x)<1000) ? 1 : ((x)/1000)))
#else
#include <unistd.h>
#include <sys/time.h>
......
......@@ -335,7 +335,7 @@ tr_parse_pattern(mrb_state *mrb, struct tr_pattern *ret, const mrb_value v_patte
len = i - start_pos;
if (len > UINT16_MAX) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "tr pattern too long (max 65536)");
mrb_raise(mrb, E_ARGUMENT_ERROR, "tr pattern too long (max 65535)");
}
if (pat1 == NULL && ret) {
goto nomem;
......@@ -343,9 +343,9 @@ tr_parse_pattern(mrb_state *mrb, struct tr_pattern *ret, const mrb_value v_patte
pat1->type = TR_IN_ORDER;
pat1->flag_reverse = flag_reverse;
pat1->flag_on_heap = !ret_uninit;
pat1->n = len;
pat1->n = (uint16_t)len;
pat1->next = NULL;
pat1->val.start_pos = start_pos;
pat1->val.start_pos = (uint16_t)start_pos;
}
if (ret == NULL || ret_uninit) {
......
......@@ -160,7 +160,7 @@ fmt_fp(struct fmt_args *f, long double y, ptrdiff_t w, ptrdiff_t p, uint32_t fl,
out(f, prefix, pl);
out(f, ss, 3);
pad(f, ' ', w, 3+pl, fl^LEFT_ADJ);
return MAX(w, 3+(int)pl);
return (int)MAX(w, 3+pl);
}
y = frexp((double)y, &e2) * 2;
......@@ -215,7 +215,7 @@ fmt_fp(struct fmt_args *f, long double y, ptrdiff_t w, ptrdiff_t p, uint32_t fl,
pad(f, '0', l-(ebuf-estr)-(s-buf), 0, 0);
out(f, estr, ebuf-estr);
pad(f, ' ', w, pl+l, fl^LEFT_ADJ);
return MAX(w, (int)pl+(int)l);
return (int)MAX(w, pl+l);
}
if (p<0) p=6;
......@@ -366,7 +366,7 @@ fmt_fp(struct fmt_args *f, long double y, ptrdiff_t w, ptrdiff_t p, uint32_t fl,
pad(f, ' ', w, pl+l, fl^LEFT_ADJ);
return MAX(w, (int)pl+(int)l);
return (int)MAX(w, pl+l);
}
static int
......@@ -440,7 +440,7 @@ mrb_float_to_cstr(mrb_state *mrb, char *buf, size_t len, const char *fmt, mrb_fl
mrb_raise(mrb, E_ARGUMENT_ERROR, "invalid format string");
}
*cstr.buf = '\0';
return cstr.buf - buf;
return (int)cstr.buf - buf;
}
#else /* MRB_DISABLE_STDIO || _WIN32 || _WIN64 */
#include <mruby.h>
......
......@@ -365,7 +365,7 @@ ht_put(mrb_state *mrb, htable *t, mrb_value key, mrb_value val)
if (!seg->next && i >= t->last_len) {
seg->e[i].key = key;
seg->e[i].val = val;
t->last_len = i+1;
t->last_len = (uint16_t)i+1;
t->size++;
return;
}
......@@ -407,7 +407,7 @@ ht_put(mrb_state *mrb, htable *t, mrb_value key, mrb_value val)
}
seg->e[i].key = key;
seg->e[i].val = val;
t->last_len = i+1;
t->last_len = (uint16_t)i+1;
if (t->index == NULL && t->size > MRB_HT_INIT_SIZE*4) {
ht_index(mrb, t);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment