Skip to content
Permalink
Browse files
mruby-sprintf:fix double negative signs in printf; fix #3148
MRB_INT_MAX does not have corresponding positive integer
  • Loading branch information
matz committed Apr 23, 2016
1 parent c522907 commit 8f0c1c7d3c44338ea8314e93e9f04fcfc71cb372
Showing 1 changed file with 9 additions and 12 deletions.
@@ -828,18 +828,15 @@ mrb_str_format(mrb_state *mrb, int argc, const mrb_value *argv, mrb_value fmt)
}
}
if (sign) {
if (v < 0) {
v = -v;
sc = '-';
width--;
}
else if (flags & FPLUS) {
sc = '+';
width--;
}
else if (flags & FSPACE) {
sc = ' ';
width--;
if (v > 0) {
if (flags & FPLUS) {
sc = '+';
width--;
}
else if (flags & FSPACE) {
sc = ' ';
width--;
}
}
switch (base) {
case 2:

0 comments on commit 8f0c1c7

Please sign in to comment.