* 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:
nobu 2006-07-26 08:28:57 +00:00
Родитель 69be57eb57
Коммит 79c5eb1af3
2 изменённых файлов: 21 добавлений и 18 удалений

Просмотреть файл

@ -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>
* string.c (rb_str_scan): add string modification check.

Просмотреть файл

@ -625,25 +625,23 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
if (base == 10) {
rb_warning("negative number for %%u specifier");
}
else {
remove_sign_bits(++s, base);
tmp = rb_str_new(0, 3+strlen(s));
t = RSTRING(tmp)->ptr;
if (!(flags&(FPREC|FZERO))) {
strcpy(t, "..");
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;
remove_sign_bits(++s, base);
tmp = rb_str_new(0, 3+strlen(s));
t = RSTRING(tmp)->ptr;
if (!(flags&(FPREC|FZERO))) {
strcpy(t, "..");
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;
}
}
}