mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 21:23:03 +01:00
Fixed CORE-3447 - Collation is not installed with icu > 4.2.
This commit is contained in:
parent
38ab7278a2
commit
5e4be8ebf5
@ -61,8 +61,11 @@ private:
|
||||
ICU& operator =(const ICU&); // not implemented
|
||||
|
||||
public:
|
||||
ICU()
|
||||
: inModule(NULL), ucModule(NULL)
|
||||
ICU(int aMajorVersion, int aMinorVersion)
|
||||
: majorVersion(aMajorVersion),
|
||||
minorVersion(aMinorVersion),
|
||||
inModule(NULL),
|
||||
ucModule(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
@ -72,6 +75,21 @@ public:
|
||||
delete inModule;
|
||||
}
|
||||
|
||||
template <typename T> void getEntryPoint(const char* name, ModuleLoader::Module* module, T& ptr)
|
||||
{
|
||||
string symbol;
|
||||
|
||||
symbol.printf("%s_%d_%d", name, majorVersion, minorVersion);
|
||||
module->findSymbol(symbol, ptr);
|
||||
if (ptr)
|
||||
return;
|
||||
|
||||
symbol.printf("%s_%d%d", name, majorVersion, minorVersion);
|
||||
module->findSymbol(symbol, ptr);
|
||||
}
|
||||
|
||||
int majorVersion;
|
||||
int minorVersion;
|
||||
ModuleLoader::Module* inModule;
|
||||
ModuleLoader::Module* ucModule;
|
||||
UVersionInfo collVersion;
|
||||
@ -740,17 +758,17 @@ UnicodeUtil::ICU* UnicodeUtil::loadICU(const Firebird::string& icuVersion,
|
||||
const Firebird::string& configInfo)
|
||||
{
|
||||
#if defined(WIN_NT)
|
||||
const char* const inTemplate = "icuin%s%s.dll";
|
||||
const char* const ucTemplate = "icuuc%s%s.dll";
|
||||
const char* const inTemplate = "icuin%d%d.dll";
|
||||
const char* const ucTemplate = "icuuc%d%d.dll";
|
||||
#elif defined(DARWIN)
|
||||
const char* const inTemplate = "/Library/Frameworks/Firebird.framework/Versions/A/Libraries/libicui18n.dylib";
|
||||
const char* const ucTemplate = "/Library/Frameworks/Firebird.framework/versions/A/Libraries/libicuuc.dylib";
|
||||
#elif defined(HPUX)
|
||||
const char* const inTemplate = "libicui18n.sl.%s%s";
|
||||
const char* const ucTemplate = "libicuuc.sl.%s%s";
|
||||
const char* const inTemplate = "libicui18n.sl.%d%d";
|
||||
const char* const ucTemplate = "libicuuc.sl.%d%d";
|
||||
#else
|
||||
const char* const inTemplate = "libicui18n.so.%s%s";
|
||||
const char* const ucTemplate = "libicuuc.so.%s%s";
|
||||
const char* const inTemplate = "libicui18n.so.%d%d";
|
||||
const char* const ucTemplate = "libicuuc.so.%d%d";
|
||||
#endif
|
||||
|
||||
ObjectsArray<string> versions;
|
||||
@ -764,41 +782,32 @@ UnicodeUtil::ICU* UnicodeUtil::loadICU(const Firebird::string& icuVersion,
|
||||
|
||||
for (ObjectsArray<string>::const_iterator i(versions.begin()); i != versions.end(); ++i)
|
||||
{
|
||||
string majorVersion;
|
||||
string minorVersion;
|
||||
int majorVersion, minorVersion;
|
||||
|
||||
if (*i == "default")
|
||||
{
|
||||
majorVersion = STRINGIZE(U_ICU_VERSION_MAJOR_NUM);
|
||||
minorVersion = STRINGIZE(U_ICU_VERSION_MINOR_NUM);
|
||||
majorVersion = U_ICU_VERSION_MAJOR_NUM;
|
||||
minorVersion = U_ICU_VERSION_MINOR_NUM;
|
||||
}
|
||||
else
|
||||
{
|
||||
const size_t pos = i->find('.');
|
||||
if (pos == i->npos)
|
||||
else if (sscanf(i->c_str(), "%d.%d", &majorVersion, &minorVersion) != 2)
|
||||
continue;
|
||||
|
||||
majorVersion = i->substr(0, pos);
|
||||
minorVersion = i->substr(pos + 1);
|
||||
}
|
||||
string configVersion;
|
||||
configVersion.printf("%d.%d", majorVersion, minorVersion);
|
||||
|
||||
if (version != majorVersion + "." + minorVersion)
|
||||
{
|
||||
if (version != configVersion)
|
||||
continue;
|
||||
}
|
||||
|
||||
ReadLockGuard readGuard(icuModules->lock);
|
||||
|
||||
ICU* icu;
|
||||
if (icuModules->modules().get(version, icu))
|
||||
{
|
||||
return icu;
|
||||
}
|
||||
|
||||
PathName filename;
|
||||
filename.printf(ucTemplate, majorVersion.c_str(), minorVersion.c_str());
|
||||
filename.printf(ucTemplate, majorVersion, minorVersion);
|
||||
|
||||
icu = FB_NEW(*getDefaultMemoryPool()) ICU();
|
||||
icu = FB_NEW(*getDefaultMemoryPool()) ICU(majorVersion, minorVersion);
|
||||
|
||||
icu->ucModule = ModuleLoader::loadModule(filename);
|
||||
if (!icu->ucModule)
|
||||
@ -813,7 +822,7 @@ UnicodeUtil::ICU* UnicodeUtil::loadICU(const Firebird::string& icuVersion,
|
||||
continue;
|
||||
}
|
||||
|
||||
filename.printf(inTemplate, majorVersion.c_str(), minorVersion.c_str());
|
||||
filename.printf(inTemplate, majorVersion, minorVersion);
|
||||
|
||||
icu->inModule = ModuleLoader::loadModule(filename);
|
||||
if (!icu->inModule)
|
||||
@ -828,61 +837,25 @@ UnicodeUtil::ICU* UnicodeUtil::loadICU(const Firebird::string& icuVersion,
|
||||
continue;
|
||||
}
|
||||
|
||||
string symbol;
|
||||
icu->getEntryPoint("u_init", icu->ucModule, icu->uInit);
|
||||
icu->getEntryPoint("u_versionToString", icu->ucModule, icu->uVersionToString);
|
||||
icu->getEntryPoint("uloc_countAvailable", icu->ucModule, icu->ulocCountAvailable);
|
||||
icu->getEntryPoint("uloc_getAvailable", icu->ucModule, icu->ulocGetAvailable);
|
||||
icu->getEntryPoint("uset_close", icu->ucModule, icu->usetClose);
|
||||
icu->getEntryPoint("uset_getItem", icu->ucModule, icu->usetGetItem);
|
||||
icu->getEntryPoint("uset_getItemCount", icu->ucModule, icu->usetGetItemCount);
|
||||
icu->getEntryPoint("uset_open", icu->ucModule, icu->usetOpen);
|
||||
|
||||
symbol.printf("u_init_%s_%s", majorVersion.c_str(), minorVersion.c_str());
|
||||
icu->ucModule->findSymbol(symbol, icu->uInit);
|
||||
|
||||
symbol.printf("u_versionToString_%s_%s", majorVersion.c_str(), minorVersion.c_str());
|
||||
icu->ucModule->findSymbol(symbol, icu->uVersionToString);
|
||||
|
||||
symbol.printf("uloc_countAvailable_%s_%s", majorVersion.c_str(), minorVersion.c_str());
|
||||
icu->ucModule->findSymbol(symbol, icu->ulocCountAvailable);
|
||||
|
||||
symbol.printf("uloc_getAvailable_%s_%s", majorVersion.c_str(), minorVersion.c_str());
|
||||
icu->ucModule->findSymbol(symbol, icu->ulocGetAvailable);
|
||||
|
||||
symbol.printf("uset_close_%s_%s", majorVersion.c_str(), minorVersion.c_str());
|
||||
icu->ucModule->findSymbol(symbol, icu->usetClose);
|
||||
|
||||
symbol.printf("uset_getItem_%s_%s", majorVersion.c_str(), minorVersion.c_str());
|
||||
icu->ucModule->findSymbol(symbol, icu->usetGetItem);
|
||||
|
||||
symbol.printf("uset_getItemCount_%s_%s", majorVersion.c_str(), minorVersion.c_str());
|
||||
icu->ucModule->findSymbol(symbol, icu->usetGetItemCount);
|
||||
|
||||
symbol.printf("uset_open_%s_%s", majorVersion.c_str(), minorVersion.c_str());
|
||||
icu->ucModule->findSymbol(symbol, icu->usetOpen);
|
||||
|
||||
symbol.printf("ucol_close_%s_%s", majorVersion.c_str(), minorVersion.c_str());
|
||||
icu->inModule->findSymbol(symbol, icu->ucolClose);
|
||||
|
||||
symbol.printf("ucol_getContractions_%s_%s", majorVersion.c_str(), minorVersion.c_str());
|
||||
icu->inModule->findSymbol(symbol, icu->ucolGetContractions);
|
||||
|
||||
symbol.printf("ucol_getSortKey_%s_%s", majorVersion.c_str(), minorVersion.c_str());
|
||||
icu->inModule->findSymbol(symbol, icu->ucolGetSortKey);
|
||||
|
||||
symbol.printf("ucol_open_%s_%s", majorVersion.c_str(), minorVersion.c_str());
|
||||
icu->inModule->findSymbol(symbol, icu->ucolOpen);
|
||||
|
||||
symbol.printf("ucol_setAttribute_%s_%s", majorVersion.c_str(), minorVersion.c_str());
|
||||
icu->inModule->findSymbol(symbol, icu->ucolSetAttribute);
|
||||
|
||||
symbol.printf("ucol_strcoll_%s_%s", majorVersion.c_str(), minorVersion.c_str());
|
||||
icu->inModule->findSymbol(symbol, icu->ucolStrColl);
|
||||
|
||||
symbol.printf("ucol_getVersion_%s_%s", majorVersion.c_str(), minorVersion.c_str());
|
||||
icu->inModule->findSymbol(symbol, icu->ucolGetVersion);
|
||||
|
||||
symbol.printf("utrans_open_%s_%s", majorVersion.c_str(), minorVersion.c_str());
|
||||
icu->inModule->findSymbol(symbol, icu->utransOpen);
|
||||
|
||||
symbol.printf("utrans_close_%s_%s", majorVersion.c_str(), minorVersion.c_str());
|
||||
icu->inModule->findSymbol(symbol, icu->utransClose);
|
||||
|
||||
symbol.printf("utrans_transUChars_%s_%s", majorVersion.c_str(), minorVersion.c_str());
|
||||
icu->inModule->findSymbol(symbol, icu->utransTransUChars);
|
||||
icu->getEntryPoint("ucol_close", icu->inModule, icu->ucolClose);
|
||||
icu->getEntryPoint("ucol_getContractions", icu->inModule, icu->ucolGetContractions);
|
||||
icu->getEntryPoint("ucol_getSortKey", icu->inModule, icu->ucolGetSortKey);
|
||||
icu->getEntryPoint("ucol_open", icu->inModule, icu->ucolOpen);
|
||||
icu->getEntryPoint("ucol_setAttribute", icu->inModule, icu->ucolSetAttribute);
|
||||
icu->getEntryPoint("ucol_strcoll", icu->inModule, icu->ucolStrColl);
|
||||
icu->getEntryPoint("ucol_getVersion", icu->inModule, icu->ucolGetVersion);
|
||||
icu->getEntryPoint("utrans_open", icu->inModule, icu->utransOpen);
|
||||
icu->getEntryPoint("utrans_close", icu->inModule, icu->utransClose);
|
||||
icu->getEntryPoint("utrans_transUChars", icu->inModule, icu->utransTransUChars);
|
||||
|
||||
if (/*!icu->uInit ||*/ !icu->uVersionToString || !icu->ulocCountAvailable ||
|
||||
!icu->ulocGetAvailable || !icu->usetClose || !icu->usetGetItem ||
|
||||
|
Loading…
Reference in New Issue
Block a user