Re: integer to string conversion

Felix von Leitner <[email protected]>
Newsgroups gmane.linux.lib.dietlibc
Message-ID <[email protected]>
Thus spake Richard Wossal ([email protected]):

> I was going to ask you about your opinion whether or not
> the non-standard itoa-family of functions have a place in
> dietlibc, when I discovered that the dietlibc features
> __ltostr (and derivates). I've never seen that before,
> Internet says they come from HP-UX.

Uh, we invented that interface ourselves. It's not for public
consumption.  The official way to do it is to use sprintf, which sucks,
obviously.

So my recommendation is to use fmt_* from libowfat
(www.fefe.de/libowfat/)

> Now what I would like is a function family in the
> dietlibc that looks like the following:
>         int itoa(int n, char *buf, int base)
> returning the length of n in characters.

> Do you think, a libc is the right place for those?
> After all, they are not "less standard" than the
> __ltostr functions, are they?
> And (on a side note), why doesn't embutils use
> __ltostr?

__ltostr is not portable at all, it's only an internal function used by
sprintf in dietlibc.  Do not use it, even if you checked for it's
existance!

As a rule of thumb: if the function name starts with __, stay away from
it :-)

A function like that does not belong in libc, because there is a
standard that says what libc should export.  Actually, there is more
than one.  But it's standardized.  What good is standardization if you
ignore it and add stuff?

Felix
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.