diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2015-12-22 18:02:31 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2015-12-22 18:02:31 +0900 |
| commit | 7e4a7abf5f2396acc1eb302da75f79b296aa3b31 (patch) | |
| tree | 16f444f586b644175032c34253a14e1e2cb403c2 /src | |
| parent | d0727be6eb22932aaf67447d09c9b3751516e891 (diff) | |
| parent | 7cc33af2dc1137ef819b589e51e3756bdaa222e1 (diff) | |
| download | mruby-7e4a7abf5f2396acc1eb302da75f79b296aa3b31.tar.gz mruby-7e4a7abf5f2396acc1eb302da75f79b296aa3b31.zip | |
Merge pull request #3055 from mattn/fix-msvc-warnings
fix build on VS2012
Diffstat (limited to 'src')
| -rw-r--r-- | src/dump.c | 2 | ||||
| -rw-r--r-- | src/fmt_fp.c | 6 | ||||
| -rw-r--r-- | src/string.c | 8 |
3 files changed, 10 insertions, 6 deletions
diff --git a/src/dump.c b/src/dump.c index 8870c6c65..ea1cd5596 100644 --- a/src/dump.c +++ b/src/dump.c @@ -54,7 +54,7 @@ write_irep_header(mrb_state *mrb, mrb_irep *irep, uint8_t *buf) { uint8_t *cur = buf; - cur += uint32_to_bin(get_irep_record_size_1(mrb, irep), cur); /* record size */ + cur += uint32_to_bin((uint32_t)get_irep_record_size_1(mrb, irep), cur); /* record size */ cur += uint16_to_bin((uint16_t)irep->nlocals, cur); /* number of local variable */ cur += uint16_to_bin((uint16_t)irep->nregs, cur); /* number of register variable */ cur += uint16_to_bin((uint16_t)irep->rlen, cur); /* number of child irep */ diff --git a/src/fmt_fp.c b/src/fmt_fp.c index b20eb895f..61c7a4cc9 100644 --- a/src/fmt_fp.c +++ b/src/fmt_fp.c @@ -156,7 +156,7 @@ fmt_fp(struct fmt_args *f, long double y, int w, int p, int fl, int t) s=buf; do { - int x=y; + int x=(int)y; *s++=xdigits[x]|(t&32); y=16*(y-x); if (s-buf==1 && (y||p>0||(fl&ALT_FORM))) *s++='.'; @@ -184,7 +184,7 @@ fmt_fp(struct fmt_args *f, long double y, int w, int p, int fl, int t) else a=r=z=big+sizeof(big)/sizeof(*big) - LDBL_MANT_DIG - 1; do { - *z = y; + *z = (uint32_t)y; y = 1000000000*(y-*z++); } while (y); @@ -194,7 +194,7 @@ fmt_fp(struct fmt_args *f, long double y, int w, int p, int fl, int t) for (d=z-1; d>=a; d--) { uint64_t x = ((uint64_t)*d<<sh)+carry; *d = x % 1000000000; - carry = x / 1000000000; + carry = (uint32_t)(x / 1000000000); } if (carry) *--a = carry; while (z>a && !z[-1]) z--; diff --git a/src/string.c b/src/string.c index 2638fa04e..6664eabd6 100644 --- a/src/string.c +++ b/src/string.c @@ -4,6 +4,10 @@ ** See Copyright Notice in mruby.h */ +#ifdef _MSC_VER +# define _CRT_NONSTDC_NO_DEPRECATE +#endif + #include <float.h> #include <limits.h> #include <stddef.h> @@ -2170,12 +2174,12 @@ mrb_str_len_to_inum(mrb_state *mrb, const char *str, size_t len, int base, int b } n *= base; n += c; - if (n > (int64_t)MRB_INT_MAX + (sign ? 0 : 1)) { + if (n > (uint64_t)MRB_INT_MAX + (sign ? 0 : 1)) { mrb_raisef(mrb, E_ARGUMENT_ERROR, "string (%S) too big for integer", mrb_str_new(mrb, str, pend-str)); } } - val = n; + val = (mrb_int)n; if (badcheck) { if (p == str) goto bad; /* no number */ while (p<pend && ISSPACE(*p)) p++; |
