From 7542162cb1b1fd2ce8a26dd7f3fedc8de8160d38 Mon Sep 17 00:00:00 2001 From: Adam Lesinski Date: Fri, 6 Jan 2017 15:20:04 -0800 Subject: AAPT2: Fix pseudolocalization to respect The XLIFF 'g' tag specifies content that should NOT be translated. AAPT2's pseudolocalization process should respect it. Bug:34064599 Test: make libandroidfw_tests Change-Id: Ice437d7f0ff246730ee04896fd035e2d846148fb --- tools/aapt2/StringPool.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'tools/aapt2/StringPool.cpp') diff --git a/tools/aapt2/StringPool.cpp b/tools/aapt2/StringPool.cpp index d968d73c44ee..57da5f01dcd1 100644 --- a/tools/aapt2/StringPool.cpp +++ b/tools/aapt2/StringPool.cpp @@ -63,6 +63,14 @@ StringPool::Ref& StringPool::Ref::operator=(const StringPool::Ref& rhs) { return *this; } +bool StringPool::Ref::operator==(const Ref& rhs) const { + return entry_->value == rhs.entry_->value; +} + +bool StringPool::Ref::operator!=(const Ref& rhs) const { + return entry_->value != rhs.entry_->value; +} + const std::string* StringPool::Ref::operator->() const { return &entry_->value; } @@ -109,6 +117,28 @@ StringPool::StyleRef& StringPool::StyleRef::operator=( return *this; } +bool StringPool::StyleRef::operator==(const StyleRef& rhs) const { + if (entry_->str != rhs.entry_->str) { + return false; + } + + if (entry_->spans.size() != rhs.entry_->spans.size()) { + return false; + } + + auto rhs_iter = rhs.entry_->spans.begin(); + for (const Span& span : entry_->spans) { + const Span& rhs_span = *rhs_iter; + if (span.first_char != rhs_span.first_char || span.last_char != rhs_span.last_char || + span.name != rhs_span.name) { + return false; + } + } + return true; +} + +bool StringPool::StyleRef::operator!=(const StyleRef& rhs) const { return !operator==(rhs); } + const StringPool::StyleEntry* StringPool::StyleRef::operator->() const { return entry_; } -- cgit v1.2.3-59-g8ed1b