diff options
| author | 2017-02-09 16:17:15 +0000 | |
|---|---|---|
| committer | 2017-02-09 16:17:18 +0000 | |
| commit | 024d22fdb76a75f72ac1a421c4dd184bbfe2ba12 (patch) | |
| tree | 074240054a9d37547ab9ddd3cac73a05e08b3f0e /tools/aapt2/ResourceValues.cpp | |
| parent | 34895c404b0153f021094d149cf36918edbd4552 (diff) | |
| parent | 7542162cb1b1fd2ce8a26dd7f3fedc8de8160d38 (diff) | |
Merge "AAPT2: Fix pseudolocalization to respect <xliff:g>"
Diffstat (limited to 'tools/aapt2/ResourceValues.cpp')
| -rw-r--r-- | tools/aapt2/ResourceValues.cpp | 47 | 
1 files changed, 35 insertions, 12 deletions
diff --git a/tools/aapt2/ResourceValues.cpp b/tools/aapt2/ResourceValues.cpp index 7956ad826acd..f75ed7ad978a 100644 --- a/tools/aapt2/ResourceValues.cpp +++ b/tools/aapt2/ResourceValues.cpp @@ -140,7 +140,23 @@ bool String::Equals(const Value* value) const {    if (!other) {      return false;    } -  return *this->value == *other->value; + +  if (this->value != other->value) { +    return false; +  } + +  if (untranslatable_sections.size() != other->untranslatable_sections.size()) { +    return false; +  } + +  auto other_iter = other->untranslatable_sections.begin(); +  for (const UntranslatableSection& this_section : untranslatable_sections) { +    if (this_section != *other_iter) { +      return false; +    } +    ++other_iter; +  } +  return true;  }  bool String::Flatten(android::Res_value* out_value) const { @@ -158,6 +174,7 @@ String* String::Clone(StringPool* new_pool) const {    String* str = new String(new_pool->MakeRef(*value));    str->comment_ = comment_;    str->source_ = source_; +  str->untranslatable_sections = untranslatable_sections;    return str;  } @@ -173,17 +190,22 @@ bool StyledString::Equals(const Value* value) const {      return false;    } -  if (*this->value->str == *other->value->str) { -    const std::vector<StringPool::Span>& spans_a = this->value->spans; -    const std::vector<StringPool::Span>& spans_b = other->value->spans; -    return std::equal( -        spans_a.begin(), spans_a.end(), spans_b.begin(), -        [](const StringPool::Span& a, const StringPool::Span& b) -> bool { -          return *a.name == *b.name && a.first_char == b.first_char && -                 a.last_char == b.last_char; -        }); +  if (this->value != other->value) { +    return false; +  } + +  if (untranslatable_sections.size() != other->untranslatable_sections.size()) { +    return false; +  } + +  auto other_iter = other->untranslatable_sections.begin(); +  for (const UntranslatableSection& this_section : untranslatable_sections) { +    if (this_section != *other_iter) { +      return false; +    } +    ++other_iter;    } -  return false; +  return true;  }  bool StyledString::Flatten(android::Res_value* out_value) const { @@ -200,6 +222,7 @@ StyledString* StyledString::Clone(StringPool* new_pool) const {    StyledString* str = new StyledString(new_pool->MakeRef(value));    str->comment_ = comment_;    str->source_ = source_; +  str->untranslatable_sections = untranslatable_sections;    return str;  } @@ -218,7 +241,7 @@ bool FileReference::Equals(const Value* value) const {    if (!other) {      return false;    } -  return *path == *other->path; +  return path == other->path;  }  bool FileReference::Flatten(android::Res_value* out_value) const {  |