Skip to content
Permalink
Browse files
binary format no longer need to preserve org_v
  • Loading branch information
matz committed Nov 19, 2015
1 parent 996417c commit f974880563e75be84631276875e88c79ff03a970
Showing 1 changed file with 2 additions and 3 deletions.
@@ -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;

@@ -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;
@@ -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;

0 comments on commit f974880

Please sign in to comment.