Skip to content

Commit 7297f37

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 7297f37

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

platform/source/minimal-printf/mbed_printf_implementation.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,10 @@ 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+
}
629+
else if (next == '%') {
630+
index = next_index;
631+
mbed_minimal_formatted_string_signed(buffer, length, &result, next, stream);
628632
} else {
629633
/* write all characters between format beginning and unrecognied modifier */
630634
while (index < next_index) {

0 commit comments

Comments
 (0)