removed special cases for formatting of lowest signed values due to Corrin' rationale; fixed formatting routines to handle formatting "0" values
git-svn-id: svn://anubis/hos/trunk@59 5b3e749e-e535-0410-8002-a9bb6afbdfca
This commit is contained in:
parent
c21caccb1f
commit
e70b1a5213
@ -205,12 +205,6 @@ void kputs_pad(const char * s, int width, char pad_char, bool pad_right)
|
||||
} /* extern "C" */
|
||||
|
||||
static void fmt_d2a(char * buf, int val)
|
||||
{
|
||||
if (val == INT_MIN)
|
||||
{
|
||||
strcpy(buf, "-2147483648");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (val < 0)
|
||||
{
|
||||
@ -219,7 +213,6 @@ static void fmt_d2a(char * buf, int val)
|
||||
}
|
||||
fmt_u2a(buf, (unsigned int) val);
|
||||
}
|
||||
}
|
||||
|
||||
static void fmt_u2a(char * buf, unsigned int val)
|
||||
{
|
||||
@ -227,7 +220,7 @@ static void fmt_u2a(char * buf, unsigned int val)
|
||||
for (unsigned int div = 1000000000; div >= 1; div /= 10)
|
||||
{
|
||||
unsigned int n = val / div;
|
||||
if (n)
|
||||
if (n || div == 1)
|
||||
{
|
||||
printing = true;
|
||||
}
|
||||
@ -241,12 +234,6 @@ static void fmt_u2a(char * buf, unsigned int val)
|
||||
}
|
||||
|
||||
static void fmt_ll2a(char * buf, long long val)
|
||||
{
|
||||
if (val == LONG_LONG_MIN)
|
||||
{
|
||||
strcpy(buf, "-9223372036854775808");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (val < 0)
|
||||
{
|
||||
@ -255,7 +242,6 @@ static void fmt_ll2a(char * buf, long long val)
|
||||
}
|
||||
fmt_ull2a(buf, (unsigned long long) val);
|
||||
}
|
||||
}
|
||||
|
||||
static void fmt_ull2a(char * buf, unsigned long long val)
|
||||
{
|
||||
@ -263,7 +249,7 @@ static void fmt_ull2a(char * buf, unsigned long long val)
|
||||
for (unsigned long long div = 10000000000000000000ull; div >= 1; div /= 10)
|
||||
{
|
||||
unsigned long long n = val / div;
|
||||
if (n)
|
||||
if (n || div == 1)
|
||||
{
|
||||
printing = true;
|
||||
}
|
||||
@ -282,7 +268,7 @@ static void fmt_x2a(char * buf, unsigned int val)
|
||||
for (int s = 28; s >= 0; s -= 4)
|
||||
{
|
||||
unsigned int n = (val >> s) & 0xF;
|
||||
if (n)
|
||||
if (n || s == 0)
|
||||
{
|
||||
printing = true;
|
||||
}
|
||||
@ -296,13 +282,11 @@ static void fmt_x2a(char * buf, unsigned int val)
|
||||
|
||||
static void fmt_xl2a(char * buf, unsigned long long val)
|
||||
{
|
||||
fmt_x2a(buf, val >> 32);
|
||||
buf += strlen(buf);
|
||||
bool printing = ( (val >> 32) != 0 );
|
||||
for (int s = 28; s >= 0; s -= 4)
|
||||
bool printing = false;
|
||||
for (int s = 60; s >= 0; s -= 4)
|
||||
{
|
||||
unsigned int n = (val >> s) & 0xF;
|
||||
if (n)
|
||||
if (n || s == 0)
|
||||
{
|
||||
printing = true;
|
||||
}
|
||||
@ -320,7 +304,7 @@ static void fmt_o2a(char * buf, unsigned int val)
|
||||
for (int s = 30; s >= 0; s -= 3)
|
||||
{
|
||||
unsigned int n = (val >> s) & 0x7;
|
||||
if (n)
|
||||
if (n || s == 0)
|
||||
{
|
||||
printing = true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user