aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2013-09-03 08:30:47 -0500
committerRob Landley <rob@landley.net>2013-09-03 08:30:47 -0500
commitf538f420deffc242742ce2d0661a39fa9a3b5399 (patch)
tree25841579cf96612ab0f81e6d4738ac5da89ef7c4 /lib
parent79d8bc70539b7a3d459630c97e38d3cdff77e591 (diff)
downloadtoybox-f538f420deffc242742ce2d0661a39fa9a3b5399.tar.gz
Remove itoa/utoa, let libc do this with sprintf.
Diffstat (limited to 'lib')
-rw-r--r--lib/lib.c56
-rw-r--r--lib/lib.h4
2 files changed, 0 insertions, 60 deletions
diff --git a/lib/lib.c b/lib/lib.c
index 58670921..86e99ace 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -177,62 +177,6 @@ struct string_list *find_in_path(char *path, char *filename)
return rlist;
}
-// Convert unsigned int to ascii, writing into supplied buffer. A truncated
-// result contains the first few digits of the result ala strncpy, and is
-// always null terminated (unless buflen is 0).
-void utoa_to_buf(unsigned n, char *buf, unsigned buflen)
-{
- int i, out = 0;
-
- if (buflen) {
- for (i=1000000000; i; i/=10) {
- int res = n/i;
-
- if ((res || out || i == 1) && --buflen>0) {
- out++;
- n -= res*i;
- *buf++ = '0' + res;
- }
- }
- *buf = 0;
- }
-}
-
-// Convert signed integer to ascii, using utoa_to_buf()
-void itoa_to_buf(int n, char *buf, unsigned buflen)
-{
- if (buflen && n<0) {
- n = -n;
- *buf++ = '-';
- buflen--;
- }
- utoa_to_buf((unsigned)n, buf, buflen);
-}
-
-// This static buffer is used by both utoa() and itoa(), calling either one a
-// second time will overwrite the previous results.
-//
-// The longest 32 bit integer is -2 billion plus a null terminator: 12 bytes.
-// Note that int is always 32 bits on any remotely unix-like system, see
-// http://www.unix.org/whitepapers/64bit.html for details.
-
-static char itoa_buf[12];
-
-// Convert unsigned integer to ascii, returning a static buffer.
-char *utoa(unsigned n)
-{
- utoa_to_buf(n, itoa_buf, sizeof(itoa_buf));
-
- return itoa_buf;
-}
-
-char *itoa(int n)
-{
- itoa_to_buf(n, itoa_buf, sizeof(itoa_buf));
-
- return itoa_buf;
-}
-
// atol() with the kilo/mega/giga/tera/peta/exa extensions.
// (zetta and yotta don't fit in 64 bits.)
long atolx(char *numstr)
diff --git a/lib/lib.h b/lib/lib.h
index 2294a5bf..14e14e91 100644
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -140,10 +140,6 @@ void msleep(long miliseconds);
int64_t peek(void *ptr, int size);
void poke(void *ptr, uint64_t val, int size);
struct string_list *find_in_path(char *path, char *filename);
-void utoa_to_buf(unsigned n, char *buf, unsigned buflen);
-void itoa_to_buf(int n, char *buf, unsigned buflen);
-char *utoa(unsigned n);
-char *itoa(int n);
long atolx(char *c);
int numlen(long l);
int stridx(char *haystack, char needle);