aboutsummaryrefslogtreecommitdiff
path: root/shell/msh.c
diff options
context:
space:
mode:
Diffstat (limited to 'shell/msh.c')
-rw-r--r--shell/msh.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/shell/msh.c b/shell/msh.c
index 89c375380..41f4cc60d 100644
--- a/shell/msh.c
+++ b/shell/msh.c
@@ -50,36 +50,36 @@ static char *find_applet_by_name(const char *applet)
50} 50}
51static void utoa_to_buf(unsigned n, char *buf, unsigned buflen) 51static void utoa_to_buf(unsigned n, char *buf, unsigned buflen)
52{ 52{
53 unsigned i, out, res; 53 unsigned i, out, res;
54 assert(sizeof(unsigned) == 4); 54 assert(sizeof(unsigned) == 4);
55 if (buflen) { 55 if (buflen) {
56 out = 0; 56 out = 0;
57 for (i = 1000000000; i; i /= 10) { 57 for (i = 1000000000; i; i /= 10) {
58 res = n / i; 58 res = n / i;
59 if (res || out || i == 1) { 59 if (res || out || i == 1) {
60 if (!--buflen) break; 60 if (!--buflen) break;
61 out++; 61 out++;
62 n -= res*i; 62 n -= res*i;
63 *buf++ = '0' + res; 63 *buf++ = '0' + res;
64 } 64 }
65 } 65 }
66 *buf = '\0'; 66 *buf = '\0';
67 } 67 }
68} 68}
69static void itoa_to_buf(int n, char *buf, unsigned buflen) 69static void itoa_to_buf(int n, char *buf, unsigned buflen)
70{ 70{
71 if (buflen && n<0) { 71 if (buflen && n < 0) {
72 n = -n; 72 n = -n;
73 *buf++ = '-'; 73 *buf++ = '-';
74 buflen--; 74 buflen--;
75 } 75 }
76 utoa_to_buf((unsigned)n, buf, buflen); 76 utoa_to_buf((unsigned)n, buf, buflen);
77} 77}
78static char local_buf[12]; 78static char local_buf[12];
79static char *itoa(int n) 79static char *itoa(int n)
80{ 80{
81 itoa_to_buf(n, local_buf, sizeof(local_buf)); 81 itoa_to_buf(n, local_buf, sizeof(local_buf));
82 return local_buf; 82 return local_buf;
83} 83}
84#else 84#else
85# include <setjmp.h> 85# include <setjmp.h>