File tree Expand file tree Collapse file tree 1 file changed +15
-19
lines changed
components/esp8266/source Expand file tree Collapse file tree 1 file changed +15
-19
lines changed Original file line number Diff line number Diff line change 1414
1515#include <stdint.h>
1616#include <stdio.h>
17+ #include <string.h>
1718
1819#include "sdkconfig.h"
1920
@@ -62,6 +63,7 @@ int __attribute__ ((weak)) ets_putc(int c)
6263#define ALTERNATE 0x08
6364#define OUPUT_INT 0x10
6465#define START 0x20
66+ #define END 0x40
6567
6668#define VINT_STR_MAX 10
6769
@@ -73,7 +75,7 @@ typedef union _val_cache {
7375} val_cache_t ;
7476
7577typedef struct _val_attr {
76- int8_t type ;
78+ uint8_t type ;
7779 uint8_t state ;
7880 uint8_t fillbytes ;
7981 uint8_t precision ;
@@ -182,23 +184,10 @@ int ets_vprintf(const char *fmt, va_list va)
182184
183185 fmt = ps ;
184186
185- attr .state = 0 ;
186- attr .type = -1 ;
187- attr .fillbytes = 0 ;
188- attr .precision = 0 ;
187+ memset (& attr , 0 , sizeof (val_attr_t ));
189188
190189 for (; ;) {
191190 switch (* ++ ps ) {
192- case 'd' :
193- case 'i' :
194- case 'u' :
195- case 'x' :
196- case 'c' :
197- case 's' :
198- case 'p' :
199- case '\0' :
200- attr .type = * ps ++ ;
201- break ;
202191 case '#' :
203192 attr .state |= ALTERNATE ;
204193 ps ++ ;
@@ -220,14 +209,15 @@ int ets_vprintf(const char *fmt, va_list va)
220209 attr .state |= FILL_LEFT ;
221210 break ;
222211 default :
223- attr .type = -2 ;
212+ attr .type = * ps ++ ;
213+ attr .state |= END ;
224214 break ;
225215 }
226216
227- attr .state |= START ;
228-
229- if (attr .type != -1 )
217+ if (attr .state & END )
230218 break ;
219+
220+ attr .state |= START ;
231221 }
232222
233223 switch (attr .type ) {
@@ -260,7 +250,13 @@ int ets_vprintf(const char *fmt, va_list va)
260250 ets_printf_buf ("0x" , 2 );
261251 attr .value .valcp = va_arg (va , const char * );
262252 ets_printf_int (& attr , 16 );
253+ break ;
254+ case '%' :
255+ ets_putc ('%' );
256+ break ;
263257 default :
258+ ets_putc ('%' );
259+ ps = fmt + 1 ;
264260 break ;
265261 }
266262
You can’t perform that action at this time.
0 commit comments