Exemplo n.º 1
0
static const DataHeader *pointerTOCLookupFn(const UDataMemory *pData,
                   const char *name,
                   int32_t *pLength,
                   UErrorCode *pErrorCode) {
    if(pData->toc!=NULL) {
        const PointerTOC *toc = (PointerTOC *)pData->toc;
        int32_t number, count=(int32_t)toc->count;

#if defined (UDATA_DEBUG_DUMP)
        /* list the contents of the TOC each time .. not recommended */
        for(number=0; number<count; ++number) {
            fprintf(stderr, "\tx%d: %s\n", number, toc->entry[number].entryName);
        }
#endif
        number=pointerTOCPrefixBinarySearch(name, toc->entry, count);
        if(number>=0) {
            /* found it */
#ifdef UDATA_DEBUG
            fprintf(stderr, "%s: Found.\n", toc->entry[number].entryName);
#endif
            *pLength=-1;
            return UDataMemory_normalizeDataPointer(toc->entry[number].pHeader);
        } else {
#ifdef UDATA_DEBUG
            fprintf(stderr, "%s: Not found.\n", name);
#endif
            return NULL;
        }
    } else {
        return pData->pHeader;
    }
}
Exemplo n.º 2
0
static const DataHeader *pointerTOCLookupFn(const UDataMemory *pData,
                   const char *name,
                   UErrorCode *pErrorCode) {
    if(pData->toc!=NULL) {
        const PointerTOC *toc = (PointerTOC *)pData->toc;
        uint32_t start, limit, number;

        /* perform a binary search for the data in the common data's table of contents */
        start=0;
        limit=toc->count;   

        if (limit == 0) {       /* Stub common data library used during build is empty. */
            return NULL;
        }

        while(start<limit-1) {
            number=(start+limit)/2;
            if(uprv_strcmp(name, toc->entry[number].entryName)<0) {
                limit=number;
            } else {
                start=number;
            }
        }

        if(uprv_strcmp(name, toc->entry[start].entryName)==0) {
            /* found it */
            return UDataMemory_normalizeDataPointer(toc->entry[start].pHeader);
        } else {
            return NULL;
        }
    } else {
        return pData->pHeader;
    }
}
Exemplo n.º 3
0
static const DataHeader *pointerTOCLookupFn(const UDataMemory *pData,
                   const char *name,
                   int32_t *pLength,
                   UErrorCode *pErrorCode) {
    if(pData->toc!=NULL) {
        const PointerTOC *toc = (PointerTOC *)pData->toc;
        uint32_t start, limit, number, lastNumber;
        int32_t strResult;

#if defined (UDATA_DEBUG_DUMP)
        /* list the contents of the TOC each time .. not recommended */
        for(start=0;start<toc->count;start++) {
            fprintf(stderr, "\tx%d: %s\n", start, toc->entry[start].entryName);
        }
#endif

        /* perform a binary search for the data in the common data's table of contents */
        start=0;
        limit=toc->count;
        lastNumber=limit;

        for (;;) {
            number = (start+limit)/2;
            if (lastNumber == number) { /* Have we moved? */
                break;  /* We haven't moved, and it wasn't found, */
                        /* or the empty stub common data library was used during build. */
            }
            lastNumber = number;
            strResult = uprv_strcmp(name, toc->entry[number].entryName);
            if(strResult<0) {
                limit=number;
            } else if (strResult>0) {
                start=number;
            }
            else {
                /* found it */
#ifdef UDATA_DEBUG
                fprintf(stderr, "%s: Found.\n", toc->entry[number].entryName);
#endif
                *pLength=-1;
                return UDataMemory_normalizeDataPointer(toc->entry[number].pHeader);
            }
        }
#ifdef UDATA_DEBUG
        fprintf(stderr, "%s: Not found.\n", name);
#endif
        return NULL;
    } else {
        return pData->pHeader;
    }
}
Exemplo n.º 4
0
void UDataMemory_setData (UDataMemory *This, const void *dataAddr) {
    This->pHeader = UDataMemory_normalizeDataPointer(dataAddr);
}