diff options
author | deva <deva> | 2009-05-27 11:39:43 +0000 |
---|---|---|
committer | deva <deva> | 2009-05-27 11:39:43 +0000 |
commit | f6506e34a84256f0620ee97559bf415c27b9974c (patch) | |
tree | 64d9762a8d9bd6f5e143bcca5a4c33a09a6eb0e0 | |
parent | cf8af9792e5c14108e4a6ba37a784e221f370aa2 (diff) |
Fixed error in linesplitter (utf8 characters fucked up pretty good)
-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; |