Skip to content

Commit

Permalink
More correct wrap_rows implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
figec authored and est31 committed Jun 20, 2015
1 parent dd91b3d commit d7190df
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/util/string.h
Expand Up @@ -426,18 +426,12 @@ inline std::string wrap_rows(const std::string &from,
{
std::string to;

bool need_to_wrap = false;

size_t character_idx = 0;
for (size_t i = 0; i < from.size(); i++) {
if (character_idx > 0 && character_idx % row_len == 0)
need_to_wrap = true;
if (!IS_UTF8_MULTB_INNER(from[i])) {
// Wrap string if needed before next char started
if (need_to_wrap) {
// Wrap string after last inner byte of char
if (character_idx > 0 && character_idx % row_len == 0)
to += '\n';
need_to_wrap = false;
}
character_idx++;
}
to += from[i];
Expand Down

0 comments on commit d7190df

Please sign in to comment.