bonefish+mmlr:

Fix kernel printing of unsigned 64bit datatypes with the highest bit set. They
would previously be converted to a signed type and were then handled wrongly.
Use the sign flag to properly decide when to use casting to a singed type.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26473 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz
2008-07-17 19:26:09 +00:00
parent 87f9eb4682
commit 84717c2c61
+10 -7
View File
@@ -148,7 +148,7 @@ sign_symbol(int flags, bool negative)
static void
number(char **_string, int32 *_bytesLeft, int64 num, uint32 base, int size,
number(char **_string, int32 *_bytesLeft, uint64 num, uint32 base, int size,
int precision, int flags)
{
const char *digits = "0123456789abcdefghijklmnopqrstuvwxyz";
@@ -164,11 +164,14 @@ number(char **_string, int32 *_bytesLeft, int64 num, uint32 base, int size,
c = (flags & ZEROPAD) ? '0' : ' ';
sign = sign_symbol(flags, num < 0);
if (num < 0)
num = -num;
if (sign)
size--;
if (flags & SIGN) {
sign = sign_symbol(flags, (int64)num < 0);
if ((int64)num < 0)
num = -(int64)num;
if (sign)
size--;
} else
sign = 0;
if ((flags & SPECIAL) != 0) {
if (base == 16)
@@ -181,7 +184,7 @@ number(char **_string, int32 *_bytesLeft, int64 num, uint32 base, int size,
if (num == 0)
tmp[i++] = '0';
else while (num != 0)
tmp[i++] = digits[do_div((uint64 *)&num, base)];
tmp[i++] = digits[do_div(&num, base)];
if (i > precision)
precision = i;