move simple_itoa to libbb so that others can use it
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
9640c2b4a5
commit
8e8c61e786
|
@ -121,6 +121,7 @@
|
|||
#include <libbb.h>
|
||||
#include <glob.h>
|
||||
#include <getopt.h>
|
||||
#include <libbb.h>
|
||||
#include <linux/list.h>
|
||||
|
||||
/*cmd_boot.c*/
|
||||
|
@ -361,20 +362,6 @@ static int b_addqchr(o_string *o, int ch, int quote)
|
|||
return b_addchr(o, ch);
|
||||
}
|
||||
|
||||
/* belongs in utility.c */
|
||||
static char *simple_itoa(unsigned int i)
|
||||
{
|
||||
/* 21 digits plus null terminator, good for 64-bit or smaller ints */
|
||||
static char local[22];
|
||||
char *p = &local[21];
|
||||
*p-- = '\0';
|
||||
do {
|
||||
*p-- = '0' + i % 10;
|
||||
i /= 10;
|
||||
} while (i > 0);
|
||||
return p + 1;
|
||||
}
|
||||
|
||||
static int b_adduint(o_string *o, unsigned int i)
|
||||
{
|
||||
int r;
|
||||
|
|
|
@ -30,4 +30,6 @@ int copy_file(const char *src, const char *dst);
|
|||
|
||||
int process_escape_sequence(const char *source, char *dest, int destlen);
|
||||
|
||||
char *simple_itoa(unsigned int i);
|
||||
|
||||
#endif /* __LIBBB_H */
|
||||
|
|
13
lib/libbb.c
13
lib/libbb.c
|
@ -114,3 +114,16 @@ char * safe_strncpy(char *dst, const char *src, size_t size)
|
|||
}
|
||||
EXPORT_SYMBOL(safe_strncpy);
|
||||
|
||||
char *simple_itoa(unsigned int i)
|
||||
{
|
||||
/* 21 digits plus null terminator, good for 64-bit or smaller ints */
|
||||
static char local[22];
|
||||
char *p = &local[21];
|
||||
*p-- = '\0';
|
||||
do {
|
||||
*p-- = '0' + i % 10;
|
||||
i /= 10;
|
||||
} while (i > 0);
|
||||
return p + 1;
|
||||
}
|
||||
EXPORT_SYMBOL(simple_itoa);
|
||||
|
|
Loading…
Reference in New Issue