Skip to content

Commit

Permalink
binary format no longer need to preserve org_v
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Nov 19, 2015
1 parent 996417c commit f974880
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions mrbgems/mruby-sprintf/src/sprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ mrb_str_format(mrb_state *mrb, int argc, const mrb_value *argv, mrb_value fmt)
const char *prefix = NULL;
int sign = 0, dots = 0;
char sc = 0;
mrb_int v = 0, org_v = 0;
mrb_int v = 0;
int base;
mrb_int len;

Expand Down Expand Up @@ -827,7 +827,6 @@ mrb_str_format(mrb_state *mrb, int argc, const mrb_value *argv, mrb_value fmt)
}

if (base == 2) {
org_v = v;
if (v < 0 && !sign) {
val = mrb_fix2binstr(mrb, mrb_fixnum_value(v), base);
dots = 1;
Expand Down Expand Up @@ -964,7 +963,7 @@ mrb_str_format(mrb_state *mrb, int argc, const mrb_value *argv, mrb_value fmt)
CHECK(prec - len);
if (dots) PUSH("..", 2);

if (v < 0 || (base == 2 && org_v < 0)) {
if (v < 0) {
char c = sign_bits(base, p);
while (len < prec--) {
buf[blen++] = c;
Expand Down

0 comments on commit f974880

Please sign in to comment.