| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  ******************************************************************** | 2  ******************************************************************** | 
| 3  * COPYRIGHT: | 3  * COPYRIGHT: | 
| 4  * Copyright (c) 1996-2013, International Business Machines Corporation and | 4  * Copyright (c) 1996-2015, International Business Machines Corporation and | 
| 5  * others. All Rights Reserved. | 5  * others. All Rights Reserved. | 
| 6  ******************************************************************** | 6  ******************************************************************** | 
| 7  * | 7  * | 
| 8  *  uconv_bld.cpp: | 8  *  ucnv_bld.cpp: | 
| 9  * | 9  * | 
| 10  *  Defines functions that are used in the creation/initialization/deletion | 10  *  Defines functions that are used in the creation/initialization/deletion | 
| 11  *  of converters and related structures. | 11  *  of converters and related structures. | 
| 12  *  uses uconv_io.h routines to access disk information | 12  *  uses uconv_io.h routines to access disk information | 
| 13  *  is used by ucnv.h to implement public API create/delete/flushCache routines | 13  *  is used by ucnv.h to implement public API create/delete/flushCache routines | 
| 14  * Modification History: | 14  * Modification History: | 
| 15  * | 15  * | 
| 16  *   Date        Name        Description | 16  *   Date        Name        Description | 
| 17  * | 17  * | 
| 18  *   06/20/2000  helena      OS/400 port changes; mostly typecast. | 18  *   06/20/2000  helena      OS/400 port changes; mostly typecast. | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 57 converterData[UCNV_NUMBER_OF_SUPPORTED_CONVERTER_TYPES]={ | 57 converterData[UCNV_NUMBER_OF_SUPPORTED_CONVERTER_TYPES]={ | 
| 58     NULL, NULL, | 58     NULL, NULL, | 
| 59 | 59 | 
| 60 #if UCONFIG_NO_LEGACY_CONVERSION | 60 #if UCONFIG_NO_LEGACY_CONVERSION | 
| 61     NULL, | 61     NULL, | 
| 62 #else | 62 #else | 
| 63     &_MBCSData, | 63     &_MBCSData, | 
| 64 #endif | 64 #endif | 
| 65 | 65 | 
| 66     &_Latin1Data, | 66     &_Latin1Data, | 
| 67     &_UTF8Data, &_UTF16BEData, &_UTF16LEData, &_UTF32BEData, &_UTF32LEData, | 67     &_UTF8Data, &_UTF16BEData, &_UTF16LEData, | 
|  | 68 #if UCONFIG_ONLY_HTML_CONVERSION | 
|  | 69     NULL, NULL, | 
|  | 70 #else | 
|  | 71     &_UTF32BEData, &_UTF32LEData, | 
|  | 72 #endif | 
| 68     NULL, | 73     NULL, | 
| 69 | 74 | 
| 70 #if UCONFIG_NO_LEGACY_CONVERSION | 75 #if UCONFIG_NO_LEGACY_CONVERSION | 
| 71     NULL, | 76     NULL, | 
| 72 #else | 77 #else | 
| 73     &_ISO2022Data, | 78     &_ISO2022Data, | 
| 74 #endif | 79 #endif | 
| 75 | 80 | 
| 76 #if UCONFIG_NO_LEGACY_CONVERSION || UCONFIG_NO_NON_HTML5_CONVERSION | 81 #if UCONFIG_NO_LEGACY_CONVERSION || UCONFIG_ONLY_HTML_CONVERSION | 
| 77     NULL, NULL, NULL, NULL, NULL, NULL, | 82     NULL, NULL, NULL, NULL, NULL, NULL, | 
| 78     NULL, NULL, NULL, NULL, NULL, NULL, | 83     NULL, NULL, NULL, NULL, NULL, NULL, | 
| 79     NULL, | 84     NULL, | 
| 80 #else | 85 #else | 
| 81     &_LMBCSData1,&_LMBCSData2, &_LMBCSData3, &_LMBCSData4, &_LMBCSData5, &_LMBCS
      Data6, | 86     &_LMBCSData1,&_LMBCSData2, &_LMBCSData3, &_LMBCSData4, &_LMBCSData5, &_LMBCS
      Data6, | 
| 82     &_LMBCSData8,&_LMBCSData11,&_LMBCSData16,&_LMBCSData17,&_LMBCSData18,&_LMBCS
      Data19, | 87     &_LMBCSData8,&_LMBCSData11,&_LMBCSData16,&_LMBCSData17,&_LMBCSData18,&_LMBCS
      Data19, | 
| 83     &_HZData, | 88     &_HZData, | 
| 84 #endif | 89 #endif | 
| 85 | 90 | 
| 86 #if UCONFIG_NO_NON_HTML5_CONVERSION | 91 #if UCONFIG_ONLY_HTML_CONVERSION | 
| 87     NULL, | 92     NULL, | 
| 88 #else | 93 #else | 
| 89     &_SCSUData, | 94     &_SCSUData, | 
| 90 #endif | 95 #endif | 
| 91 | 96 | 
| 92 | 97 | 
| 93 #if UCONFIG_NO_LEGACY_CONVERSION || UCONFIG_NO_NON_HTML5_CONVERSION | 98 #if UCONFIG_NO_LEGACY_CONVERSION || UCONFIG_ONLY_HTML_CONVERSION | 
| 94     NULL, | 99     NULL, | 
| 95 #else | 100 #else | 
| 96     &_ISCIIData, | 101     &_ISCIIData, | 
| 97 #endif | 102 #endif | 
| 98 | 103 | 
| 99     &_ASCIIData, | 104     &_ASCIIData, | 
| 100 #if UCONFIG_NO_NON_HTML5_CONVERSION | 105 #if UCONFIG_ONLY_HTML_CONVERSION | 
| 101     NULL, NULL, &_UTF16Data, &_UTF32Data, NULL, NULL, | 106     NULL, NULL, &_UTF16Data, NULL, NULL, NULL, | 
| 102 #else | 107 #else | 
| 103     &_UTF7Data, &_Bocu1Data, &_UTF16Data, &_UTF32Data, &_CESU8Data, &_IMAPData, | 108     &_UTF7Data, &_Bocu1Data, &_UTF16Data, &_UTF32Data, &_CESU8Data, &_IMAPData, | 
| 104 #endif | 109 #endif | 
| 105 | 110 | 
| 106 #if UCONFIG_NO_LEGACY_CONVERSION || UCONFIG_NO_NON_HTML5_CONVERSION | 111 #if UCONFIG_NO_LEGACY_CONVERSION || UCONFIG_ONLY_HTML_CONVERSION | 
| 107     NULL, | 112     NULL, | 
| 108 #else | 113 #else | 
| 109     &_CompoundTextData | 114     &_CompoundTextData | 
| 110 #endif | 115 #endif | 
| 111 }; | 116 }; | 
| 112 | 117 | 
| 113 /* Please keep this in binary sorted order for getAlgorithmicTypeFromName. | 118 /* Please keep this in binary sorted order for getAlgorithmicTypeFromName. | 
| 114    Also the name should be in lower case and all spaces, dashes and underscores | 119    Also the name should be in lower case and all spaces, dashes and underscores | 
| 115    removed | 120    removed | 
| 116 */ | 121 */ | 
| 117 static struct { | 122 static struct { | 
| 118   const char *name; | 123   const char *name; | 
| 119   const UConverterType type; | 124   const UConverterType type; | 
| 120 } const cnvNameType[] = { | 125 } const cnvNameType[] = { | 
| 121 #if !UCONFIG_NO_NON_HTML5_CONVERSION | 126 #if !UCONFIG_ONLY_HTML_CONVERSION | 
| 122   { "bocu1", UCNV_BOCU1 }, | 127   { "bocu1", UCNV_BOCU1 }, | 
| 123   { "cesu8", UCNV_CESU8 }, | 128   { "cesu8", UCNV_CESU8 }, | 
| 124 #endif | 129 #endif | 
| 125 #if !UCONFIG_NO_LEGACY_CONVERSION && !UCONFIG_NO_NON_HTML5_CONVERSION | 130 #if !UCONFIG_NO_LEGACY_CONVERSION && !UCONFIG_ONLY_HTML_CONVERSION | 
| 126   { "hz",UCNV_HZ }, | 131   { "hz",UCNV_HZ }, | 
| 127 #endif | 132 #endif | 
| 128 #if !UCONFIG_NO_NON_HTML5_CONVERSION | 133 #if !UCONFIG_ONLY_HTML_CONVERSION | 
| 129   { "imapmailboxname", UCNV_IMAP_MAILBOX }, | 134   { "imapmailboxname", UCNV_IMAP_MAILBOX }, | 
| 130 #endif | 135 #endif | 
| 131 #if !UCONFIG_NO_LEGACY_CONVERSION && !UCONFIG_NO_NON_HTML5_CONVERSION | 136 #if !UCONFIG_NO_LEGACY_CONVERSION && !UCONFIG_ONLY_HTML_CONVERSION | 
| 132   { "iscii", UCNV_ISCII }, | 137   { "iscii", UCNV_ISCII }, | 
| 133 #endif | 138 #endif | 
| 134 #if !UCONFIG_NO_LEGACY_CONVERSION | 139 #if !UCONFIG_NO_LEGACY_CONVERSION | 
| 135   { "iso2022", UCNV_ISO_2022 }, | 140   { "iso2022", UCNV_ISO_2022 }, | 
| 136 #endif | 141 #endif | 
| 137   { "iso88591", UCNV_LATIN_1 }, | 142   { "iso88591", UCNV_LATIN_1 }, | 
| 138 #if !UCONFIG_NO_LEGACY_CONVERSION && !UCONFIG_NO_NON_HTML5_CONVERSION | 143 #if !UCONFIG_NO_LEGACY_CONVERSION && !UCONFIG_ONLY_HTML_CONVERSION | 
| 139   { "lmbcs1", UCNV_LMBCS_1 }, | 144   { "lmbcs1", UCNV_LMBCS_1 }, | 
| 140   { "lmbcs11",UCNV_LMBCS_11 }, | 145   { "lmbcs11",UCNV_LMBCS_11 }, | 
| 141   { "lmbcs16",UCNV_LMBCS_16 }, | 146   { "lmbcs16",UCNV_LMBCS_16 }, | 
| 142   { "lmbcs17",UCNV_LMBCS_17 }, | 147   { "lmbcs17",UCNV_LMBCS_17 }, | 
| 143   { "lmbcs18",UCNV_LMBCS_18 }, | 148   { "lmbcs18",UCNV_LMBCS_18 }, | 
| 144   { "lmbcs19",UCNV_LMBCS_19 }, | 149   { "lmbcs19",UCNV_LMBCS_19 }, | 
| 145   { "lmbcs2", UCNV_LMBCS_2 }, | 150   { "lmbcs2", UCNV_LMBCS_2 }, | 
| 146   { "lmbcs3", UCNV_LMBCS_3 }, | 151   { "lmbcs3", UCNV_LMBCS_3 }, | 
| 147   { "lmbcs4", UCNV_LMBCS_4 }, | 152   { "lmbcs4", UCNV_LMBCS_4 }, | 
| 148   { "lmbcs5", UCNV_LMBCS_5 }, | 153   { "lmbcs5", UCNV_LMBCS_5 }, | 
| 149   { "lmbcs6", UCNV_LMBCS_6 }, | 154   { "lmbcs6", UCNV_LMBCS_6 }, | 
| 150   { "lmbcs8", UCNV_LMBCS_8 }, | 155   { "lmbcs8", UCNV_LMBCS_8 }, | 
| 151 #endif | 156 #endif | 
| 152 #if !UCONFIG_NO_NON_HTML5_CONVERSION | 157 #if !UCONFIG_ONLY_HTML_CONVERSION | 
| 153   { "scsu", UCNV_SCSU }, | 158   { "scsu", UCNV_SCSU }, | 
| 154 #endif | 159 #endif | 
| 155   { "usascii", UCNV_US_ASCII }, | 160   { "usascii", UCNV_US_ASCII }, | 
| 156   { "utf16", UCNV_UTF16 }, | 161   { "utf16", UCNV_UTF16 }, | 
| 157   { "utf16be", UCNV_UTF16_BigEndian }, | 162   { "utf16be", UCNV_UTF16_BigEndian }, | 
| 158   { "utf16le", UCNV_UTF16_LittleEndian }, | 163   { "utf16le", UCNV_UTF16_LittleEndian }, | 
| 159 #if U_IS_BIG_ENDIAN | 164 #if U_IS_BIG_ENDIAN | 
| 160   { "utf16oppositeendian", UCNV_UTF16_LittleEndian }, | 165   { "utf16oppositeendian", UCNV_UTF16_LittleEndian }, | 
| 161   { "utf16platformendian", UCNV_UTF16_BigEndian }, | 166   { "utf16platformendian", UCNV_UTF16_BigEndian }, | 
| 162 #else | 167 #else | 
| 163   { "utf16oppositeendian", UCNV_UTF16_BigEndian}, | 168   { "utf16oppositeendian", UCNV_UTF16_BigEndian}, | 
| 164   { "utf16platformendian", UCNV_UTF16_LittleEndian }, | 169   { "utf16platformendian", UCNV_UTF16_LittleEndian }, | 
| 165 #endif | 170 #endif | 
|  | 171 #if !UCONFIG_ONLY_HTML_CONVERSION | 
| 166   { "utf32", UCNV_UTF32 }, | 172   { "utf32", UCNV_UTF32 }, | 
| 167   { "utf32be", UCNV_UTF32_BigEndian }, | 173   { "utf32be", UCNV_UTF32_BigEndian }, | 
| 168   { "utf32le", UCNV_UTF32_LittleEndian }, | 174   { "utf32le", UCNV_UTF32_LittleEndian }, | 
| 169 #if U_IS_BIG_ENDIAN | 175 #if U_IS_BIG_ENDIAN | 
| 170   { "utf32oppositeendian", UCNV_UTF32_LittleEndian }, | 176   { "utf32oppositeendian", UCNV_UTF32_LittleEndian }, | 
| 171   { "utf32platformendian", UCNV_UTF32_BigEndian }, | 177   { "utf32platformendian", UCNV_UTF32_BigEndian }, | 
| 172 #else | 178 #else | 
| 173   { "utf32oppositeendian", UCNV_UTF32_BigEndian }, | 179   { "utf32oppositeendian", UCNV_UTF32_BigEndian }, | 
| 174   { "utf32platformendian", UCNV_UTF32_LittleEndian }, | 180   { "utf32platformendian", UCNV_UTF32_LittleEndian }, | 
| 175 #endif | 181 #endif | 
| 176 #if !UCONFIG_NO_NON_HTML5_CONVERSION | 182 #endif | 
|  | 183 #if !UCONFIG_ONLY_HTML_CONVERSION | 
| 177   { "utf7", UCNV_UTF7 }, | 184   { "utf7", UCNV_UTF7 }, | 
| 178 #endif | 185 #endif | 
| 179   { "utf8", UCNV_UTF8 }, | 186   { "utf8", UCNV_UTF8 }, | 
| 180 #if !UCONFIG_NO_NON_HTML5_CONVERSION | 187 #if !UCONFIG_ONLY_HTML_CONVERSION | 
| 181   { "x11compoundtext", UCNV_COMPOUND_TEXT} | 188   { "x11compoundtext", UCNV_COMPOUND_TEXT} | 
| 182 #endif | 189 #endif | 
| 183 }; | 190 }; | 
| 184 | 191 | 
| 185 | 192 | 
| 186 /*initializes some global variables */ | 193 /*initializes some global variables */ | 
| 187 static UHashtable *SHARED_DATA_HASHTABLE = NULL; | 194 static UHashtable *SHARED_DATA_HASHTABLE = NULL; | 
| 188 static UMutex cnvCacheMutex = U_MUTEX_INITIALIZER;  /* Mutex for synchronizing c
      nv cache access. */ | 195 static UMutex cnvCacheMutex = U_MUTEX_INITIALIZER;  /* Mutex for synchronizing c
      nv cache access. */ | 
