[Fwd: Re: [BusyBox] busybox-1.00-pre2 printf feature ?]

John Traill john.traill at motorola.com
Thu Aug 7 15:51:50 UTC 2003


Erik,

Could you comment on the changes from strtol(..., 0) to strtol(...,10) ?


It appears to have broken printf functionality - ie "printf %d 0x12" 
returns 0x120.

-------- Original Message --------
Subject: 	Re: [BusyBox] busybox-1.00-pre2 printf feature ?
Date: 	Thu, 07 Aug 2003 18:06:26 +0400
From: 	Vladimir N. Oleynik <dzo at simtreas.ru>
Organization: 	Ulyanovsk Treasury
To: 	John Traill<John.Traill at motorola.com>, Manuel Nova 
III<mjn3 at codepoet.org>
References: 	<3F30F056.5010205 at motorola.com> 
<3F30F765.1000108 at simtreas.ru> <3F31278F.7080502 at motorola.com> 
<3F31328D.8090204 at simtreas.ru> <3F3238A4.1080605 at simtreas.ru> 
<3F323AE9.2020508 at motorola.com> <3F324AA2.609 at simtreas.ru> 
<3F325955.5030204 at motorola.com>



John,

> # ./test
> 18=0x12
> 
> That works but I think I've discovered what the problem is - tracing 
> through a command line of "printf %d 0x12"  in coreutils/printf.c 
> eventually calls xstrtol(argument) which falls through to "result = 
> strtoul(arg, &endptr, 10);"

O may God. I have busybox-0.61pre version. But Erik change May 26 this from
strtol(..., 0) to strtol(...,10).
Heh. Please ask his.

--w
vodz


> The error would appear to  caused by the assumption that the input is 
> base 10.
> 
> Comments ?
> 
> 
> 
> Vladimir N. Oleynik wrote:
> 
>> John,
>>
>>> You beat me to it - I was just typing a similar mail to uClibc but 
>>> reporting an error with powerpc.
>>
>>
>>
>>>> #include <stdlib.h>
>>>>
>>>> int main(void)
>>>> {
>>>>         const char *p = "1";
>>>>         int i;
>>>>
>>>>         i = atoi(p);
>>>>         return printf("%s=%d\n", i, p);
>>>> }
>>>
>>>
>>
>> OOPS! OOPS! must "%d=%s" ...
>>
>> if change to this test:
>>
>> #include <stdlib.h>
>>
>> int main(void)
>> {
>>          const char *p = "0x12";
>>     char *e;
>>          int i;
>>
>>          i = strtol(p, &e, 0);
>>          return printf("%d=%s%s\n", i, p, e);
>> }
>>
>> you have result 0x120 or 18?


-- 

Regards, John

 





More information about the busybox mailing list