1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* sprintf.c (rb_str_format): make %u behave like %d for negative

values, since decimal format does not work with preceding dots.
  [ruby-core:11575]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2007-07-16 16:58:58 +00:00
parent bc8724d05f
commit 4d16ce7da4
2 changed files with 9 additions and 9 deletions

View file

@ -3,6 +3,12 @@ Mon Jul 16 23:07:51 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/base64.rb (Base64::b64encode): should not specify /o option
for regular expression. [ruby-dev:31221]
Mon Jul 16 22:57:53 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* sprintf.c (rb_str_format): make %u behave like %d for negative
values, since decimal format does not work with preceding dots.
[ruby-core:11575]
Mon Jul 16 18:29:33 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (rb_str_rindex_m): accept string-like object convertible

View file

@ -491,14 +491,13 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
switch (*p) {
case 'd':
case 'i':
case 'u':
sign = 1; break;
case 'o':
case 'x':
case 'X':
case 'b':
case 'B':
case 'u':
default:
if (flags&(FPLUS|FSPACE)) sign = 1;
break;
}
@ -584,13 +583,8 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
else {
s = nbuf;
if (v < 0) {
if (base == 10) {
rb_warning("negative number for %%u specifier");
}
else if (!(flags&(FPREC|FZERO))) {
strcpy(s, "..");
s += 2;
}
strcpy(s, "..");
s += 2;
}
sprintf(fbuf, "%%l%c", *p == 'X' ? 'x' : *p);
sprintf(s, fbuf, v);