Skip to content

Commit

Permalink
commit romaric's suggestion
Browse files Browse the repository at this point in the history
Co-authored-by: Romaric Jodin <rjodin@chromium.org>
  • Loading branch information
Rekt3421 and rjodinchr authored Oct 2, 2024
1 parent 49fc753 commit 181a82c
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 181a82c

Please sign in to comment.