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:
parent
bc8724d05f
commit
4d16ce7da4
2 changed files with 9 additions and 9 deletions
|
@ -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
|
||||
|
|
12
sprintf.c
12
sprintf.c
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue