Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b2106687 authored by Adam Lesinski's avatar Adam Lesinski
Browse files

Fix pseudolocalizer at end of string

The accent pseudolocalizer would incorrectly process
the byte after the end of the string, which would end
up inserting null characters into the resulting
output.

Change-Id: I5cdabd6b0272d94073f06e180b8cbe7abafa3888
parent 92baab4f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -280,13 +280,13 @@ std::u16string PseudoMethodAccent::text(const StringPiece16& source)
            std::u16string chunk;
            bool end = false;
            chunk.append(&c, 1);
            while (!end && i < I) {
            while (!end && i + 1 < I) {
                ++i;
                c = s[i];
                chunk.append(&c, 1);
                if (isPossibleNormalPlaceholderEnd(c)) {
                    end = true;
                } else if (c == 't') {
                } else if (i + 1 < I && c == 't') {
                    ++i;
                    c = s[i];
                    chunk.append(&c, 1);
+1 −1
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ TEST(PseudolocalizerTest, PlaintextAccent) {

    EXPECT_TRUE(simpleHelper("Battery %1d%%",
                             "[βåţţéŕý »%1d«%% one two]", Pseudolocalizer::Method::kAccent));

    EXPECT_TRUE(simpleHelper("^1 %", "[^1 % one]", Pseudolocalizer::Method::kAccent));
    EXPECT_TRUE(compoundHelper("", "", "", "[]", Pseudolocalizer::Method::kAccent));
    EXPECT_TRUE(compoundHelper("Hello,", " world", "",
                               "[Ĥéļļö, ŵöŕļð one two]", Pseudolocalizer::Method::kAccent));