[PATCH] unify itoa

Denis Vlasenko vda.linux at googlemail.com
Wed Jul 12 14:32:12 UTC 2006


On Tuesday 11 July 2006 21:42, Rob Landley wrote:
> > The version in current svn produces _most significant_ digits
> > if buffer is too small. IOW: utoa_to_buf_rob(100223,buf,3)=="10".
> > The usual practuce is to produce "23".
> 
> If the buffer is too small it essentially produces garbage, we just don't want 
> it to overflow and stomp memory it doesn't own.

Real-world example why we should do it:

printf("%02d:%02d\n", seconds/60, seconds);

Here user of sprintf deliberately uses the fact
that printf shows least significant digits,
not most significant ones.
--
vda



More information about the busybox mailing list