X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/4388f060552cc537e71e957d32f35e9d75a61233..9663b57d33cc571e269bcfab3d9df43b149162db:/icuSources/tools/toolutil/swapimpl.cpp diff --git a/icuSources/tools/toolutil/swapimpl.cpp b/icuSources/tools/toolutil/swapimpl.cpp index 90c1eb41..f3f333a0 100644 --- a/icuSources/tools/toolutil/swapimpl.cpp +++ b/icuSources/tools/toolutil/swapimpl.cpp @@ -1,12 +1,14 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html /* ******************************************************************************* * -* Copyright (C) 2005-2012, International Business Machines +* Copyright (C) 2005-2014, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* * file name: swapimpl.cpp -* encoding: US-ASCII +* encoding: UTF-8 * tab size: 8 (not used) * indentation:4 * @@ -54,8 +56,9 @@ #include "sprpimpl.h" #include "propname.h" #include "rbbidata.h" -#include "triedict.h" +#include "utrie.h" #include "utrie2.h" +#include "dictionarydata.h" /* swapping implementations in i18n */ @@ -67,8 +70,6 @@ U_NAMESPACE_USE /* definitions */ -#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0])) - /* Unicode property (value) aliases data swapping --------------------------- */ static int32_t U_CALLCONV @@ -84,7 +85,7 @@ upname_swap(const UDataSwapper *ds, /* check data format and format version */ const UDataInfo *pInfo= reinterpret_cast( - reinterpret_cast(inData)+4); + static_cast(inData)+4); if(!( pInfo->dataFormat[0]==0x70 && /* dataFormat="pnam" */ pInfo->dataFormat[1]==0x6e && @@ -100,8 +101,8 @@ upname_swap(const UDataSwapper *ds, return 0; } - const uint8_t *inBytes=reinterpret_cast(inData)+headerSize; - uint8_t *outBytes=reinterpret_cast(outData)+headerSize; + const uint8_t *inBytes=static_cast(inData)+headerSize; + uint8_t *outBytes=static_cast(outData)+headerSize; if(length>=0) { length-=headerSize; @@ -232,7 +233,7 @@ uprops_swap(const UDataSwapper *ds, /* copy everything for inaccessible data (padding) */ if(inData32!=outData32) { - uprv_memcpy(outData32, inData32, 4*dataTop); + uprv_memcpy(outData32, inData32, 4*(size_t)dataTop); } /* swap the indexes[16] */ @@ -335,7 +336,7 @@ ucase_swap(const UDataSwapper *ds, ((pInfo->formatVersion[0]==1 && pInfo->formatVersion[2]==UTRIE_SHIFT && pInfo->formatVersion[3]==UTRIE_INDEX_SHIFT) || - pInfo->formatVersion[0]==2 || pInfo->formatVersion[0]==3) + 2<=pInfo->formatVersion[0] || pInfo->formatVersion[0]<=4) )) { udata_printError(ds, "ucase_swap(): data format %02x.%02x.%02x.%02x (format version %02x) is not recognized as case mapping data\n", pInfo->dataFormat[0], pInfo->dataFormat[1], @@ -500,9 +501,11 @@ ubidi_swap(const UDataSwapper *ds, ds->swapArray32(ds, inBytes+offset, count, outBytes+offset, pErrorCode); offset+=count; - /* just skip the uint8_t jgArray[] */ + /* just skip the uint8_t jgArray[] and jgArray2[] */ count=indexes[UBIDI_IX_JG_LIMIT]-indexes[UBIDI_IX_JG_START]; offset+=count; + count=indexes[UBIDI_IX_JG_LIMIT2]-indexes[UBIDI_IX_JG_START2]; + offset+=count; U_ASSERT(offset==size); } @@ -653,7 +656,7 @@ test_swap(const UDataSwapper *ds, /* udata_swapDataHeader checks the arguments */ headerSize=udata_swapDataHeader(ds, inData, length, outData, pErrorCode); if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) { - udata_printError(ds, "test_swap(): data header swap failed %s\n", u_errorName(*pErrorCode)); + udata_printError(ds, "test_swap(): data header swap failed %s\n", pErrorCode != NULL ? u_errorName(*pErrorCode) : "pErrorCode is NULL"); return 0; } @@ -734,7 +737,7 @@ static const struct { #endif #if !UCONFIG_NO_BREAK_ITERATION { { 0x42, 0x72, 0x6b, 0x20 }, ubrk_swap }, /* dataFormat="Brk " */ - { { 0x54, 0x72, 0x44, 0x63 }, triedict_swap }, /* dataFormat="TrDc " */ + { { 0x44, 0x69, 0x63, 0x74 }, udict_swap }, /* dataFormat="Dict" */ #endif { { 0x70, 0x6e, 0x61, 0x6d }, upname_swap }, /* dataFormat="pnam" */ { { 0x75, 0x6e, 0x61, 0x6d }, uchar_swapNames }, /* dataFormat="unam" */ @@ -790,7 +793,7 @@ udata_swap(const UDataSwapper *ds, } /* dispatch to the swap function for the dataFormat */ - for(i=0; idataFormat, 4)) { swappedLength=swapFns[i].swapFn(ds, inData, length, outData, pErrorCode);