| 189                                                     /*  Note:  the global mutex 
      is used for      */ | 196                                                     /*  Note:  the global mutex 
      is used for      */ | 
| 190                                                     /*         reference count u
      pdates.          */ | 197                                                     /*         reference count u
      pdates.          */ | 
| (...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1050     umtx_lock(&cnvCacheMutex); | 1057     umtx_lock(&cnvCacheMutex); | 
| 1051     /* | 1058     /* | 
| 1052      * double loop: A delta/extension-only converter has a pointer to its base t
      able's | 1059      * double loop: A delta/extension-only converter has a pointer to its base t
      able's | 
| 1053      * shared data; the first iteration of the outer loop may see the delta conv
      erter | 1060      * shared data; the first iteration of the outer loop may see the delta conv
      erter | 
| 1054      * before the base converter, and unloading the delta converter may get the 
      base | 1061      * before the base converter, and unloading the delta converter may get the 
      base | 
| 1055      * converter's reference counter down to 0. | 1062      * converter's reference counter down to 0. | 
| 1056      */ | 1063      */ | 
| 1057     i = 0; | 1064     i = 0; | 
| 1058     do { | 1065     do { | 
| 1059         remaining = 0; | 1066         remaining = 0; | 
| 1060         pos = -1; | 1067         pos = UHASH_FIRST; | 
| 1061         while ((e = uhash_nextElement (SHARED_DATA_HASHTABLE, &pos)) != NULL) | 1068         while ((e = uhash_nextElement (SHARED_DATA_HASHTABLE, &pos)) != NULL) | 
| 1062         { | 1069         { | 
| 1063             mySharedData = (UConverterSharedData *) e->value.pointer; | 1070             mySharedData = (UConverterSharedData *) e->value.pointer; | 
| 1064             /*deletes only if reference counter == 0 */ | 1071             /*deletes only if reference counter == 0 */ | 
| 1065             if (mySharedData->referenceCounter == 0) | 1072             if (mySharedData->referenceCounter == 0) | 
| 1066             { | 1073             { | 
| 1067                 tableDeletedNum++; | 1074                 tableDeletedNum++; | 
| 1068 | 1075 | 
| 1069                 UCNV_DEBUG_LOG("del",mySharedData->staticData->name,mySharedData
      ); | 1076                 UCNV_DEBUG_LOG("del",mySharedData->staticData->name,mySharedData
      ); | 
| 1070 | 1077 | 
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1666         *pErrorCode=U_UNSUPPORTED_ERROR; | 1673         *pErrorCode=U_UNSUPPORTED_ERROR; | 
| 1667         return 0; | 1674         return 0; | 
| 1668     } | 1675     } | 
| 1669 | 1676 | 
| 1670     return headerSize+(int32_t)staticDataSize+size; | 1677     return headerSize+(int32_t)staticDataSize+size; | 
| 1671 } | 1678 } | 
| 1672 | 1679 | 
| 1673 #endif /* #if !UCONFIG_NO_LEGACY_CONVERSION */ | 1680 #endif /* #if !UCONFIG_NO_LEGACY_CONVERSION */ | 
| 1674 | 1681 | 
| 1675 #endif | 1682 #endif | 
| OLD | NEW | 
|---|