diff options
Diffstat (limited to 'server')
| -rw-r--r-- | server/src/journal_commit.cc | 13 | 
1 files changed, 11 insertions, 2 deletions
| diff --git a/server/src/journal_commit.cc b/server/src/journal_commit.cc index f74e54e..4992545 100644 --- a/server/src/journal_commit.cc +++ b/server/src/journal_commit.cc @@ -52,6 +52,11 @@  #include "template.h"  #include "templateparser.h" +static inline bool iswhitespace(char c) +{ +  return c == ' ' || c == '\n' || c == '\t'; +} +  /**   * Remove all spaces, tabs and newline trailing the string.   */ @@ -61,7 +66,9 @@ static std::string stripTrailingWhitepace(std::string str)    ssize_t end = str.size() - 1; -  while(end && str[end] <=  ' ') { // Every below SPACE 0x20 is consideret whitespace. +  while(end && iswhitespace(str[end])  +        && (end>0 && str[end-1] & 0x80) == false // Make sure we are not in a utf8 character. +        ) {      end--;    }    end++; @@ -83,7 +90,9 @@ static std::string addNewlines(std::string str, size_t width)      fraction += str[i]; -    if(str[i] <= ' ') { +    if(iswhitespace(str[i])  +       && (i>0 && str[i-1] & 0x80) == false // Make sure we are not in a utf8 character. +       ) {        if(linelen + fraction.size() > width) {          output[output.size() - 1] = '\n';          linelen = 0; | 
