mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* sprintf.c (rb_str_format): Fix a dynamic format string.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41248 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7fa5e608d3
commit
174e3fb6e4
2 changed files with 7 additions and 6 deletions
|
@ -1,3 +1,7 @@
|
|||
Wed Jun 12 12:07:04 2013 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* sprintf.c (rb_str_format): Fix a dynamic format string.
|
||||
|
||||
Wed Jun 12 12:04:09 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* array.c (rb_ary_uniq_bang): must not be modified once frozen even in
|
||||
|
|
|
@ -734,7 +734,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
|
|||
{
|
||||
volatile VALUE val = GETARG();
|
||||
int valsign;
|
||||
char fbuf[32], nbuf[64], *s;
|
||||
char nbuf[64], *s;
|
||||
const char *prefix = 0;
|
||||
int sign = 0, dots = 0;
|
||||
char sc = 0;
|
||||
|
@ -866,8 +866,6 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
|
|||
len = rb_long2int(RSTRING_END(tmp) - s);
|
||||
}
|
||||
else if (!bignum) {
|
||||
char c = *p;
|
||||
if (c == 'i') c = 'd'; /* %d and %i are identical */
|
||||
valsign = 1;
|
||||
if (v < 0) {
|
||||
v = -v;
|
||||
|
@ -883,13 +881,12 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
|
|||
sc = ' ';
|
||||
width--;
|
||||
}
|
||||
snprintf(fbuf, sizeof(fbuf), "%%l%c", c);
|
||||
snprintf(nbuf, sizeof(nbuf), fbuf, v);
|
||||
snprintf(nbuf, sizeof(nbuf), "%ld", v);
|
||||
s = nbuf;
|
||||
len = (int)strlen(s);
|
||||
}
|
||||
else {
|
||||
tmp = rb_big2str(val, base);
|
||||
tmp = rb_big2str(val, 10);
|
||||
s = RSTRING_PTR(tmp);
|
||||
valsign = 1;
|
||||
if (s[0] == '-') {
|
||||
|
|
Loading…
Reference in a new issue