summaryrefslogtreecommitdiffhomepage
path: root/src/fmt_fp.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2017-08-19 17:09:30 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2017-08-19 17:09:30 +0900
commit5d0fc7e57a02987c15c41c7211b928491227bdc6 (patch)
treebea864a1befd5c60ab5029311b9102243d4e007b /src/fmt_fp.c
parent8cea1f890758da901916ba331bf4b524e4e54e00 (diff)
downloadmruby-5d0fc7e57a02987c15c41c7211b928491227bdc6.tar.gz
mruby-5d0fc7e57a02987c15c41c7211b928491227bdc6.zip
Reduce signed/unsigned warnings in fmt_fp.c
Diffstat (limited to 'src/fmt_fp.c')
-rw-r--r--src/fmt_fp.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/fmt_fp.c b/src/fmt_fp.c
index 803343233..ac76cef0e 100644
--- a/src/fmt_fp.c
+++ b/src/fmt_fp.c
@@ -91,7 +91,7 @@ typedef char compiler_defines_long_double_incorrectly[9-(int)sizeof(long double)
#endif
static int
-fmt_fp(struct fmt_args *f, long double y, int w, int p, uint8_t fl, int t)
+fmt_fp(struct fmt_args *f, long double y, ptrdiff_t p, uint8_t fl, int t)
{
uint32_t big[(LDBL_MANT_DIG+28)/29 + 1 // mantissa expansion
+ (LDBL_MAX_EXP+LDBL_MANT_DIG+28+8)/9]; // exponent expansion
@@ -116,11 +116,11 @@ fmt_fp(struct fmt_args *f, long double y, int w, int p, uint8_t fl, int t)
if (!isfinite(y)) {
const char *ss = (t&32)?"inf":"INF";
if (y!=y) ss=(t&32)?"nan":"NAN";
- pad(f, ' ', w, 3+pl, fl&~ZERO_PAD);
+ pad(f, ' ', 0, 3+pl, fl&~ZERO_PAD);
out(f, prefix, pl);
out(f, ss, 3);
- pad(f, ' ', w, 3+pl, fl^LEFT_ADJ);
- return MAX(w, 3+pl);
+ pad(f, ' ', 0, 3+pl, fl^LEFT_ADJ);
+ return MAX(0, 3+pl);
}
y = frexp((double)y, &e2) * 2;
@@ -168,14 +168,14 @@ fmt_fp(struct fmt_args *f, long double y, int w, int p, uint8_t fl, int t)
else
l = (s-buf) + (ebuf-estr);
- pad(f, ' ', w, pl+l, fl);
+ pad(f, ' ', 0, pl+l, fl);
out(f, prefix, pl);
- pad(f, '0', w, pl+l, fl^ZERO_PAD);
+ pad(f, '0', 0, pl+l, fl^ZERO_PAD);
out(f, buf, s-buf);
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, pl+l);
+ pad(f, ' ', 0, pl+l, fl^LEFT_ADJ);
+ return pl+l;
}
if (p<0) p=6;
@@ -287,9 +287,9 @@ fmt_fp(struct fmt_args *f, long double y, int w, int p, uint8_t fl, int t)
l += ebuf-estr;
}
- pad(f, ' ', w, pl+l, fl);
+ pad(f, ' ', 0, pl+l, fl);
out(f, prefix, pl);
- pad(f, '0', w, pl+l, fl^ZERO_PAD);
+ pad(f, '0', 0, pl+l, fl^ZERO_PAD);
if ((t|32)=='f') {
if (a>r) a=r;
@@ -318,15 +318,15 @@ fmt_fp(struct fmt_args *f, long double y, int w, int p, uint8_t fl, int t)
if (p>0||(fl&ALT_FORM)) out(f, ".", 1);
}
out(f, ss, MIN(buf+9-ss, p));
- p -= buf+9-ss;
+ p -= (int)(buf+9-ss);
}
pad(f, '0', p+18, 18, 0);
out(f, estr, ebuf-estr);
}
- pad(f, ' ', w, pl+l, fl^LEFT_ADJ);
+ pad(f, ' ', 0, pl+l, fl^LEFT_ADJ);
- return MAX(w, pl+l);
+ return pl+l;
}
static int
@@ -352,7 +352,7 @@ fmt_core(struct fmt_args *f, const char *fmt, mrb_float flo)
switch (*fmt) {
case 'e': case 'f': case 'g': case 'a':
case 'E': case 'F': case 'G': case 'A':
- return fmt_fp(f, flo, 0, p, 0, *fmt);
+ return fmt_fp(f, flo, p, 0, *fmt);
default:
return -1;
}