Skip to content

Commit 1ebd043

Browse files
committed
minimal-printf: Fix handling of the two character sequence %%
The two character sequence %% is used in standard implementations of printf to print a single %. This is because % is essentially printf's escape character for format specifiers and as \% cannot work printf uses %%. Therefore to be compatible with string buffers containing %%, minimal-printf also needs to only print a single %.
1 parent 5d330bf commit 1ebd043

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

platform/source/minimal-printf/mbed_printf_implementation.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,9 @@ int mbed_minimal_formatted_string(char *buffer, size_t length, const char *forma
625625
index = next_index;
626626

627627
mbed_minimal_formatted_string_void_pointer(buffer, length, &result, value, stream);
628+
} else if (next == '%') {
629+
index = next_index;
630+
mbed_minimal_formatted_string_character(buffer, length, &result, next, stream);
628631
} else {
629632
/* write all characters between format beginning and unrecognied modifier */
630633
while (index < next_index) {

0 commit comments

Comments
 (0)