Skip to content

Commit

Permalink
Add romaric's suggestion back in
Browse files Browse the repository at this point in the history
Co-authored-by: Romaric Jodin <[email protected]>
  • Loading branch information
Rekt3421 and rjodinchr authored Oct 8, 2024
1 parent 9c25fbe commit 6d85e0c
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/printf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,14 @@ void process_printf(char*& data, const printf_descriptor_map_t& descs,
// Handle special cases
if (part_end == part_start + 1) {
printf_out << "%";
size_t next_format = format_string.find_first_of('%', part_end + 1);
// Check if there is anything to print between two %
if (next_format != std::string::npos &&
next_format - part_end > 1) {
// Print everything in between the two %
printf_out << format_string.substr(
part_end + 1, next_format - (part_end + 1));
next_part = next_format;
} else {
next_part = part_end + 1;
// We also need to print the literals between '%%' and the next '%'
next_part = part_start = part_end + 1;
part_end = format_string.find_first_of('%', part_start);
if (part_end != std::string::npos && part_end > part_start) {
part_fmt =
format_string.substr(part_start, part_end - part_start);
printf_out << part_fmt;
next_part = part_end;
}
continue;
} else if (part_end == std::string::npos &&
Expand Down

0 comments on commit 6d85e0c

Please sign in to comment.