summaryrefslogtreecommitdiff
path: root/android/PhoneNumberUtils.cpp
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:04:54 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:04:54 -0800
commit5770aafd1e1040dec51f2ed73cb95ed4dbe2a690 (patch)
tree5aa822f7d2f56a5f715b58a3e7647b91ea62aee3 /android/PhoneNumberUtils.cpp
parent6005ac625aa553fe461b363385a8ed4a3c217a1f (diff)
Code drop from //branches/cupcake/...@124589
Diffstat (limited to 'android/PhoneNumberUtils.cpp')
-rw-r--r--android/PhoneNumberUtils.cpp32
1 files changed, 19 insertions, 13 deletions
diff --git a/android/PhoneNumberUtils.cpp b/android/PhoneNumberUtils.cpp
index efbda77..c8f8e73 100644
--- a/android/PhoneNumberUtils.cpp
+++ b/android/PhoneNumberUtils.cpp
@@ -237,13 +237,11 @@ bool phone_number_compare(const char* a, const char* b)
int ia, ib;
int matched;
- if (a == NULL || b == NULL)
- {
+ if (a == NULL || b == NULL) {
return false;
}
- if (strlen(a) == 0 || strlen(b) == 0)
- {
+ if (strlen(a) == 0 || strlen(b) == 0) {
return false;
}
@@ -302,21 +300,29 @@ bool phone_number_compare(const char* a, const char* b)
* (for this, a '0' and a '00' prefix would have succeeded above)
*/
- if (matchIntlPrefix(a, ia + 1)
- && matchIntlPrefix (b, ib +1)
- ) {
+ if (matchIntlPrefix(a, ia + 1) && matchIntlPrefix(b, ib +1)) {
return true;
}
- if (matchTrunkPrefix(a, ia + 1)
- && matchIntlPrefixAndCC(b, ib +1)
- ) {
+ if (matchTrunkPrefix(a, ia + 1) && matchIntlPrefixAndCC(b, ib +1)) {
return true;
}
- if (matchTrunkPrefix(b, ib + 1)
- && matchIntlPrefixAndCC(a, ia +1)
- ) {
+ if (matchTrunkPrefix(b, ib + 1) && matchIntlPrefixAndCC(a, ia +1)) {
+ return true;
+ }
+
+ /*
+ * Last resort: if the number of unmatched characters on both sides is less than or equal
+ * to the length of the longest country code and only one number starts with a + accept
+ * the match. This is because some countries like France and Russia have an extra prefix
+ * digit that is used when dialing locally in country that does not show up when you dial
+ * the number using the country code. In France this prefix digit is used to determine
+ * which land line carrier to route the call over.
+ */
+ bool aPlusFirst = (*a == '+');
+ bool bPlusFirst = (*b == '+');
+ if (ia < 4 && ib < 4 && (aPlusFirst || bPlusFirst) && !(aPlusFirst && bPlusFirst)) {
return true;
}