This is the mail archive of the mailing list for the newlib project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] itoa

On 12/08/2014 12:17 PM, Corinna Vinschen wrote:
Hi Jon,

On Dec  7 13:34, Jon Beniston wrote:

The attached patch adds support for the itoa and utoa functions, for
converting integers to strings.

This is a function that is supported on other platforms,
What other platforms?  It appears in K&R, base 10 only, and it appears
in a Unix manual from 1971(*), but I can't find it in GLibc nor one of
the BSDs.

The API is rather unsafe, given that the size of the buffer is not
checked (no size parameter).  But what I'm really missing are checks for
the base parameter being valid.  It could be > 36.  Or negative.
Microsoft Visual Studio has a "safe" variant which adds the buffer size:
errno_t _itoa_s(
   int value,
   char *buffer,
   size_t sizeInCharacters,
   int radix
(See, where they also have some other flavors of it. They do define an error return for base out of range.)

I see how this may be useful for embedded targets, but in a standard C
library, I'm not so sure about.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]