aboutsummaryrefslogtreecommitdiff
path: root/libbb/xfuncs.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-03-27 22:01:31 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-03-27 22:01:31 +0000
commit10457b90db925369739a900445b640364eda5e4c (patch)
tree6d6f18564291257738360d97712724868175167e /libbb/xfuncs.c
parentf4d40c87d3a18fccb8c0946fc09f1d8f24a2bcf3 (diff)
downloadbusybox-w32-10457b90db925369739a900445b640364eda5e4c.tar.gz
busybox-w32-10457b90db925369739a900445b640364eda5e4c.tar.bz2
busybox-w32-10457b90db925369739a900445b640364eda5e4c.zip
make pidfile writing configurable.
[ui]toa_to_buf: change API. No users yet.
Diffstat (limited to 'libbb/xfuncs.c')
-rw-r--r--libbb/xfuncs.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c
index 7f870ac8b..e1632a4b6 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -257,7 +257,7 @@ void smart_ulltoa5(unsigned long long ul, char buf[5])
257// truncated result is always null terminated (unless buflen is 0), and 257// truncated result is always null terminated (unless buflen is 0), and
258// contains the first few digits of the result ala strncpy. 258// contains the first few digits of the result ala strncpy.
259void BUG_sizeof_unsigned_not_4(void); 259void BUG_sizeof_unsigned_not_4(void);
260void utoa_to_buf(unsigned n, char *buf, unsigned buflen) 260char *utoa_to_buf(unsigned n, char *buf, unsigned buflen)
261{ 261{
262 unsigned i, out, res; 262 unsigned i, out, res;
263 if (sizeof(unsigned) != 4) 263 if (sizeof(unsigned) != 4)
@@ -273,19 +273,19 @@ void utoa_to_buf(unsigned n, char *buf, unsigned buflen)
273 *buf++ = '0' + res; 273 *buf++ = '0' + res;
274 } 274 }
275 } 275 }
276 *buf = '\0';
277 } 276 }
277 return buf;
278} 278}
279 279
280// Convert signed integer to ascii, like utoa_to_buf() 280// Convert signed integer to ascii, like utoa_to_buf()
281void itoa_to_buf(int n, char *buf, unsigned buflen) 281char *itoa_to_buf(int n, char *buf, unsigned buflen)
282{ 282{
283 if (buflen && n<0) { 283 if (buflen && n<0) {
284 n = -n; 284 n = -n;
285 *buf++ = '-'; 285 *buf++ = '-';
286 buflen--; 286 buflen--;
287 } 287 }
288 utoa_to_buf((unsigned)n, buf, buflen); 288 return utoa_to_buf((unsigned)n, buf, buflen);
289} 289}
290 290
291// The following two functions use a static buffer, so calling either one a 291// The following two functions use a static buffer, so calling either one a
@@ -300,7 +300,7 @@ static char local_buf[12];
300// Convert unsigned integer to ascii using a static buffer (returned). 300// Convert unsigned integer to ascii using a static buffer (returned).
301char *utoa(unsigned n) 301char *utoa(unsigned n)
302{ 302{
303 utoa_to_buf(n, local_buf, sizeof(local_buf)); 303 *(utoa_to_buf(n, local_buf, sizeof(local_buf))) = '\0';
304 304
305 return local_buf; 305 return local_buf;
306} 306}
@@ -308,7 +308,7 @@ char *utoa(unsigned n)
308// Convert signed integer to ascii using a static buffer (returned). 308// Convert signed integer to ascii using a static buffer (returned).
309char *itoa(int n) 309char *itoa(int n)
310{ 310{
311 itoa_to_buf(n, local_buf, sizeof(local_buf)); 311 *(itoa_to_buf(n, local_buf, sizeof(local_buf))) = '\0';
312 312
313 return local_buf; 313 return local_buf;
314} 314}