Index: third_party/libaddressinput/chromium/cpp/src/rule.cc |
diff --git a/third_party/libaddressinput/chromium/cpp/src/rule.cc b/third_party/libaddressinput/chromium/cpp/src/rule.cc |
index 791ac9eca651bbba4d68945ffad93ffaafe454c4..dadc1e82a7329fec631ae4b8f265fcb57ae3da3e 100644 |
--- a/third_party/libaddressinput/chromium/cpp/src/rule.cc |
+++ b/third_party/libaddressinput/chromium/cpp/src/rule.cc |
@@ -376,7 +376,10 @@ int Rule::GetInvalidFieldMessageId(AddressField field) const { |
} |
bool Rule::CanonicalizeSubKey(const std::string& user_input, |
+ bool canonicalize_latin_name, |
Evan Stade
2014/04/16 21:55:46
|canonicalize_latin_name| is not quite optimal imo
please use gerrit instead
2014/04/16 22:53:27
Done.
|
std::string* sub_key) const { |
+ assert(sub_key != NULL); |
+ |
if (sub_keys_.empty()) { |
*sub_key = user_input; |
return true; |
@@ -384,12 +387,15 @@ bool Rule::CanonicalizeSubKey(const std::string& user_input, |
return GetMatchingSubKey(user_input, sub_keys_, sub_key) || |
GetMatchingSubKey(user_input, sub_names_, sub_key) || |
- GetMatchingSubKey(user_input, sub_lnames_, sub_key); |
+ (canonicalize_latin_name && |
+ GetMatchingSubKey(user_input, sub_lnames_, sub_key)) || |
+ GetMatchingValue(user_input, sub_lnames_, sub_key); |
} |
bool Rule::GetMatchingSubKey(const std::string& target, |
Evan Stade
2014/04/16 21:55:46
seems like GetMatchingSubKey and GetMatchingValue
please use gerrit instead
2014/04/16 22:53:27
Done.
|
const std::vector<std::string>& values, |
std::string* sub_key) const { |
+ assert(sub_key != NULL); |
for (size_t i = 0; i < values.size(); ++i) { |
if (LooseStringCompare(values[i], target)) { |
*sub_key = sub_keys_[i]; |
@@ -399,5 +405,18 @@ bool Rule::GetMatchingSubKey(const std::string& target, |
return false; |
} |
+bool Rule::GetMatchingValue(const std::string& target, |
+ const std::vector<std::string>& values, |
+ std::string* value) const { |
+ assert(value != NULL); |
+ for (size_t i = 0; i < values.size(); ++i) { |
+ if (LooseStringCompare(values[i], target)) { |
+ *value = values[i]; |
+ return true; |
+ } |
+ } |
+ return false; |
+} |
+ |
} // namespace addressinput |
} // namespace i18n |