Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix number match length for DTMF-only numbers
  • Loading branch information
matthewvogt committed Oct 24, 2013
1 parent d8d356d commit a94f343
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/seasidecache.cpp
Expand Up @@ -339,11 +339,15 @@ int matchLength(const QString &lhs, const QString &rhs)
QString::const_iterator ldtmf = firstDtmfChar(lbegin, lend);
QString::const_iterator rdtmf = firstDtmfChar(rbegin, rend);

QString::const_iterator lit, rit;
bool processDtmf = false;
int matchLength = 0;

if ((ldtmf != lbegin) && (rdtmf != rbegin)) {
// Start match length calculation at the last non-DTMF digit
QString::const_iterator lit = ldtmf - 1;
QString::const_iterator rit = rdtmf - 1;
lit = ldtmf - 1;
rit = rdtmf - 1;

int matchLength = 0;
while (*lit == *rit) {
++matchLength;

Expand All @@ -356,15 +360,22 @@ int matchLength(const QString &lhs, const QString &rhs)
if ((lit == lbegin) && (rit == rbegin)) {
// We have a complete, exact match - this must be the best match
return ExactMatch;
} else {
// We matched all of one number - continue looking in the DTMF part
processDtmf = true;
}
}
break;
}
}
} else {
// Process the DTMF section for a match
processDtmf = true;
}

// Have we got a match?
if ((matchLength >= QtContactsSqliteExtensions::DefaultMaximumPhoneNumberCharacters) ||
((lit == lbegin) || (rit == rbegin))) {
processDtmf) {
// See if the match continues into the DTMF area
QString::const_iterator lit = ldtmf;
QString::const_iterator rit = rdtmf;
Expand Down

0 comments on commit a94f343

Please sign in to comment.