| OLD | NEW |
| 1 // Copyright 2007, Google Inc. | 1 // Copyright 2007, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #define ICU_UTIL_DATA_IMPL ICU_UTIL_DATA_SHARED | 48 #define ICU_UTIL_DATA_IMPL ICU_UTIL_DATA_SHARED |
| 49 #elif defined(OS_MACOSX) | 49 #elif defined(OS_MACOSX) |
| 50 #define ICU_UTIL_DATA_IMPL ICU_UTIL_DATA_STATIC | 50 #define ICU_UTIL_DATA_IMPL ICU_UTIL_DATA_STATIC |
| 51 #elif defined(OS_LINUX) | 51 #elif defined(OS_LINUX) |
| 52 #define ICU_UTIL_DATA_IMPL ICU_UTIL_DATA_FILE | 52 #define ICU_UTIL_DATA_IMPL ICU_UTIL_DATA_FILE |
| 53 #endif | 53 #endif |
| 54 | 54 |
| 55 #endif // ICU_UTIL_DATA_IMPL | 55 #endif // ICU_UTIL_DATA_IMPL |
| 56 | 56 |
| 57 #if defined(OS_WIN) | 57 #if defined(OS_WIN) |
| 58 #define ICU_UTIL_DATA_SYMBOL "icudt38_dat" | 58 #define ICU_UTIL_DATA_SYMBOL "icudt" U_ICU_VERSION_SHORT "_dat" |
| 59 #define ICU_UTIL_DATA_SHARED_MODULE_NAME L"icudt38.dll" | 59 #define ICU_UTIL_DATA_SHARED_MODULE_NAME "icudt" U_ICU_VERSION_SHORT ".dll" |
| 60 #endif | 60 #endif |
| 61 | 61 |
| 62 bool InitializeICU() { | 62 bool InitializeICU() { |
| 63 #if (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_SHARED) | 63 #if (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_SHARED) |
| 64 // We expect to find the ICU data module alongside the current module. | 64 // We expect to find the ICU data module alongside the current module. |
| 65 HMODULE module = LoadLibrary(ICU_UTIL_DATA_SHARED_MODULE_NAME); | 65 // Because the module name is ASCII-only, "A" API should be safe. |
| 66 HMODULE module = LoadLibraryA(ICU_UTIL_DATA_SHARED_MODULE_NAME); |
| 66 if (!module) | 67 if (!module) |
| 67 return false; | 68 return false; |
| 68 | 69 |
| 69 FARPROC addr = GetProcAddress(module, ICU_UTIL_DATA_SYMBOL); | 70 FARPROC addr = GetProcAddress(module, ICU_UTIL_DATA_SYMBOL); |
| 70 if (!addr) | 71 if (!addr) |
| 71 return false; | 72 return false; |
| 72 | 73 |
| 73 UErrorCode err = U_ZERO_ERROR; | 74 UErrorCode err = U_ZERO_ERROR; |
| 74 udata_setCommonData(reinterpret_cast<void*>(addr), &err); | 75 udata_setCommonData(reinterpret_cast<void*>(addr), &err); |
| 75 return err == U_ZERO_ERROR; | 76 return err == U_ZERO_ERROR; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 87 #endif | 88 #endif |
| 88 } | 89 } |
| 89 | 90 |
| 90 int main(int argc, char **argv) { | 91 int main(int argc, char **argv) { |
| 91 ::testing::InitGoogleTest(&argc, argv); | 92 ::testing::InitGoogleTest(&argc, argv); |
| 92 | 93 |
| 93 InitializeICU(); | 94 InitializeICU(); |
| 94 | 95 |
| 95 return RUN_ALL_TESTS(); | 96 return RUN_ALL_TESTS(); |
| 96 } | 97 } |
| OLD | NEW |