diff --git a/ChangeLog b/ChangeLog index 08eddc61ce..b1bf18997a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sun Jul 18 08:13:58 2004 Nobuyoshi Nakada + + * sprintf.c (rb_f_sprintf): remove extra sign digit. + Sun Jul 18 03:19:14 2004 Akinori MUSHA * dir.c (bracket): use NULL instead of 0. diff --git a/sprintf.c b/sprintf.c index 17bcce1330..1cb3c99d7c 100644 --- a/sprintf.c +++ b/sprintf.c @@ -25,31 +25,30 @@ remove_sign_bits(str, base) char *str; int base; { - char *s, *t, *end; - unsigned long len; + char *s, *t; s = t = str; - len = strlen(str); - end = str + len; if (base == 16) { - while (t s) { + while (*t) *s++ = *t++; + *s = '\0'; + } return str; } @@ -57,7 +56,7 @@ remove_sign_bits(str, base) static char sign_bits(base, p) int base; - char *p; + const char *p; { char c = '.'; @@ -234,7 +233,8 @@ rb_f_sprintf(argc, argv) VALUE *argv; { VALUE fmt; - char *buf, *p, *end; + const char *p, *end; + char *buf; int blen, bsiz; VALUE result; @@ -257,7 +257,7 @@ rb_f_sprintf(argc, argv) buf = RSTRING(result)->ptr; for (; p < end; p++) { - char *t; + const char *t; int n; for (t = p; t < end && *t != '%'; t++) ; @@ -549,7 +549,7 @@ rb_f_sprintf(argc, argv) s += 2; } } - sprintf(fbuf, "%%l%c", *p); + sprintf(fbuf, "%%l%c", *p == 'X' ? 'x' : *p); sprintf(s, fbuf, v); if (v < 0) { char d = 0;