| OLD | NEW |
| 1 /* | 1 /* |
| 2 ******************************************************************************* | 2 ******************************************************************************* |
| 3 * | 3 * |
| 4 * Copyright (C) 2005-2012, International Business Machines | 4 * Copyright (C) 2005-2014, International Business Machines |
| 5 * Corporation and others. All Rights Reserved. | 5 * Corporation and others. All Rights Reserved. |
| 6 * | 6 * |
| 7 ******************************************************************************* | 7 ******************************************************************************* |
| 8 * file name: swapimpl.cpp | 8 * file name: swapimpl.cpp |
| 9 * encoding: US-ASCII | 9 * encoding: US-ASCII |
| 10 * tab size: 8 (not used) | 10 * tab size: 8 (not used) |
| 11 * indentation:4 | 11 * indentation:4 |
| 12 * | 12 * |
| 13 * created on: 2005may05 | 13 * created on: 2005may05 |
| 14 * created by: Markus W. Scherer | 14 * created by: Markus W. Scherer |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 /* swapping implementations in i18n */ | 60 /* swapping implementations in i18n */ |
| 61 | 61 |
| 62 #if !UCONFIG_NO_NORMALIZATION | 62 #if !UCONFIG_NO_NORMALIZATION |
| 63 #include "uspoof_impl.h" | 63 #include "uspoof_impl.h" |
| 64 #endif | 64 #endif |
| 65 | 65 |
| 66 U_NAMESPACE_USE | 66 U_NAMESPACE_USE |
| 67 | 67 |
| 68 /* definitions */ | 68 /* definitions */ |
| 69 | 69 |
| 70 #define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0])) | |
| 71 | |
| 72 /* Unicode property (value) aliases data swapping --------------------------- */ | 70 /* Unicode property (value) aliases data swapping --------------------------- */ |
| 73 | 71 |
| 74 static int32_t U_CALLCONV | 72 static int32_t U_CALLCONV |
| 75 upname_swap(const UDataSwapper *ds, | 73 upname_swap(const UDataSwapper *ds, |
| 76 const void *inData, int32_t length, void *outData, | 74 const void *inData, int32_t length, void *outData, |
| 77 UErrorCode *pErrorCode) { | 75 UErrorCode *pErrorCode) { |
| 78 /* udata_swapDataHeader checks the arguments */ | 76 /* udata_swapDataHeader checks the arguments */ |
| 79 int32_t headerSize=udata_swapDataHeader(ds, inData, length, outData, pErrorC
ode); | 77 int32_t headerSize=udata_swapDataHeader(ds, inData, length, outData, pErrorC
ode); |
| 80 if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) { | 78 if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) { |
| 81 return 0; | 79 return 0; |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 /* swap the UTrie */ | 491 /* swap the UTrie */ |
| 494 count=indexes[UBIDI_IX_TRIE_SIZE]; | 492 count=indexes[UBIDI_IX_TRIE_SIZE]; |
| 495 utrie2_swapAnyVersion(ds, inBytes+offset, count, outBytes+offset, pError
Code); | 493 utrie2_swapAnyVersion(ds, inBytes+offset, count, outBytes+offset, pError
Code); |
| 496 offset+=count; | 494 offset+=count; |
| 497 | 495 |
| 498 /* swap the uint32_t mirrors[] */ | 496 /* swap the uint32_t mirrors[] */ |
| 499 count=indexes[UBIDI_IX_MIRROR_LENGTH]*4; | 497 count=indexes[UBIDI_IX_MIRROR_LENGTH]*4; |
| 500 ds->swapArray32(ds, inBytes+offset, count, outBytes+offset, pErrorCode); | 498 ds->swapArray32(ds, inBytes+offset, count, outBytes+offset, pErrorCode); |
| 501 offset+=count; | 499 offset+=count; |
| 502 | 500 |
| 503 /* just skip the uint8_t jgArray[] */ | 501 /* just skip the uint8_t jgArray[] and jgArray2[] */ |
| 504 count=indexes[UBIDI_IX_JG_LIMIT]-indexes[UBIDI_IX_JG_START]; | 502 count=indexes[UBIDI_IX_JG_LIMIT]-indexes[UBIDI_IX_JG_START]; |
| 505 offset+=count; | 503 offset+=count; |
| 504 count=indexes[UBIDI_IX_JG_LIMIT2]-indexes[UBIDI_IX_JG_START2]; |
| 505 offset+=count; |
| 506 | 506 |
| 507 U_ASSERT(offset==size); | 507 U_ASSERT(offset==size); |
| 508 } | 508 } |
| 509 | 509 |
| 510 return headerSize+size; | 510 return headerSize+size; |
| 511 } | 511 } |
| 512 | 512 |
| 513 /* Unicode normalization data swapping -------------------------------------- */ | 513 /* Unicode normalization data swapping -------------------------------------- */ |
| 514 | 514 |
| 515 #if !UCONFIG_NO_NORMALIZATION | 515 #if !UCONFIG_NO_NORMALIZATION |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 }; | 783 }; |
| 784 | 784 |
| 785 if(uprv_isInvariantUString(u, 4)) { | 785 if(uprv_isInvariantUString(u, 4)) { |
| 786 u_UCharsToChars(u, dataFormatChars, 4); | 786 u_UCharsToChars(u, dataFormatChars, 4); |
| 787 } else { | 787 } else { |
| 788 dataFormatChars[0]=dataFormatChars[1]=dataFormatChars[2]=dataFormatC
hars[3]='?'; | 788 dataFormatChars[0]=dataFormatChars[1]=dataFormatChars[2]=dataFormatC
hars[3]='?'; |
| 789 } | 789 } |
| 790 } | 790 } |
| 791 | 791 |
| 792 /* dispatch to the swap function for the dataFormat */ | 792 /* dispatch to the swap function for the dataFormat */ |
| 793 for(i=0; i<LENGTHOF(swapFns); ++i) { | 793 for(i=0; i<UPRV_LENGTHOF(swapFns); ++i) { |
| 794 if(0==memcmp(swapFns[i].dataFormat, pInfo->dataFormat, 4)) { | 794 if(0==memcmp(swapFns[i].dataFormat, pInfo->dataFormat, 4)) { |
| 795 swappedLength=swapFns[i].swapFn(ds, inData, length, outData, pErrorC
ode); | 795 swappedLength=swapFns[i].swapFn(ds, inData, length, outData, pErrorC
ode); |
| 796 | 796 |
| 797 if(U_FAILURE(*pErrorCode)) { | 797 if(U_FAILURE(*pErrorCode)) { |
| 798 udata_printError(ds, "udata_swap(): failure swapping data format
%02x.%02x.%02x.%02x (\"%c%c%c%c\") - %s\n", | 798 udata_printError(ds, "udata_swap(): failure swapping data format
%02x.%02x.%02x.%02x (\"%c%c%c%c\") - %s\n", |
| 799 pInfo->dataFormat[0], pInfo->dataFormat[1], | 799 pInfo->dataFormat[0], pInfo->dataFormat[1], |
| 800 pInfo->dataFormat[2], pInfo->dataFormat[3], | 800 pInfo->dataFormat[2], pInfo->dataFormat[3], |
| 801 dataFormatChars[0], dataFormatChars[1], | 801 dataFormatChars[0], dataFormatChars[1], |
| 802 dataFormatChars[2], dataFormatChars[3], | 802 dataFormatChars[2], dataFormatChars[3], |
| 803 u_errorName(*pErrorCode)); | 803 u_errorName(*pErrorCode)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 819 /* the dataFormat was not recognized */ | 819 /* the dataFormat was not recognized */ |
| 820 udata_printError(ds, "udata_swap(): unknown data format %02x.%02x.%02x.%02x
(\"%c%c%c%c\")\n", | 820 udata_printError(ds, "udata_swap(): unknown data format %02x.%02x.%02x.%02x
(\"%c%c%c%c\")\n", |
| 821 pInfo->dataFormat[0], pInfo->dataFormat[1], | 821 pInfo->dataFormat[0], pInfo->dataFormat[1], |
| 822 pInfo->dataFormat[2], pInfo->dataFormat[3], | 822 pInfo->dataFormat[2], pInfo->dataFormat[3], |
| 823 dataFormatChars[0], dataFormatChars[1], | 823 dataFormatChars[0], dataFormatChars[1], |
| 824 dataFormatChars[2], dataFormatChars[3]); | 824 dataFormatChars[2], dataFormatChars[3]); |
| 825 | 825 |
| 826 *pErrorCode=U_UNSUPPORTED_ERROR; | 826 *pErrorCode=U_UNSUPPORTED_ERROR; |
| 827 return 0; | 827 return 0; |
| 828 } | 828 } |
| OLD | NEW |