From 0631aae4fdc8439001319419bbda4eebc6bce0b8 Mon Sep 17 00:00:00 2001 From: Vladimir Weinstein Date: Thu, 2 Dec 1999 23:26:44 +0000 Subject: [PATCH] making tools independent form icudata.dll X-Trac-URL: https://ssl.icu-project.org/trac/ticket/157 git-svn-id: http://source.icu-project.org/repos/icu/icu/trunk@282 0a8b766c-62c9-45f9-954d-7f2943c9ead0 --- source/common/locid.cpp | 2 +- source/common/resbund.cpp | 23 +++++++++++++---------- source/common/uloc.c | 13 +++++++++++-- source/common/unistr.cpp | 7 +++++++ source/i18n/tblcoll.cpp | 14 +++++++------- source/tools/makedata.bat | 27 ++++++++++++++------------- 6 files changed, 53 insertions(+), 33 deletions(-) diff --git a/source/common/locid.cpp b/source/common/locid.cpp index 7965ddda478..317e721e10c 100644 --- a/source/common/locid.cpp +++ b/source/common/locid.cpp @@ -406,7 +406,7 @@ Locale::getVariant(UnicodeString& var) const UnicodeString& Locale::getName(UnicodeString& name) const { - name = fullName; + name = UnicodeString(fullName,""); return name; } diff --git a/source/common/resbund.cpp b/source/common/resbund.cpp index 2b8d58ca433..39faeb2429d 100644 --- a/source/common/resbund.cpp +++ b/source/common/resbund.cpp @@ -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; diff --git a/source/common/uloc.c b/source/common/uloc.c index 8c1c0658e59..1fed06842f7 100644 --- a/source/common/uloc.c +++ b/source/common/uloc.c @@ -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); diff --git a/source/common/unistr.cpp b/source/common/unistr.cpp index 35d69427bd5..732a97965db 100644 --- a/source/common/unistr.cpp +++ b/source/common/unistr.cpp @@ -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 diff --git a/source/i18n/tblcoll.cpp b/source/i18n/tblcoll.cpp index 497d1ca0ed2..1a6ba31c582 100644 --- a/source/i18n/tblcoll.cpp +++ b/source/i18n/tblcoll.cpp @@ -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; diff --git a/source/tools/makedata.bat b/source/tools/makedata.bat index 3f75b290222..1fe39e56006 100755 --- a/source/tools/makedata.bat +++ b/source/tools/makedata.bat @@ -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