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

* vsnprintf.c (BSD_vfprintf): use HEXPREFIX flag for prefix of %a.

[ruby-core:32841]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29531 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2010-10-18 18:08:58 +00:00
parent 81e40399fb
commit da55cfdf72
4 changed files with 21 additions and 8 deletions

View file

@ -1,3 +1,8 @@
Tue Oct 19 03:08:52 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* vsnprintf.c (BSD_vfprintf): use HEXPREFIX flag for prefix of %a.
[ruby-core:32841]
Mon Oct 18 13:18:01 2010 Akinori MUSHA <knu@iDaemons.org>
* ext/digest/digest.c (rb_digest_class_init): Define

View file

@ -211,6 +211,14 @@ class TestSprintf < Test::Unit::TestCase
assert_equal(" -0x1.2p+0", sprintf("%10a", -1.125))
assert_equal(" -0x1.1p+0", sprintf("%10a", -1.0625))
assert_equal("-0x1.08p+0", sprintf("%10a", -1.03125))
bug3962 = '[ruby-core:32841]'
assert_equal("-0x0001p+0", sprintf("%010a", -1), bug3962)
assert_equal("-0x01.8p+0", sprintf("%010a", -1.5), bug3962)
assert_equal("-0x01.4p+0", sprintf("%010a", -1.25), bug3962)
assert_equal("-0x01.2p+0", sprintf("%010a", -1.125), bug3962)
assert_equal("-0x01.1p+0", sprintf("%010a", -1.0625), bug3962)
assert_equal("-0x1.08p+0", sprintf("%010a", -1.03125), bug3962)
end
BSIZ = 120

View file

@ -1,11 +1,11 @@
#define RUBY_VERSION "1.9.3"
#define RUBY_RELEASE_DATE "2010-10-18"
#define RUBY_RELEASE_DATE "2010-10-19"
#define RUBY_PATCHLEVEL -1
#define RUBY_BRANCH_NAME "trunk"
#define RUBY_RELEASE_YEAR 2010
#define RUBY_RELEASE_MONTH 10
#define RUBY_RELEASE_DAY 18
#define RUBY_RELEASE_DAY 19
#include "ruby/version.h"

View file

@ -826,8 +826,10 @@ fp_begin: _double = va_arg(ap, double);
ch = 'g';
}
if (ch == 'a' || ch == 'A') {
flags |= HEXPREFIX;
--expt;
expsize = exponent(expstr, expt, ch + 'p' - 'a');
ch += 'x' - 'a';
size = expsize + ndig;
size += 2; /* 0x */
if (ndig > 1)
@ -1037,7 +1039,8 @@ long_len:
/* prefix */
if (sign) {
PRINT(&sign, 1);
} else if (flags & HEXPREFIX) {
}
if (flags & HEXPREFIX) {
ox[0] = '0';
ox[1] = ch;
PRINT(ox, 2);
@ -1051,7 +1054,7 @@ long_len:
PAD_L(dprec - fieldsz, zeroes);
if (sign)
fieldsz--;
else if (flags & HEXPREFIX)
if (flags & HEXPREFIX)
fieldsz -= 2;
/* the string or number proper */
@ -1059,10 +1062,7 @@ long_len:
if ((flags & FPT) == 0) {
PRINT(cp, fieldsz);
} else { /* glue together f_p fragments */
if (ch == 'a' || ch == 'A') {
ox[0] = '0';
ox[1] = ch + ('x' - 'a');
PRINT(ox, 2);
if (flags & HEXPREFIX) {
if (ndig > 1 || flags & ALT) {
ox[2] = *cp++;
ox[3] = '.';