Hans-Juergen Taenzer wrote:

hello,

doing some tests with the new version, I have encountered a problem:

void testva(void)
{
   char *s;
   unsigned long ul1 = 0x7FFFFFFF;
   unsigned long ul2 = 0xFFFFFFFF;

   s = sqlite3_mprintf("%lu", ul1);
   printf("ul1: %lx, %s\n", ul1, s);

   s = sqlite3_mprintf("%lu", ul2);
   printf("ul2: %lx, %s\n", ul2, s);

   printf("sizeof(unsigned long): %u\n", sizeof(unsigned long));
}

Output is:

ul1: 7fffffff, 2147483647
ul2: ffffffff, 18446744073709551615
sizeof(unsigned long): 4

Is this the expected behavior? Compiler is MSVC 6.

Hans-Jürgen



Perhaps if the two lines of code starting at 349 in printf.c were changed from:
else if( flag_long ) longvalue = va_arg(ap,long int);
else longvalue = va_arg(ap,int);
to somthing like:
else if( flag_long )
{
if (infop->flags & FLAG_SIGNED)
longvalue = va_arg(ap,long int);
else
longvalue = va_arg(ap,unsigned long int);
}
else
{
if (infop->flags & FLAG_SIGNED)
longvalue = va_arg(ap,int);
else
longvalue = va_arg(ap,unsigned int);
}


You would get what you expect for %lu and %u?

ul1: 7fffffff, 2147483647
ul2: ffffffff, 4294967295

Regards,
Julian.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to