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

Side by Side Diff: source/tools/makeconv/gencnvex.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/tools/icuswap/icuswap.vcxproj ('k') | source/tools/makeconv/makeconv.c » ('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-2013, 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: gencnvex.c 8 * file name: gencnvex.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: 2003oct12 13 * created on: 2003oct12
14 * created by: Markus W. Scherer 14 * created by: Markus W. Scherer
15 */ 15 */
16 16
17 #include <stdio.h> 17 #include <stdio.h>
18 #include "unicode/utypes.h" 18 #include "unicode/utypes.h"
19 #include "unicode/ustring.h" 19 #include "unicode/ustring.h"
20 #include "cstring.h" 20 #include "cstring.h"
21 #include "cmemory.h" 21 #include "cmemory.h"
22 #include "ucnv_cnv.h" 22 #include "ucnv_cnv.h"
23 #include "ucnvmbcs.h" 23 #include "ucnvmbcs.h"
24 #include "toolutil.h" 24 #include "toolutil.h"
25 #include "unewdata.h" 25 #include "unewdata.h"
26 #include "ucm.h" 26 #include "ucm.h"
27 #include "makeconv.h" 27 #include "makeconv.h"
28 #include "genmbcs.h" 28 #include "genmbcs.h"
29 29
30 #define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
31
32
33 static void 30 static void
34 CnvExtClose(NewConverter *cnvData); 31 CnvExtClose(NewConverter *cnvData);
35 32
36 static UBool 33 static UBool
37 CnvExtIsValid(NewConverter *cnvData, 34 CnvExtIsValid(NewConverter *cnvData,
38 const uint8_t *bytes, int32_t length); 35 const uint8_t *bytes, int32_t length);
39 36
40 static UBool 37 static UBool
41 CnvExtAddTable(NewConverter *cnvData, UCMTable *table, UConverterStaticData *sta ticData); 38 CnvExtAddTable(NewConverter *cnvData, UCMTable *table, UConverterStaticData *sta ticData);
42 39
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 if(extData->stage1[i1]==0) { 839 if(extData->stage1[i1]==0) {
843 /* allocate another block in stage 2; overlap with the previous block */ 840 /* allocate another block in stage 2; overlap with the previous block */
844 newBlock=extData->stage2Top; 841 newBlock=extData->stage2Top;
845 min=newBlock-nextOffset; /* minimum block start with overlap */ 842 min=newBlock-nextOffset; /* minimum block start with overlap */
846 while(min<newBlock && extData->stage2[newBlock-1]==0) { 843 while(min<newBlock && extData->stage2[newBlock-1]==0) {
847 --newBlock; 844 --newBlock;
848 } 845 }
849 846
850 extData->stage1[i1]=(uint16_t)newBlock; 847 extData->stage1[i1]=(uint16_t)newBlock;
851 extData->stage2Top=newBlock+MBCS_STAGE_2_BLOCK_SIZE; 848 extData->stage2Top=newBlock+MBCS_STAGE_2_BLOCK_SIZE;
852 if(extData->stage2Top>LENGTHOF(extData->stage2)) { 849 if(extData->stage2Top>UPRV_LENGTHOF(extData->stage2)) {
853 fprintf(stderr, "error: too many stage 2 entries at U+%04x\n", (int) c); 850 fprintf(stderr, "error: too many stage 2 entries at U+%04x\n", (int) c);
854 exit(U_MEMORY_ALLOCATION_ERROR); 851 exit(U_MEMORY_ALLOCATION_ERROR);
855 } 852 }
856 } 853 }
857 854
858 i2=extData->stage1[i1]+nextOffset; 855 i2=extData->stage1[i1]+nextOffset;
859 nextOffset=c&0xf; 856 nextOffset=c&0xf;
860 857
861 if(extData->stage2[i2]==0) { 858 if(extData->stage2[i2]==0) {
862 /* allocate another block in stage 3; overlap with the previous block */ 859 /* allocate another block in stage 3; overlap with the previous block */
863 newBlock=extData->stage3Top; 860 newBlock=extData->stage3Top;
864 min=newBlock-nextOffset; /* minimum block start with overlap */ 861 min=newBlock-nextOffset; /* minimum block start with overlap */
865 while(min<newBlock && extData->stage3[newBlock-1]==0) { 862 while(min<newBlock && extData->stage3[newBlock-1]==0) {
866 --newBlock; 863 --newBlock;
867 } 864 }
868 865
869 /* round up to a multiple of stage 3 granularity >1 (similar to utrie.c) */ 866 /* round up to a multiple of stage 3 granularity >1 (similar to utrie.c) */
870 newBlock=(newBlock+(UCNV_EXT_STAGE_3_GRANULARITY-1))&~(UCNV_EXT_STAGE_3_ GRANULARITY-1); 867 newBlock=(newBlock+(UCNV_EXT_STAGE_3_GRANULARITY-1))&~(UCNV_EXT_STAGE_3_ GRANULARITY-1);
871 extData->stage2[i2]=(uint16_t)(newBlock>>UCNV_EXT_STAGE_2_LEFT_SHIFT); 868 extData->stage2[i2]=(uint16_t)(newBlock>>UCNV_EXT_STAGE_2_LEFT_SHIFT);
872 869
873 extData->stage3Top=newBlock+MBCS_STAGE_3_BLOCK_SIZE; 870 extData->stage3Top=newBlock+MBCS_STAGE_3_BLOCK_SIZE;
874 if(extData->stage3Top>LENGTHOF(extData->stage3)) { 871 if(extData->stage3Top>UPRV_LENGTHOF(extData->stage3)) {
875 fprintf(stderr, "error: too many stage 3 entries at U+%04x\n", (int) c); 872 fprintf(stderr, "error: too many stage 3 entries at U+%04x\n", (int) c);
876 exit(U_MEMORY_ALLOCATION_ERROR); 873 exit(U_MEMORY_ALLOCATION_ERROR);
877 } 874 }
878 } 875 }
879 876
880 i3=((int32_t)extData->stage2[i2]<<UCNV_EXT_STAGE_2_LEFT_SHIFT)+nextOffset; 877 i3=((int32_t)extData->stage2[i2]<<UCNV_EXT_STAGE_2_LEFT_SHIFT)+nextOffset;
881 /* 878 /*
882 * assume extData->stage3[i3]==0 because we get 879 * assume extData->stage3[i3]==0 because we get
883 * code points in strictly ascending order 880 * code points in strictly ascending order
884 */ 881 */
(...skipping 23 matching lines...) Expand all
908 extData->stage2[i2]=extData->stage3Sub1Block; 905 extData->stage2[i2]=extData->stage3Sub1Block;
909 extData->stage3Top-=MBCS_STAGE_3_BLOCK_SIZE; 906 extData->stage3Top-=MBCS_STAGE_3_BLOCK_SIZE;
910 uprv_memset(extData->stage3+extData->stage3Top, 0, MBCS_STAG E_3_BLOCK_SIZE*2); 907 uprv_memset(extData->stage3+extData->stage3Top, 0, MBCS_STAG E_3_BLOCK_SIZE*2);
911 } else { 908 } else {
912 /* remember this block's stage2 entry */ 909 /* remember this block's stage2 entry */
913 extData->stage3Sub1Block=extData->stage2[i2]; 910 extData->stage3Sub1Block=extData->stage2[i2];
914 } 911 }
915 } 912 }
916 } 913 }
917 } else { 914 } else {
918 if((i3b=extData->stage3bTop++)>=LENGTHOF(extData->stage3b)) { 915 if((i3b=extData->stage3bTop++)>=UPRV_LENGTHOF(extData->stage3b)) {
919 fprintf(stderr, "error: too many stage 3b entries at U+%04x\n", (int )c); 916 fprintf(stderr, "error: too many stage 3b entries at U+%04x\n", (int )c);
920 exit(U_MEMORY_ALLOCATION_ERROR); 917 exit(U_MEMORY_ALLOCATION_ERROR);
921 } 918 }
922 919
923 /* roundtrip or fallback mapping */ 920 /* roundtrip or fallback mapping */
924 extData->stage3[i3]=(uint16_t)i3b; 921 extData->stage3[i3]=(uint16_t)i3b;
925 extData->stage3b[i3b]=value; 922 extData->stage3b[i3b]=value;
926 } 923 }
927 } 924 }
928 925
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 * assume that the table is sorted 1067 * assume that the table is sorted
1071 * 1068 *
1072 * call the functions in this order because 1069 * call the functions in this order because
1073 * makeToUTable() modifies the original reverseMap, 1070 * makeToUTable() modifies the original reverseMap,
1074 * makeFromUTable() writes a whole new mapping into reverseMap 1071 * makeFromUTable() writes a whole new mapping into reverseMap
1075 */ 1072 */
1076 return 1073 return
1077 makeToUTable(extData, table) && 1074 makeToUTable(extData, table) &&
1078 makeFromUTable(extData, table); 1075 makeFromUTable(extData, table);
1079 } 1076 }
OLDNEW
« no previous file with comments | « source/tools/icuswap/icuswap.vcxproj ('k') | source/tools/makeconv/makeconv.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698