diff toys/pending/syslogd.c @ 1042:cbc467592b2e draft

Remove itoa/utoa, let libc do this with sprintf.
author Rob Landley <rob@landley.net>
date Tue, 03 Sep 2013 08:30:47 -0500
parents 58bfd974216d
children e11684e3bbc5
line wrap: on
line diff
--- a/toys/pending/syslogd.c	Tue Sep 03 08:16:42 2013 -0500
+++ b/toys/pending/syslogd.c	Tue Sep 03 08:30:47 2013 -0500
@@ -84,11 +84,13 @@
 }
 
 //search the given name and return its value
-static char *dec(int val, CODE *clist)
+static char *dec(int val, CODE *clist, char *buf)
 {
   for (; clist->c_name; clist++) 
     if (val == clist->c_val) return clist->c_name;
-  return itoa(val);
+  sprintf(buf, "%u", val);
+
+  return buf;
 }
 
 /*
@@ -340,8 +342,10 @@
 
   if (toys.optflags & FLAG_K) len = sprintf(toybuf, "<%d> %s\n", pri, msg);
   else {
-    facstr = dec(pri & LOG_FACMASK, facilitynames);
-    lvlstr = dec(LOG_PRI(pri), prioritynames);
+    char facbuf[12], pribuf[12];
+
+    facstr = dec(pri & LOG_FACMASK, facilitynames, facbuf);
+    lvlstr = dec(LOG_PRI(pri), prioritynames, pribuf);
 
     p = "local";
     if (!uname(&uts)) p = uts.nodename;