OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/icu_util.h" | 5 #include "src/icu_util.h" |
6 | 6 |
7 #if defined(_WIN32) | 7 #if defined(_WIN32) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #endif | 9 #endif |
10 | 10 |
11 #if defined(V8_I18N_SUPPORT) | 11 #if defined(V8_I18N_SUPPORT) |
12 #include <stdio.h> | 12 #include <stdio.h> |
13 #include <stdlib.h> | 13 #include <stdlib.h> |
14 | 14 |
15 #include "unicode/putil.h" | 15 #include "unicode/putil.h" |
16 #include "unicode/udata.h" | 16 #include "unicode/udata.h" |
17 | 17 |
| 18 #include "src/base/build_config.h" |
18 #include "src/base/file-utils.h" | 19 #include "src/base/file-utils.h" |
19 | 20 |
20 #define ICU_UTIL_DATA_FILE 0 | 21 #define ICU_UTIL_DATA_FILE 0 |
21 #define ICU_UTIL_DATA_SHARED 1 | 22 #define ICU_UTIL_DATA_SHARED 1 |
22 #define ICU_UTIL_DATA_STATIC 2 | 23 #define ICU_UTIL_DATA_STATIC 2 |
23 | 24 |
24 #define ICU_UTIL_DATA_SYMBOL "icudt" U_ICU_VERSION_SHORT "_dat" | 25 #define ICU_UTIL_DATA_SYMBOL "icudt" U_ICU_VERSION_SHORT "_dat" |
25 #define ICU_UTIL_DATA_SHARED_MODULE_NAME "icudt.dll" | 26 #define ICU_UTIL_DATA_SHARED_MODULE_NAME "icudt.dll" |
26 #endif | 27 #endif |
27 | 28 |
(...skipping 15 matching lines...) Expand all Loading... |
43 bool InitializeICUDefaultLocation(const char* exec_path, | 44 bool InitializeICUDefaultLocation(const char* exec_path, |
44 const char* icu_data_file) { | 45 const char* icu_data_file) { |
45 #if !defined(V8_I18N_SUPPORT) | 46 #if !defined(V8_I18N_SUPPORT) |
46 return true; | 47 return true; |
47 #else | 48 #else |
48 #if ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE | 49 #if ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE |
49 if (icu_data_file) { | 50 if (icu_data_file) { |
50 return InitializeICU(icu_data_file); | 51 return InitializeICU(icu_data_file); |
51 } | 52 } |
52 char* icu_data_file_default; | 53 char* icu_data_file_default; |
| 54 #if defined(V8_TARGET_LITTLE_ENDIAN) |
53 RelativePath(&icu_data_file_default, exec_path, "icudtl.dat"); | 55 RelativePath(&icu_data_file_default, exec_path, "icudtl.dat"); |
| 56 #elif defined(V8_TARGET_BIG_ENDIAN) |
| 57 RelativePath(&icu_data_file_default, exec_path, "icudtb.dat"); |
| 58 #else |
| 59 #error Unknown byte ordering |
| 60 #endif |
54 bool result = InitializeICU(icu_data_file_default); | 61 bool result = InitializeICU(icu_data_file_default); |
55 free(icu_data_file_default); | 62 free(icu_data_file_default); |
56 return result; | 63 return result; |
57 #else | 64 #else |
58 return InitializeICU(NULL); | 65 return InitializeICU(NULL); |
59 #endif | 66 #endif |
60 #endif | 67 #endif |
61 } | 68 } |
62 | 69 |
63 bool InitializeICU(const char* icu_data_file) { | 70 bool InitializeICU(const char* icu_data_file) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 110 |
104 UErrorCode err = U_ZERO_ERROR; | 111 UErrorCode err = U_ZERO_ERROR; |
105 udata_setCommonData(reinterpret_cast<void*>(g_icu_data_ptr), &err); | 112 udata_setCommonData(reinterpret_cast<void*>(g_icu_data_ptr), &err); |
106 return err == U_ZERO_ERROR; | 113 return err == U_ZERO_ERROR; |
107 #endif | 114 #endif |
108 #endif | 115 #endif |
109 } | 116 } |
110 | 117 |
111 } // namespace internal | 118 } // namespace internal |
112 } // namespace v8 | 119 } // namespace v8 |
OLD | NEW |