From 6af99edcc14b85859cf35dfa07964d70105d4e0b Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Sun, 22 Aug 2010 20:58:34 +0200 Subject: [PATCH] conv: shorten: maintain proper string length if max_length is odd --- src/conv.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conv.cpp b/src/conv.cpp index 69a2db7b..de977a5c 100644 --- a/src/conv.cpp +++ b/src/conv.cpp @@ -222,7 +222,7 @@ std::string Shorten(const std::basic_string &s, size_t max_length) return TO_STRING(s); if (max_length < 2) return ""; - std::basic_string result(s, 0, max_length/2-1); + std::basic_string result(s, 0, max_length/2-!(max_length%2)); result += U(".."); result += s.substr(s.length()-max_length/2+1); return TO_STRING(result);