summaryrefslogtreecommitdiffstats
path: root/WebKit/android
diff options
context:
space:
mode:
authorCary Clark <cary@android.com>2009-08-25 11:38:47 -0400
committerCary Clark <cary@android.com>2009-08-25 11:38:47 -0400
commit10dd59ed29ea8ab537279de1bd91fb93dce15ca3 (patch)
treeb39efd68cd9a2d72097f1c0b46b231d01b6d5a55 /WebKit/android
parent59d6f2367e5fd0e25609fed4b5bb77b0c740d677 (diff)
downloadexternal_webkit-10dd59ed29ea8ab537279de1bd91fb93dce15ca3.zip
external_webkit-10dd59ed29ea8ab537279de1bd91fb93dce15ca3.tar.gz
external_webkit-10dd59ed29ea8ab537279de1bd91fb93dce15ca3.tar.bz2
fix address detection when the city and state are both valid states
This fixes detecting "4 E. 86th St New York, NY" The old logic found 'New York' and assumed that St was the city name. Since 86th is not a valid street suffix, the test failed. The new logic looks for a valid street suffix instead of skipping 'city'. If it finds one, and the subsequent street suffix test fails, it resets to search again for a valid state name while retaining the starting point for the address (the street number). Fixing this exposed a bug in the zip code detection code where it dropped the first character of the actual state name.
Diffstat (limited to 'WebKit/android')
-rw-r--r--WebKit/android/nav/CacheBuilder.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/WebKit/android/nav/CacheBuilder.cpp b/WebKit/android/nav/CacheBuilder.cpp
index 56cb2ae..037a6e5 100644
--- a/WebKit/android/nav/CacheBuilder.cpp
+++ b/WebKit/android/nav/CacheBuilder.cpp
@@ -1590,6 +1590,7 @@ CacheBuilder::FoundState CacheBuilder::FindPartialAddress(const UChar* baseChars
s->mCurrentStart = chars;
s->mEnd = chars + length;
int candIndex = 0;
+ bool retryState;
bool mustBeAllUpper = false;
bool secondHalf = false;
chars -= 1;
@@ -1914,6 +1915,15 @@ CacheBuilder::FoundState CacheBuilder::FindPartialAddress(const UChar* baseChars
s->mZipDelimiter = true;
} else if (WTF::isASCIIAlpha(ch) == false)
s->mZipDelimiter = true;
+ else {
+ if (s->mLetterCount == 0) {
+ s->mBases[s->mWordCount] = baseChars;
+ s->mWords[s->mWordCount] = chars;
+ s->mStarts[s->mWordCount] = s->mCurrentStart;
+ s->mUnparsed = true;
+ }
+ ++s->mLetterCount;
+ }
if (s->mNumberCount == 5 || s->mNumberCount == 9) {
if (validZip(s->mZipHint, s->mZipStart) == false)
goto noZipMatch;
@@ -1945,8 +1955,9 @@ CacheBuilder::FoundState CacheBuilder::FindPartialAddress(const UChar* baseChars
break;
s->mProgress = FIND_STREET;
case FIND_STREET:
- findStreet: // minus two below skips city before state
- for (int wordsIndex = s->mStateWord - 2; wordsIndex >= 0; --wordsIndex) {
+ findStreet:
+ retryState = false;
+ for (int wordsIndex = s->mStateWord - 1; wordsIndex >= 0; --wordsIndex) {
const UChar* test = s->mWords[wordsIndex];
UChar letter = test[0];
letter -= 'A';
@@ -1992,17 +2003,27 @@ CacheBuilder::FoundState CacheBuilder::FindPartialAddress(const UChar* baseChars
wordReduction = shift;
} while (s->mNumberWords >> ++shift != 0);
if (wordReduction >= 0) {
- if (s->mContinuationNode)
+ if (s->mContinuationNode) {
+ if (retryState)
+ break;
return FOUND_NONE;
+ }
s->mStartResult = s->mWords[wordReduction] - s->mStarts[wordReduction];
}
}
- return FOUND_COMPLETE;
+ if (wordsIndex != s->mStateWord - 1)
+ return FOUND_COMPLETE;
+ retryState = true;
}
nextTest:
names += offset;
}
}
+ if (retryState) {
+ s->mProgress = ADDRESS_LINE;
+ s->mStates = NULL;
+ continue;
+ }
if (s->mNumberWords != 0) {
unsigned shift = 0;
while ((s->mNumberWords & (1 << shift)) == 0)