Added support for printing hex (heheh... doesn't work right, but better than nothing)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1628 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
fad8fe8cc8
commit
64444d7479
1 changed files with 47 additions and 0 deletions
|
@ -88,7 +88,54 @@ retry:
|
|||
*buffer++ = _int;
|
||||
tokens++;
|
||||
break;
|
||||
case 'x':
|
||||
_int = va_arg(vargs, int);
|
||||
if (_int < 0)
|
||||
{
|
||||
if (--maxlen < 0)
|
||||
{*buffer++='\0';return tokens;}
|
||||
*buffer++ = '-';
|
||||
_int *= -1;
|
||||
}
|
||||
i = sizeof(tempbuffer)-2;
|
||||
tempbuffer[sizeof(tempbuffer)-1] = '\0';
|
||||
while(_int)
|
||||
{
|
||||
tempbuffer[i] = _int%16 + '0';
|
||||
_int/=16;
|
||||
i--;
|
||||
}
|
||||
string = tempbuffer+i+1;
|
||||
|
||||
if (!*string)
|
||||
{
|
||||
i=61;
|
||||
string = tempbuffer+i+1;
|
||||
string[0] = '0';
|
||||
string[1] = '\0';
|
||||
}
|
||||
|
||||
precision -= 62-i;
|
||||
while (precision>0)
|
||||
{
|
||||
string--;
|
||||
if (use0s)
|
||||
*string = '0';
|
||||
else
|
||||
*string = ' ';
|
||||
precision--;
|
||||
}
|
||||
|
||||
while (*string)
|
||||
{
|
||||
if (--maxlen < 0)
|
||||
{*buffer++='\0';return tokens;}
|
||||
*buffer++ = *string++;
|
||||
}
|
||||
tokens++;
|
||||
break;
|
||||
case 'd':
|
||||
case 'u':
|
||||
case 'i':
|
||||
_int = va_arg(vargs, int);
|
||||
if (_int < 0)
|
||||
|
|
Loading…
Reference in a new issue