22
22
#include <stdint.h>
23
23
#include <stddef.h>
24
24
25
- /***************************/
26
- /* MBED */
27
- /***************************/
28
- #if TARGET_LIKE_MBED
29
-
30
- #if MBED_CONF_PLATFORM_STDIO_CONVERT_NEWLINES
31
- static char mbed_stdio_out_prev = 0 ;
32
- #endif
33
-
34
-
35
- /***************************/
36
- /* Linux */
37
- /***************************/
38
- #else
25
+ #if !TARGET_LIKE_MBED
39
26
/* Linux implementation is for debug only */
40
27
#define MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_FLOATING_POINT 1
41
28
#define MBED_CONF_PLATFORM_MINIMAL_PRINTF_SET_FLOATING_POINT_MAX_DECIMALS 6
@@ -106,7 +93,6 @@ static void mbed_minimal_formatted_string_signed(char *buffer, size_t length, in
106
93
static void mbed_minimal_formatted_string_unsigned (char * buffer , size_t length , int * result , MBED_UNSIGNED_STORAGE value , FILE * stream );
107
94
static void mbed_minimal_formatted_string_hexadecimal (char * buffer , size_t length , int * result , MBED_UNSIGNED_STORAGE value , FILE * stream , bool upper );
108
95
static void mbed_minimal_formatted_string_void_pointer (char * buffer , size_t length , int * result , const void * value , FILE * stream );
109
- static void mbed_minimal_formatted_string_character (char * buffer , size_t length , int * result , char character , FILE * stream );
110
96
static void mbed_minimal_formatted_string_string (char * buffer , size_t length , int * result , const char * string , size_t precision , FILE * stream );
111
97
112
98
@@ -282,7 +268,7 @@ static void mbed_minimal_formatted_string_double(char *buffer, size_t length, in
282
268
mbed_minimal_formatted_string_signed (buffer , length , result , integer , stream );
283
269
284
270
/* write decimal point */
285
- mbed_minimal_formatted_string_character (buffer , length , result , '.' , stream );
271
+ mbed_minimal_putchar (buffer , length , result , '.' , stream );
286
272
287
273
/* get decimal part */
288
274
double precision = 1.0 ;
@@ -327,33 +313,6 @@ static void mbed_minimal_formatted_string_double(char *buffer, size_t length, in
327
313
}
328
314
#endif
329
315
330
- /**
331
- * @brief Print character.
332
- *
333
- * @param buffer The buffer to store output (NULL for stdout).
334
- * @param[in] length The length of the buffer.
335
- * @param result The current output location.
336
- * @param[in] value The character to be printed.
337
- */
338
- static void mbed_minimal_formatted_string_character (char * buffer , size_t length , int * result , char character , FILE * stream )
339
- {
340
- /* write character */
341
- if (buffer ) {
342
- mbed_minimal_putchar (buffer , length , result , character , stream );
343
- } else {
344
- /* convert \n to \r\n if enabled in platform configuration */
345
- #if MBED_CONF_PLATFORM_STDIO_CONVERT_NEWLINES
346
- if (character == '\n' && mbed_stdio_out_prev != '\r' ) {
347
- mbed_minimal_putchar (buffer , length , result , '\r' , stream );
348
- }
349
-
350
- /* cache character */
351
- mbed_stdio_out_prev = character ;
352
- #endif
353
- mbed_minimal_putchar (buffer , length , result , character , stream );
354
- }
355
- }
356
-
357
316
/**
358
317
* @brief Print string with precision.
359
318
*
@@ -513,7 +472,7 @@ int mbed_minimal_formatted_string(char *buffer, size_t length, const char *forma
513
472
#else
514
473
/* If 64 bit is not enabled, print %ll[di] rather than truncated value */
515
474
if (length_modifier == LENGTH_LL ) {
516
- mbed_minimal_formatted_string_character (buffer , length , & result , '%' , stream );
475
+ mbed_minimal_putchar (buffer , length , & result , '%' , stream );
517
476
if (next == '%' ) {
518
477
// Continue printing loop after `%`
519
478
index = next_index ;
@@ -572,7 +531,7 @@ int mbed_minimal_formatted_string(char *buffer, size_t length, const char *forma
572
531
#else
573
532
/* If 64 bit is not enabled, print %ll[uxX] rather than truncated value */
574
533
if (length_modifier == LENGTH_LL ) {
575
- mbed_minimal_formatted_string_character (buffer , length , & result , '%' , stream );
534
+ mbed_minimal_putchar (buffer , length , & result , '%' , stream );
576
535
if (next == '%' ) {
577
536
// Continue printing loop after `%`
578
537
index = next_index ;
@@ -638,7 +597,7 @@ int mbed_minimal_formatted_string(char *buffer, size_t length, const char *forma
638
597
char value = va_arg (arguments , MBED_SIGNED_NATIVE_TYPE );
639
598
index = next_index ;
640
599
641
- mbed_minimal_formatted_string_character (buffer , length , & result , value , stream );
600
+ mbed_minimal_putchar (buffer , length , & result , value , stream );
642
601
}
643
602
/* string */
644
603
else if (next == 's' ) {
@@ -655,7 +614,7 @@ int mbed_minimal_formatted_string(char *buffer, size_t length, const char *forma
655
614
mbed_minimal_formatted_string_void_pointer (buffer , length , & result , value , stream );
656
615
} else {
657
616
// Unrecognised, or `%%`. Print the `%` that led us in.
658
- mbed_minimal_formatted_string_character (buffer , length , & result , '%' , stream );
617
+ mbed_minimal_putchar (buffer , length , & result , '%' , stream );
659
618
if (next == '%' ) {
660
619
// Continue printing loop after `%%`
661
620
index = next_index ;
@@ -667,7 +626,7 @@ int mbed_minimal_formatted_string(char *buffer, size_t length, const char *forma
667
626
/* not a format specifier */
668
627
{
669
628
/* write normal character */
670
- mbed_minimal_formatted_string_character (buffer , length , & result , format [index ], stream );
629
+ mbed_minimal_putchar (buffer , length , & result , format [index ], stream );
671
630
}
672
631
}
673
632
0 commit comments