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 14
14
15
15
#include <stdint.h>
16
16
#include <stdio.h>
17
+ #include <string.h>
17
18
18
19
#include "sdkconfig.h"
19
20
@@ -62,6 +63,7 @@ int __attribute__ ((weak)) ets_putc(int c)
62
63
#define ALTERNATE 0x08
63
64
#define OUPUT_INT 0x10
64
65
#define START 0x20
66
+ #define END 0x40
65
67
66
68
#define VINT_STR_MAX 10
67
69
@@ -73,7 +75,7 @@ typedef union _val_cache {
73
75
} val_cache_t ;
74
76
75
77
typedef struct _val_attr {
76
- int8_t type ;
78
+ uint8_t type ;
77
79
uint8_t state ;
78
80
uint8_t fillbytes ;
79
81
uint8_t precision ;
@@ -182,23 +184,10 @@ int ets_vprintf(const char *fmt, va_list va)
182
184
183
185
fmt = ps ;
184
186
185
- attr .state = 0 ;
186
- attr .type = -1 ;
187
- attr .fillbytes = 0 ;
188
- attr .precision = 0 ;
187
+ memset (& attr , 0 , sizeof (val_attr_t ));
189
188
190
189
for (; ;) {
191
190
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 ;
202
191
case '#' :
203
192
attr .state |= ALTERNATE ;
204
193
ps ++ ;
@@ -220,14 +209,15 @@ int ets_vprintf(const char *fmt, va_list va)
220
209
attr .state |= FILL_LEFT ;
221
210
break ;
222
211
default :
223
- attr .type = -2 ;
212
+ attr .type = * ps ++ ;
213
+ attr .state |= END ;
224
214
break ;
225
215
}
226
216
227
- attr .state |= START ;
228
-
229
- if (attr .type != -1 )
217
+ if (attr .state & END )
230
218
break ;
219
+
220
+ attr .state |= START ;
231
221
}
232
222
233
223
switch (attr .type ) {
@@ -260,7 +250,13 @@ int ets_vprintf(const char *fmt, va_list va)
260
250
ets_printf_buf ("0x" , 2 );
261
251
attr .value .valcp = va_arg (va , const char * );
262
252
ets_printf_int (& attr , 16 );
253
+ break ;
254
+ case '%' :
255
+ ets_putc ('%' );
256
+ break ;
263
257
default :
258
+ ets_putc ('%' );
259
+ ps = fmt + 1 ;
264
260
break ;
265
261
}
266
262
You can’t perform that action at this time.
0 commit comments