Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(793)

Side by Side Diff: source/common/udataswp.c

Issue 845603002: Update ICU to 54.1 step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@master
Patch Set: remove unusued directories Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/common/udataswp.h ('k') | source/common/uidna.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 ******************************************************************************* 2 *******************************************************************************
3 * 3 *
4 * Copyright (C) 2003, International Business Machines 4 * Copyright (C) 2003-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: udataswp.c 8 * file name: udataswp.c
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: 2003jun05 13 * created on: 2003jun05
14 * created by: Markus W. Scherer 14 * created by: Markus W. Scherer
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; 116 *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
117 return 0; 117 return 0;
118 } 118 }
119 119
120 if(length>0 && inData!=outData) { 120 if(length>0 && inData!=outData) {
121 uprv_memcpy(outData, inData, length); 121 uprv_memcpy(outData, inData, length);
122 } 122 }
123 return length; 123 return length;
124 } 124 }
125 125
126 static int32_t U_CALLCONV
127 uprv_swapArray64(const UDataSwapper *ds,
128 const void *inData, int32_t length, void *outData,
129 UErrorCode *pErrorCode) {
130 const uint64_t *p;
131 uint64_t *q;
132 int32_t count;
133
134 if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) {
135 return 0;
136 }
137 if(ds==NULL || inData==NULL || length<0 || (length&7)!=0 || outData==NULL) {
138 *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
139 return 0;
140 }
141
142 /* setup and swapping */
143 p=(const uint64_t *)inData;
144 q=(uint64_t *)outData;
145 count=length/8;
146 while(count>0) {
147 uint64_t x=*p++;
148 x=(x<<56)|((x&0xff00)<<40)|((x&0xff0000)<<24)|((x&0xff000000)<<8)|
149 ((x>>8)&0xff000000)|((x>>24)&0xff0000)|((x>>40)&0xff00)|(x>>56);
150 *q++=x;
151 --count;
152 }
153
154 return length;
155 }
156
157 static int32_t U_CALLCONV
158 uprv_copyArray64(const UDataSwapper *ds,
159 const void *inData, int32_t length, void *outData,
160 UErrorCode *pErrorCode) {
161 if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) {
162 return 0;
163 }
164 if(ds==NULL || inData==NULL || length<0 || (length&7)!=0 || outData==NULL) {
165 *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
166 return 0;
167 }
168
169 if(length>0 && inData!=outData) {
170 uprv_memcpy(outData, inData, length);
171 }
172 return length;
173 }
174
126 static uint16_t U_CALLCONV 175 static uint16_t U_CALLCONV
127 uprv_readSwapUInt16(uint16_t x) { 176 uprv_readSwapUInt16(uint16_t x) {
128 return (uint16_t)((x<<8)|(x>>8)); 177 return (uint16_t)((x<<8)|(x>>8));
129 } 178 }
130 179
131 static uint16_t U_CALLCONV 180 static uint16_t U_CALLCONV
132 uprv_readDirectUInt16(uint16_t x) { 181 uprv_readDirectUInt16(uint16_t x) {
133 return x; 182 return x;
134 } 183 }
135 184
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 swapper->outCharset=outCharset; 386 swapper->outCharset=outCharset;
338 387
339 swapper->readUInt16= inIsBigEndian==U_IS_BIG_ENDIAN ? uprv_readDirectUInt16 : uprv_readSwapUInt16; 388 swapper->readUInt16= inIsBigEndian==U_IS_BIG_ENDIAN ? uprv_readDirectUInt16 : uprv_readSwapUInt16;
340 swapper->readUInt32= inIsBigEndian==U_IS_BIG_ENDIAN ? uprv_readDirectUInt32 : uprv_readSwapUInt32; 389 swapper->readUInt32= inIsBigEndian==U_IS_BIG_ENDIAN ? uprv_readDirectUInt32 : uprv_readSwapUInt32;
341 390
342 swapper->writeUInt16= outIsBigEndian==U_IS_BIG_ENDIAN ? uprv_writeDirectUInt 16 : uprv_writeSwapUInt16; 391 swapper->writeUInt16= outIsBigEndian==U_IS_BIG_ENDIAN ? uprv_writeDirectUInt 16 : uprv_writeSwapUInt16;
343 swapper->writeUInt32= outIsBigEndian==U_IS_BIG_ENDIAN ? uprv_writeDirectUInt 32 : uprv_writeSwapUInt32; 392 swapper->writeUInt32= outIsBigEndian==U_IS_BIG_ENDIAN ? uprv_writeDirectUInt 32 : uprv_writeSwapUInt32;
344 393
345 swapper->compareInvChars= outCharset==U_ASCII_FAMILY ? uprv_compareInvAscii : uprv_compareInvEbcdic; 394 swapper->compareInvChars= outCharset==U_ASCII_FAMILY ? uprv_compareInvAscii : uprv_compareInvEbcdic;
346 395
347 swapper->swapArray16= inIsBigEndian==outIsBigEndian ? uprv_copyArray16 : upr v_swapArray16; 396 if(inIsBigEndian==outIsBigEndian) {
348 swapper->swapArray32= inIsBigEndian==outIsBigEndian ? uprv_copyArray32 : upr v_swapArray32; 397 swapper->swapArray16=uprv_copyArray16;
398 swapper->swapArray32=uprv_copyArray32;
399 swapper->swapArray64=uprv_copyArray64;
400 } else {
401 swapper->swapArray16=uprv_swapArray16;
402 swapper->swapArray32=uprv_swapArray32;
403 swapper->swapArray64=uprv_swapArray64;
404 }
349 405
350 if(inCharset==U_ASCII_FAMILY) { 406 if(inCharset==U_ASCII_FAMILY) {
351 swapper->swapInvChars= outCharset==U_ASCII_FAMILY ? uprv_copyAscii : upr v_ebcdicFromAscii; 407 swapper->swapInvChars= outCharset==U_ASCII_FAMILY ? uprv_copyAscii : upr v_ebcdicFromAscii;
352 } else /* U_EBCDIC_FAMILY */ { 408 } else /* U_EBCDIC_FAMILY */ {
353 swapper->swapInvChars= outCharset==U_EBCDIC_FAMILY ? uprv_copyEbcdic : u prv_asciiFromEbcdic; 409 swapper->swapInvChars= outCharset==U_EBCDIC_FAMILY ? uprv_copyEbcdic : u prv_asciiFromEbcdic;
354 } 410 }
355 411
356 return swapper; 412 return swapper;
357 } 413 }
358 414
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 return 0; 462 return 0;
407 } 463 }
408 464
409 return udata_openSwapper(inIsBigEndian, inCharset, outIsBigEndian, outCharse t, pErrorCode); 465 return udata_openSwapper(inIsBigEndian, inCharset, outIsBigEndian, outCharse t, pErrorCode);
410 } 466 }
411 467
412 U_CAPI void U_EXPORT2 468 U_CAPI void U_EXPORT2
413 udata_closeSwapper(UDataSwapper *ds) { 469 udata_closeSwapper(UDataSwapper *ds) {
414 uprv_free(ds); 470 uprv_free(ds);
415 } 471 }
OLDNEW
« no previous file with comments | « source/common/udataswp.h ('k') | source/common/uidna.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698