mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* sprintf.c (rb_str_format): prepend ".." to %u for negative bignum,
but not "-". fixed: [ruby-core:08167] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
69be57eb57
commit
79c5eb1af3
2 changed files with 21 additions and 18 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Wed Jul 26 17:28:16 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* sprintf.c (rb_str_format): prepend ".." to %u for negative bignum,
|
||||||
|
but not "-". fixed: [ruby-core:08167]
|
||||||
|
|
||||||
Wed Jul 26 16:39:07 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Wed Jul 26 16:39:07 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* string.c (rb_str_scan): add string modification check.
|
* string.c (rb_str_scan): add string modification check.
|
||||||
|
|
34
sprintf.c
34
sprintf.c
|
@ -625,25 +625,23 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
|
||||||
if (base == 10) {
|
if (base == 10) {
|
||||||
rb_warning("negative number for %%u specifier");
|
rb_warning("negative number for %%u specifier");
|
||||||
}
|
}
|
||||||
else {
|
remove_sign_bits(++s, base);
|
||||||
remove_sign_bits(++s, base);
|
tmp = rb_str_new(0, 3+strlen(s));
|
||||||
tmp = rb_str_new(0, 3+strlen(s));
|
t = RSTRING(tmp)->ptr;
|
||||||
t = RSTRING(tmp)->ptr;
|
if (!(flags&(FPREC|FZERO))) {
|
||||||
if (!(flags&(FPREC|FZERO))) {
|
strcpy(t, "..");
|
||||||
strcpy(t, "..");
|
t += 2;
|
||||||
t += 2;
|
|
||||||
}
|
|
||||||
switch (base) {
|
|
||||||
case 16:
|
|
||||||
if (s[0] != 'f') strcpy(t++, "f"); break;
|
|
||||||
case 8:
|
|
||||||
if (s[0] != '7') strcpy(t++, "7"); break;
|
|
||||||
case 2:
|
|
||||||
if (s[0] != '1') strcpy(t++, "1"); break;
|
|
||||||
}
|
|
||||||
strcpy(t, s);
|
|
||||||
s = RSTRING(tmp)->ptr;
|
|
||||||
}
|
}
|
||||||
|
switch (base) {
|
||||||
|
case 16:
|
||||||
|
if (s[0] != 'f') strcpy(t++, "f"); break;
|
||||||
|
case 8:
|
||||||
|
if (s[0] != '7') strcpy(t++, "7"); break;
|
||||||
|
case 2:
|
||||||
|
if (s[0] != '1') strcpy(t++, "1"); break;
|
||||||
|
}
|
||||||
|
strcpy(t, s);
|
||||||
|
s = RSTRING(tmp)->ptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue