Botched the case for n=0

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@40 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2007-03-06 21:35:03 +00:00
parent 4c61b4d89c
commit 282b5da0c3
+24 -9
View File
@@ -270,15 +270,15 @@ static void utodec(struct lib_stream_s *obj, unsigned int n)
static void utohex(struct lib_stream_s *obj, unsigned int n, ubyte a)
{
boolean nonleading = FALSE;
boolean nonzero = FALSE;
ubyte bits;
for (bits = 8*sizeof(unsigned int); bits > 0; bits -= 4)
{
ubyte nibble = (ubyte)((n >> (bits - 4)) & 0xf);
if (nibble || nonleading)
if (nibble || nonzero)
{
nonleading = TRUE;
nonzero = TRUE;
if (nibble < 10)
{
@@ -290,6 +290,11 @@ static void utohex(struct lib_stream_s *obj, unsigned int n, ubyte a)
}
}
}
if (!nonzero)
{
obj->put(obj, '0');
}
}
/************************************************************
@@ -518,15 +523,15 @@ static void lutodec(struct lib_stream_s *obj, unsigned long n)
static void lutohex(struct lib_stream_s *obj, unsigned long n, ubyte a)
{
boolean nonleading = FALSE;
boolean nonzero = FALSE;
ubyte bits;
for (bits = 8*sizeof(unsigned long); bits > 0; bits -= 4)
{
ubyte nibble = (ubyte)((n >> (bits - 4)) & 0xf);
if (nibble || nonleading)
if (nibble || nonzero)
{
nonleading = TRUE;
nonzero = TRUE;
if (nibble < 10)
{
@@ -538,6 +543,11 @@ static void lutohex(struct lib_stream_s *obj, unsigned long n, ubyte a)
}
}
}
if (!nonzero)
{
obj->put(obj, '0');
}
}
/************************************************************
@@ -763,15 +773,15 @@ static void llutodec(struct lib_stream_s *obj, unsigned long long n)
static void llutohex(struct lib_stream_s *obj, unsigned long long n, ubyte a)
{
boolean nonleading = FALSE;
boolean nonzero = FALSE;
ubyte bits;
for (bits = 8*sizeof(unsigned long long); bits > 0; bits -= 4)
{
ubyte nibble = (ubyte)((n >> (bits - 4)) & 0xf);
if (nibble || nonleading)
if (nibble || nonzero)
{
nonleading = TRUE;
nonzero = TRUE;
if (nibble < 10)
{
@@ -783,6 +793,11 @@ static void llutohex(struct lib_stream_s *obj, unsigned long long n, ubyte a)
}
}
}
if (!nonzero)
{
obj->put(obj, '0');
}
}
/************************************************************