mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* sprintf.c (rb_str_format): fix for octal with precision.
[ruby-dev:33411] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ce26086b01
commit
7889fdd1e6
2 changed files with 22 additions and 8 deletions
|
@ -1,3 +1,8 @@
|
|||
Sun Jan 27 22:33:39 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* sprintf.c (rb_str_format): fix for octal with precision.
|
||||
[ruby-dev:33411]
|
||||
|
||||
Sun Jan 27 22:31:45 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* misc/ruby-mode.el (ruby-mode-set-encoding): automatically insert
|
||||
|
|
25
sprintf.c
25
sprintf.c
|
@ -535,9 +535,6 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
|
|||
case 'B':
|
||||
prefix = "0B"; break;
|
||||
}
|
||||
if (prefix) {
|
||||
width -= strlen(prefix);
|
||||
}
|
||||
}
|
||||
|
||||
bin_retry:
|
||||
|
@ -687,15 +684,27 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
|
|||
pp++;
|
||||
}
|
||||
}
|
||||
if (prefix && !prefix[1]) {
|
||||
if (dots) {
|
||||
prefix = 0;
|
||||
}
|
||||
else if (len == 1 && *s == '0') {
|
||||
if (flags & FPREC) len = 0;
|
||||
prefix = 0;
|
||||
}
|
||||
else if ((flags & FPREC) && (prec > len)) {
|
||||
prefix = 0;
|
||||
}
|
||||
}
|
||||
if (prefix) {
|
||||
width -= strlen(prefix);
|
||||
}
|
||||
if ((flags&(FZERO|FPREC)) == FZERO) {
|
||||
prec = width;
|
||||
width = 0;
|
||||
}
|
||||
else {
|
||||
if (prec < len) {
|
||||
if ((flags & FPREC) && len == 1 && *s == '0') len = 0;
|
||||
else prec = len;
|
||||
}
|
||||
if (prec < len) prec = len;
|
||||
width -= prec;
|
||||
}
|
||||
if (!(flags&FMINUS)) {
|
||||
|
@ -705,7 +714,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
|
|||
}
|
||||
}
|
||||
if (sc) PUSH(&sc, 1);
|
||||
if (prefix && (prefix[1] || !(dots || (len && s[0] == '0')))) {
|
||||
if (prefix) {
|
||||
int plen = strlen(prefix);
|
||||
PUSH(prefix, plen);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue