ICU-157 making tools independent form icudata.dll

X-SVN-Rev: 282
This commit is contained in:
Vladimir Weinstein 1999-12-02 23:26:44 +00:00
parent a0e21925e7
commit 695dce92f3
6 changed files with 53 additions and 33 deletions

View file

@ -406,7 +406,7 @@ Locale::getVariant(UnicodeString& var) const
UnicodeString&
Locale::getName(UnicodeString& name) const
{
name = fullName;
name = UnicodeString(fullName,"");
return name;
}

View file

@ -291,7 +291,7 @@ ResourceBundle::ResourceBundle( const UnicodeString& path,
ResourceBundle::ResourceBundle( const UnicodeString& path,
const UnicodeString& localeName,
UErrorCode& status)
: fPath(path, kDefaultSuffix),
: fPath(path, UnicodeString(kDefaultSuffix,"")),
fRealLocale(localeName),
fIsDataOwned(TRUE),
fVersionID(0),
@ -948,21 +948,24 @@ const UnicodeString*
ResourceBundle::listInstalledLocales(const UnicodeString& path,
int32_t& numInstalledLocales)
{
const UHashtable* h = getFromCache(PathInfo(path, kDefaultSuffix),
kIndexLocaleName, fgUserCache);
const UnicodeString kDefaultSuffixString = UnicodeString(kDefaultSuffix,"");
const UHashtable* h = getFromCache(PathInfo(path, kDefaultSuffixString),
UnicodeString(kIndexLocaleName,""), fgUserCache);
if(h == 0) {
UErrorCode error = U_ZERO_ERROR;
if(parseIfUnparsed(PathInfo(path, kDefaultSuffix),
kIndexFilename, fgUserCache,
if(parseIfUnparsed(PathInfo(path, kDefaultSuffixString),
UnicodeString(kIndexFilename,""), fgUserCache,
fgUserVisitedFiles, error)) {
h = getFromCache(PathInfo(path, kDefaultSuffix),
kIndexLocaleName, fgUserCache);
h = getFromCache(PathInfo(path, kDefaultSuffixString),
UnicodeString(kIndexLocaleName,""), fgUserCache);
}
}
if(h != 0) {
UnicodeString ukIndexTag = kIndexTag;
UnicodeString ukIndexTag = UnicodeString(kIndexTag,"");
ResourceBundleData *data =
(ResourceBundleData*) uhash_get(h, ukIndexTag.hashCode() & 0x7FFFFFFF);
if(data != 0
@ -997,7 +1000,7 @@ listInstalledLocalesImplementation(const char* path,
// ResourceBundle and does the work, and a hidden method with C
// linkage that calls it and is used by the C implementation of
// Locale. Disgusting, isn't it? --rtg 11/30/98
const UnicodeString* array = (ResourceBundle::listInstalledLocales(path, *numInstalledLocales));
const UnicodeString* array = (ResourceBundle::listInstalledLocales(UnicodeString(path,""), *numInstalledLocales));
const UnicodeString** arrayOfPtrs = (const UnicodeString**) new UnicodeString*[*numInstalledLocales];
for(int i = 0; i < *numInstalledLocales; i++)
arrayOfPtrs[i] = &array[i];
@ -1327,7 +1330,7 @@ ResourceBundle::PathInfo::openFile(const UnicodeString& localeName) const
UnicodeString workingName(makeCacheKey(localeName));
int32_t size = workingName.size();
char* returnVal = new char[size + 1];
workingName.extract(0, size, returnVal);
workingName.extract(0, size, returnVal, "");
returnVal[size] = 0;
FileStream* result = T_FileStream_open(returnVal, "rb");
delete [] returnVal;

View file

@ -43,6 +43,10 @@
typedef struct UnicodeString UnicodeString;
U_CAPI const UChar* T_UnicodeString_getUChars(const UnicodeString *s);
U_CAPI int32_t
T_UnicodeString_extract(const UnicodeString *s, char *dst);
/* Locale stuff */
U_CAPI void locale_set_default(const char *id);
@ -1053,6 +1057,7 @@ void _lazyEvaluate_installedLocales()
UnicodeString** temp;
char ** temp2;
int i;
int32_t strSize;
if (_installedLocales == NULL)
{
temp = T_ResourceBundle_listInstalledLocales(uloc_getDataDirectory(),
@ -1061,9 +1066,13 @@ void _lazyEvaluate_installedLocales()
for (i = 0; i < _installedLocalesCount; i++)
{
strSize = u_strlen(T_UnicodeString_getUChars(temp[i]));
temp2[i] = (char*) icu_malloc(sizeof(char) *
(u_strlen(T_UnicodeString_getUChars(temp[i])) + 1));
temp2[i] = u_austrcpy(temp2[i], T_UnicodeString_getUChars(temp[i]));
(strSize + 1));
T_UnicodeString_extract(temp[i], temp2[i]);
temp2[i][strSize] = 0; /* Terminate the string */
}
{
umtx_lock(NULL);

View file

@ -1138,6 +1138,13 @@ T_UnicodeString_getUChars(const UnicodeString *s)
return s->getUChars();
}
// private function for C API
U_CFUNC int32_t
T_UnicodeString_extract(const UnicodeString *s, char *dst)
{
return s->extract(0,s->size(),dst,"");
}
//========================================
// Default converter caching

View file

@ -577,9 +577,9 @@ RuleBasedCollator::RuleBasedCollator( const Locale& desiredLocale,
// srl write out default.col
{
UnicodeString defLocaleName = ResourceBundle::kDefaultFilename;
char *binaryFilePath = createPathName(Locale::getDataDirectory(),
defLocaleName, kFilenameSuffix);
UnicodeString defLocaleName = UnicodeString(ResourceBundle::kDefaultFilename,"");
char *binaryFilePath = createPathName(UnicodeString(Locale::getDataDirectory(),""),
defLocaleName, UnicodeString(kFilenameSuffix,""));
bool_t ok = writeToFile(binaryFilePath);
delete [] binaryFilePath;
#ifdef COLLDEBUG
@ -700,8 +700,8 @@ RuleBasedCollator::constructFromFile( const Locale& locale,
data = 0;
}
char *binaryFilePath = createPathName(Locale::getDataDirectory(),
localeFileName, kFilenameSuffix);
char *binaryFilePath = createPathName(UnicodeString(Locale::getDataDirectory(),""),
localeFileName, UnicodeString(kFilenameSuffix,""));
if(tryBinaryFile) {
// Try to load up the collation from a binary file first
@ -714,7 +714,7 @@ RuleBasedCollator::constructFromFile( const Locale& locale,
}
// Now try to load it up from a resource bundle text source file
ResourceBundle bundle(Locale::getDataDirectory(), localeFileName, status);
ResourceBundle bundle(UnicodeString(Locale::getDataDirectory(),""), localeFileName, status);
// if there is no resource bundle file for the give locale, break out
if(U_FAILURE(status))
@ -2400,7 +2400,7 @@ RuleBasedCollator::createPathName( const UnicodeString& prefix,
size = workingName.size();
returnVal = new char[size + 1];
workingName.extract(0, size, returnVal);
workingName.extract(0, size, returnVal, "");
returnVal[size] = 0;
return returnVal;

View file

@ -12,6 +12,20 @@ rem toolversion: Debug or Release
set toolversion=Release
if not "%2"=="" set toolversion=%2
echo create conversion tables
cd makeconv
call mkcnvfle %toolversion% %1
echo create locale resource bundles
cd ..\genrb
call genrb %toolversion% %1
echo create binary collation tables
cd ..\gencol
%toolversion%\gencol
cd ..
echo create unames.dat and unames_dat.c from UnicodeData.txt
gennames\%toolversion%\gennames -v- -c- "%ICU_DATA%UnicodeData-3.0.0.txt"
genccode\%toolversion%\genccode "%ICU_DATA%unames.dat"
@ -43,19 +57,6 @@ echo %ICU_DATA%cnvalias.dat>>mkmap.tmp
echo %ICU_DATA%tz.dat>>mkmap.tmp
gencmn\%toolversion%\gencmn 1000000 mkmap.tmp
echo create conversion tables
cd makeconv
call mkcnvfle %toolversion% %1
echo create locale resource bundles
cd ..\genrb
call genrb %toolversion% %1
echo create binary collation tables
cd ..\gencol
%toolversion%\gencol
cd ..
goto :end