X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/374ca955a76ecab1204ca8bfa63ff9238d998416..ef6cf650f4a75c3f97de06b51fa104f2069b9ea2:/icuSources/layout/LookupTables.cpp diff --git a/icuSources/layout/LookupTables.cpp b/icuSources/layout/LookupTables.cpp index 9766a813..93c93c95 100644 --- a/icuSources/layout/LookupTables.cpp +++ b/icuSources/layout/LookupTables.cpp @@ -1,6 +1,6 @@ /* * - * (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved + * (C) Copyright IBM Corp. 1998-2013 - All Rights Reserved * */ @@ -24,22 +24,26 @@ U_NAMESPACE_BEGIN of the derived classes, and implement it in the others by casting the "this" pointer to the type that has the implementation. */ -const LookupSegment *BinarySearchLookupTable::lookupSegment(const LookupSegment *segments, LEGlyphID glyph) const +const LookupSegment *BinarySearchLookupTable::lookupSegment(const LETableReference &base, const LookupSegment *segments, LEGlyphID glyph, LEErrorCode &success) const { + le_int16 unity = SWAPW(unitSize); le_int16 probe = SWAPW(searchRange); le_int16 extra = SWAPW(rangeShift); TTGlyphID ttGlyph = (TTGlyphID) LE_GET_GLYPH(glyph); - const LookupSegment *entry = segments; - const LookupSegment *trial = (const LookupSegment *) ((char *) entry + extra); + LEReferenceTo entry(base, success, segments); + LEReferenceTo trial(entry, success, extra); + + if(LE_FAILURE(success)) return NULL; if (SWAPW(trial->lastGlyph) <= ttGlyph) { entry = trial; } - while (probe > unity) { + while (probe > unity && LE_SUCCESS(success)) { probe >>= 1; - trial = (const LookupSegment *) ((char *) entry + probe); + trial = entry; // copy + trial.addOffset(probe, success); if (SWAPW(trial->lastGlyph) <= ttGlyph) { entry = trial; @@ -47,28 +51,29 @@ const LookupSegment *BinarySearchLookupTable::lookupSegment(const LookupSegment } if (SWAPW(entry->firstGlyph) <= ttGlyph) { - return entry; + return entry.getAlias(); } return NULL; } -const LookupSingle *BinarySearchLookupTable::lookupSingle(const LookupSingle *entries, LEGlyphID glyph) const +const LookupSingle *BinarySearchLookupTable::lookupSingle(const LETableReference &base, const LookupSingle *entries, LEGlyphID glyph, LEErrorCode &success) const { le_int16 unity = SWAPW(unitSize); le_int16 probe = SWAPW(searchRange); le_int16 extra = SWAPW(rangeShift); TTGlyphID ttGlyph = (TTGlyphID) LE_GET_GLYPH(glyph); - const LookupSingle *entry = entries; - const LookupSingle *trial = (const LookupSingle *) ((char *) entry + extra); + LEReferenceTo entry(base, success, entries); + LEReferenceTo trial(entry, success, extra); if (SWAPW(trial->glyph) <= ttGlyph) { entry = trial; } - while (probe > unity) { + while (probe > unity && LE_SUCCESS(success)) { probe >>= 1; - trial = (const LookupSingle *) ((char *) entry + probe); + trial = entry; + trial.addOffset(probe, success); if (SWAPW(trial->glyph) <= ttGlyph) { entry = trial; @@ -76,7 +81,7 @@ const LookupSingle *BinarySearchLookupTable::lookupSingle(const LookupSingle *en } if (SWAPW(entry->glyph) == ttGlyph) { - return entry; + return entry.getAlias(); } return NULL;