diff --git a/src/text.cpp b/src/text.cpp index 2a7608a5e..f5e3496be 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -291,7 +291,7 @@ bool extractLine ( // No hyphenation, just truncation. else { - line = text.substr (offset, prior_cursor - offset); + line = text.substr (offset, cursor - offset); offset = cursor; return true; } @@ -630,7 +630,7 @@ std::string leftJustify (const int input, const int width) //////////////////////////////////////////////////////////////////////////////// std::string leftJustify (const std::string& input, const int width) { - auto len = utf8_text_width (input); + auto len = static_cast (utf8_text_width (input)); if (len == width) return input; @@ -660,7 +660,7 @@ std::string rightJustify (const int input, const int width) //////////////////////////////////////////////////////////////////////////////// std::string rightJustify (const std::string& input, const int width) { - auto len = utf8_text_width (input); + auto len = static_cast (utf8_text_width (input)); if (len == width) return input; @@ -668,7 +668,7 @@ std::string rightJustify (const std::string& input, const int width) if (len > width) return input.substr (0, width); - return (((unsigned int) width > len) + return ((width > len) ? std::string (width - len, ' ') : "") + input; diff --git a/test/hyphenate.t b/test/hyphenate.t index e02ea5291..a62482c98 100755 --- a/test/hyphenate.t +++ b/test/hyphenate.t @@ -54,7 +54,7 @@ class TestHyphenation(TestCase): """Verify hyphenation in the absence of white space""" self.t("add AAAAAAAAAABBBBBBBBBBCCCCCCCCCC") code, out, err = self.t("ls") - self.assertIn("1 AAAAAAAAAABBBB-\n", out) + self.assertIn(" 1 AAAAAAAAAABBBBBB-\n", out) class TestBug804(TestCase): def setUp(self):