2003-10-18 Theodore A. Roth [Fix for Bug #5976] * doc/api/faq.dox: Use pgm_read_byte() instead of __lpm_inline() in the debug_P() example. * include/stdlib.h (itoa): Add note and warning about minimal buffer size to dox. (ltoa): Ditto. (utoa): Ditto. (ultoa): Ditto. Index: doc/api/faq.dox =================================================================== RCS file: /cvsroot/avr-libc/avr-libc/doc/api/faq.dox,v retrieving revision 1.28 diff -u -p -r1.28 faq.dox --- doc/api/faq.dox 17 Sep 2003 18:02:58 -0000 1.28 +++ doc/api/faq.dox 18 Oct 2003 20:11:47 -0000 @@ -980,7 +980,7 @@ debug_P(const char *addr) { char c; - while ((c = __lpm_inline((unsigned short)addr++))) + while ((c = pgm_read_byte(addr++))) uart_putchar(c); } Index: include/stdlib.h =================================================================== RCS file: /cvsroot/avr-libc/avr-libc/include/stdlib.h,v retrieving revision 1.15 diff -u -p -r1.15 stdlib.h --- include/stdlib.h 30 Sep 2003 23:05:17 -0000 1.15 +++ include/stdlib.h 18 Oct 2003 20:11:50 -0000 @@ -402,6 +402,14 @@ extern int rand_r(unsigned long *ctx); ASCII representation that will be stored under \c s. The caller is responsible for providing sufficient storage in \c s. + \note The minimal size of the buffer \c s depends on the choice of + radix. For example, if the radix is 2 (binary), you need to supply a buffer + with a minimal length of 8 * sizeof (int) + 1 characters, i.e. one + character for each bit plus one for the string terminator. Using a larger + radix will require a smaller minimal buffer size. + + \warning If the buffer is too small, you risk a buffer overflow. + Conversion is done using the \c radix as base, which may be a number between 2 (binary conversion) and up to 36. If \c radix is greater than 10, the next digit after \c '9' will be the letter @@ -422,6 +430,14 @@ extern char *itoa(int __val, char *__s, ASCII representation that will be stored under \c s. The caller is responsible for providing sufficient storage in \c s. + \note The minimal size of the buffer \c s depends on the choice of + radix. For example, if the radix is 2 (binary), you need to supply a buffer + with a minimal length of 8 * sizeof (long int) + 1 characters, i.e. one + character for each bit plus one for the string terminator. Using a larger + radix will require a smaller minimal buffer size. + + \warning If the buffer is too small, you risk a buffer overflow. + Conversion is done using the \c radix as base, which may be a number between 2 (binary conversion) and up to 36. If \c radix is greater than 10, the next digit after \c '9' will be the letter @@ -442,6 +458,14 @@ extern char *ltoa(long int __val, char * ASCII representation that will be stored under \c s. The caller is responsible for providing sufficient storage in \c s. + \note The minimal size of the buffer \c s depends on the choice of + radix. For example, if the radix is 2 (binary), you need to supply a buffer + with a minimal length of 8 * sizeof (unsigned int) + 1 characters, i.e. one + character for each bit plus one for the string terminator. Using a larger + radix will require a smaller minimal buffer size. + + \warning If the buffer is too small, you risk a buffer overflow. + Conversion is done using the \c radix as base, which may be a number between 2 (binary conversion) and up to 36. If \c radix is greater than 10, the next digit after \c '9' will be the letter @@ -459,6 +483,14 @@ extern char *utoa(unsigned int __val, ch \c val into an ASCII representation that will be stored under \c s. The caller is responsible for providing sufficient storage in \c s. + + \note The minimal size of the buffer \c s depends on the choice of + radix. For example, if the radix is 2 (binary), you need to supply a buffer + with a minimal length of 8 * sizeof (unsigned long int) + 1 characters, + i.e. one character for each bit plus one for the string terminator. Using a + larger radix will require a smaller minimal buffer size. + + \warning If the buffer is too small, you risk a buffer overflow. Conversion is done using the \c radix as base, which may be a number between 2 (binary conversion) and up to 36. If \c radix