diff options
author | Taesu Lee <taesu82.lee@samsung.com> | 2019-05-29 14:09:11 +0900 |
---|---|---|
committer | Hui Yu <huiyu@google.com> | 2019-08-05 21:29:01 +0000 |
commit | 15cec8f2872b2b9d42c5484b376da8d3fa26ad6f (patch) | |
tree | 4600c4d0198b53f1e4916c2c0d63f2a67e8be60e /android/OldPhoneNumberUtils.cpp | |
parent | 6d1591ee346f7582e92fe4ba3509433da636fe58 (diff) |
Support loose comparison using minimum matched chars
Specific min match is required for each country.
Test: Manual
Change-Id: I2f1355c4ba712170464e4c23a916024e0bf58e71
Merged-In: I2f1355c4ba712170464e4c23a916024e0bf58e71
Signed-off-by: Taesu Lee <taesu82.lee@samsung.com>
Bug:134246556
Diffstat (limited to 'android/OldPhoneNumberUtils.cpp')
-rw-r--r-- | android/OldPhoneNumberUtils.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/android/OldPhoneNumberUtils.cpp b/android/OldPhoneNumberUtils.cpp index 9846a1c..3a69e0c 100644 --- a/android/OldPhoneNumberUtils.cpp +++ b/android/OldPhoneNumberUtils.cpp @@ -159,13 +159,13 @@ static bool matchIntlPrefixAndCC(const char* a, int len) * enough for caller ID purposes. * * - Compares from right to left - * - requires MIN_MATCH (7) characters to match + * - requires minimum characters to match * - handles common trunk prefixes and international prefixes * (basically, everything except the Russian trunk prefix) * * Tolerates nulls */ -bool phone_number_compare_loose(const char* a, const char* b) +bool phone_number_compare_loose_with_minmatch(const char* a, const char* b, int min_match) { int ia, ib; int matched; @@ -216,11 +216,11 @@ bool phone_number_compare_loose(const char* a, const char* b) } } - if (matched < MIN_MATCH) { + if (matched < min_match) { const int effectiveALen = strlen(a) - numSeparatorCharsInA; const int effectiveBLen = strlen(b) - numSeparatorCharsInB; - // if the number of dialable chars in a and b match, but the matched chars < MIN_MATCH, + // if the number of dialable chars in a and b match, but the matched chars < min_match, // treat them as equal (i.e. 404-04 and 40404) if (effectiveALen == effectiveBLen && effectiveALen == matched) { return true; @@ -230,7 +230,7 @@ bool phone_number_compare_loose(const char* a, const char* b) } // At least one string has matched completely; - if (matched >= MIN_MATCH && (ia < 0 || ib < 0)) { + if (matched >= min_match && (ia < 0 || ib < 0)) { return true; } @@ -274,4 +274,9 @@ bool phone_number_compare_loose(const char* a, const char* b) return false; } +bool phone_number_compare_loose(const char* a, const char* b) +{ + return phone_number_compare_loose_with_minmatch(a, b, MIN_MATCH); +} + } // namespace android |