summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/common/sprintf.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/firmware/common/sprintf.c b/firmware/common/sprintf.c
index 79db758a4b..bbd4db5bb4 100644
--- a/firmware/common/sprintf.c
+++ b/firmware/common/sprintf.c
@@ -42,7 +42,7 @@ static int format(
42{ 42{
43 char *str; 43 char *str;
44 char tmpbuf[12], pad; 44 char tmpbuf[12], pad;
45 int ch, width, val, sign; 45 int ch, width, val, sign, precision;
46 long lval, lsign; 46 long lval, lsign;
47 unsigned int uval; 47 unsigned int uval;
48 unsigned long ulval; 48 unsigned long ulval;
@@ -65,6 +65,17 @@ static int format(
65 width = 10*width + ch - '0'; 65 width = 10*width + ch - '0';
66 ch = *fmt++; 66 ch = *fmt++;
67 } 67 }
68
69 precision = 0;
70 if(ch == '.')
71 {
72 ch = *fmt++;
73 while (ch >= '0' && ch <= '9')
74 {
75 precision = 10*precision + ch - '0';
76 ch = *fmt++;
77 }
78 }
68 79
69 str = tmpbuf + sizeof tmpbuf - 1; 80 str = tmpbuf + sizeof tmpbuf - 1;
70 switch (ch) 81 switch (ch)
@@ -75,6 +86,8 @@ static int format(
75 86
76 case 's': 87 case 's':
77 str = va_arg (ap, char*); 88 str = va_arg (ap, char*);
89 if(precision > 0)
90 str[precision] = '\0';
78 break; 91 break;
79 92
80 case 'd': 93 case 'd':