mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
merge revision(s) 58210: [Backport #8916]
vsnprintf.c: prefix with precision * vsnprintf.c (BSD_vfprintf): sign and hex-prefix should not be counted in precision. [ruby-dev:47714] [Bug #8916] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@59299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c54593eddb
commit
f5b840074d
3 changed files with 6 additions and 10 deletions
|
@ -582,7 +582,7 @@ rb_strftime_with_timespec(VALUE ftime, const char *format, size_t format_len,
|
||||||
goto unknown;
|
goto unknown;
|
||||||
}
|
}
|
||||||
i = snprintf(s, endp - s, (padding == ' ' ? "%+*ld" : "%+.*ld"),
|
i = snprintf(s, endp - s, (padding == ' ' ? "%+*ld" : "%+.*ld"),
|
||||||
precision + 1, sign * (off / 3600));
|
precision + (padding == ' '), sign * (off / 3600));
|
||||||
if (i < 0) goto err;
|
if (i < 0) goto err;
|
||||||
if (sign < 0 && off < 3600) {
|
if (sign < 0 && off < 3600) {
|
||||||
*(padding == ' ' ? s + i - 2 : s) = '-';
|
*(padding == ' ' ? s + i - 2 : s) = '-';
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#define RUBY_VERSION "2.4.2"
|
#define RUBY_VERSION "2.4.2"
|
||||||
#define RUBY_RELEASE_DATE "2017-07-10"
|
#define RUBY_RELEASE_DATE "2017-07-10"
|
||||||
#define RUBY_PATCHLEVEL 139
|
#define RUBY_PATCHLEVEL 140
|
||||||
|
|
||||||
#define RUBY_RELEASE_YEAR 2017
|
#define RUBY_RELEASE_YEAR 2017
|
||||||
#define RUBY_RELEASE_MONTH 7
|
#define RUBY_RELEASE_MONTH 7
|
||||||
|
|
12
vsnprintf.c
12
vsnprintf.c
|
@ -1119,11 +1119,11 @@ number: if ((dprec = prec) >= 0)
|
||||||
*/
|
*/
|
||||||
fieldsz = size;
|
fieldsz = size;
|
||||||
long_len:
|
long_len:
|
||||||
if (sign)
|
|
||||||
fieldsz++;
|
|
||||||
if (flags & HEXPREFIX)
|
|
||||||
fieldsz += 2;
|
|
||||||
realsz = dprec > fieldsz ? dprec : fieldsz;
|
realsz = dprec > fieldsz ? dprec : fieldsz;
|
||||||
|
if (sign)
|
||||||
|
realsz++;
|
||||||
|
if (flags & HEXPREFIX)
|
||||||
|
realsz += 2;
|
||||||
|
|
||||||
/* right-adjusting blank padding */
|
/* right-adjusting blank padding */
|
||||||
if ((flags & (LADJUST|ZEROPAD)) == 0)
|
if ((flags & (LADJUST|ZEROPAD)) == 0)
|
||||||
|
@ -1145,10 +1145,6 @@ long_len:
|
||||||
|
|
||||||
/* leading zeroes from decimal precision */
|
/* leading zeroes from decimal precision */
|
||||||
PAD_L(dprec - fieldsz, zeroes);
|
PAD_L(dprec - fieldsz, zeroes);
|
||||||
if (sign)
|
|
||||||
fieldsz--;
|
|
||||||
if (flags & HEXPREFIX)
|
|
||||||
fieldsz -= 2;
|
|
||||||
|
|
||||||
/* the string or number proper */
|
/* the string or number proper */
|
||||||
#ifdef FLOATING_POINT
|
#ifdef FLOATING_POINT
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue