From: Steven R. Loomis Date: Sun, 10 Jul 2011 03:20:22 +0000 (+0000) Subject: ICU-8157 more cleanup, remove warnings. Fix build for icu44+ X-Git-Tag: milestone-59-0-1~4665 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2b109ebb36d62555a8c0acaf57bce44a96a1d494;p=icu ICU-8157 more cleanup, remove warnings. Fix build for icu44+ X-SVN-Rev: 30309 --- diff --git a/tools/multi/proj/provider/Makefile b/tools/multi/proj/provider/Makefile index ed24b105b15..ef0c4d677b7 100644 --- a/tools/multi/proj/provider/Makefile +++ b/tools/multi/proj/provider/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2010 IBM Corporation and Others, All Rights Reserved. +# Copyright (C) 2010-2011 IBM Corporation and Others, All Rights Reserved. # all: glurens ii plugs testprog @@ -27,10 +27,10 @@ PROVIDER=provider LIBPROVIDER=lib$(PROVIDER).a #libs: $(ICU_TARBALLS_VERS:%=$(OUT)/%/lib/$(LIBPROVIDER)) - PLUGLIB=$(shell echo $(PROVIDER_TARGET) | tr '.' '_' ) PLUGLIB_MAJ=$(shell echo $(PROVIDER_TARGET) | cut -d. -f1-2 | tr -d '.' ) -PLUGLIB_ICU_CONFIG=$(C_INS)/r$(PLUGLIB)/bin/icu-config +PLUGLIB_INST=$(C_INS)/r$(PLUGLIB) +PLUGLIB_ICU_CONFIG=$(PLUGLIB_INST)/bin/icu-config #PLUGLIB_SO=$(shell $(PLUGLIB_ICU_CONFIG) --so 2>/dev/null ) PLUGLIB_NAME=libicuprov.$(PLUGLIB_MAJ).$(PLUGLIB_SO) #PLUGLIB_MAJ=$(echo $(PLUGLIB) | cut -d_ -f-1 | tr -d _ ) @@ -166,13 +166,13 @@ $(GLOUT)/$(PLUGLIB)/obj-$(OK): $(GLOUT) glurens $(PLUGLIB_ICU_CONFIG) plugs: $(PLUGLIB_OUTLIBS) $(OUT)/$(PLUGLIB_MAJ:%=icuplugins%.txt) -install-plugs: $(C_INS)/r$(PLUGLIB)/lib/$(PLUGLIB_NAME) $(C_INS)/r$(PLUGLIB)/lib/icu/icuplugins$(PLUGLIB_MAJ).txt +install-plugs: $(PLUGLIB_INST)/lib/$(PLUGLIB_NAME) $(PLUGLIB_INST)/lib/icu/icuplugins$(PLUGLIB_MAJ).txt echo "Plugins installed for testing." #TODO: should be 'install' not 'cp' -$(C_INS)/r$(PLUGLIB)/lib/$(PLUGLIB_NAME) $(C_INS)/r$(PLUGLIB)/lib/icu/icuplugins$(PLUGLIB_MAJ).txt: $(PLUGLIB_OUTLIBS) - cp $(PLUGLIB_OUTLIBS) $(C_INS)/r$(PLUGLIB)/lib - echo "$(PLUGLIB_NAME) coll_provider_plugin" > $(C_INS)/r$(PLUGLIB)/lib/icu/icuplugins$(PLUGLIB_MAJ).txt +$(PLUGLIB_INST)/lib/$(PLUGLIB_NAME) $(PLUGLIB_INST)/lib/icu/icuplugins$(PLUGLIB_MAJ).txt: $(PLUGLIB_OUTLIBS) + cp $(PLUGLIB_OUTLIBS) $(PLUGLIB_INST)/lib + echo "$(PLUGLIB_NAME) coll_provider_plugin" > $(PLUGLIB_INST)/lib/icu/icuplugins$(PLUGLIB_MAJ).txt $(OUT)/icuplugins$(PLUGLIB_MAJ).txt: $(PLUGLIB_OUTLIBS) echo "$(PLUGLIB_NAME) coll_provider_plugin" > $@ @@ -182,13 +182,13 @@ TESTPROG=coldiff testprog: $(PLUGLIB:%=$(OUT)/%/bin/$(TESTPROG)) check: all testprog $(OUT)/icuplugins$(PLUGLIB_MAJ).txt - ICU_PLUGINS=$(OUT) $(LIBPATH_VAR)=$(C_INS)/r$(PLUGLIB)/lib:out/$(PLUGLIB)/lib $(C_INS)/r$(PLUGLIB)/bin/icuinfo || ( echo "ICU broken." ; /bin/false ) - ICU_PLUGINS=$(OUT) $(LIBPATH_VAR)=$(C_INS)/r$(PLUGLIB)/lib:out/$(PLUGLIB)/lib $(C_INS)/r$(PLUGLIB)/bin/icuinfo -L || ( echo "Plugin broken." ; /bin/false ) - ICU_PLUGINS=$(OUT) $(LIBPATH_VAR)=$(C_INS)/r$(PLUGLIB)/lib:out/$(PLUGLIB)/lib out/$(PLUGLIB)/bin/coldiff || ( echo "coldiff failed." ; /bin/false ) + ICU_PLUGINS=$(OUT) $(LIBPATH_VAR)=$(PLUGLIB_INST)/lib:out/$(PLUGLIB)/lib $(PLUGLIB_INST)/bin/icuinfo || ( echo "ICU broken." ; /bin/false ) + ICU_PLUGINS=$(OUT) $(LIBPATH_VAR)=$(PLUGLIB_INST)/lib:out/$(PLUGLIB)/lib $(PLUGLIB_INST)/bin/icuinfo -L || ( echo "Plugin broken." ; /bin/false ) + ICU_PLUGINS=$(OUT) $(LIBPATH_VAR)=$(PLUGLIB_INST)/lib:out/$(PLUGLIB)/lib out/$(PLUGLIB)/bin/coldiff || ( echo "coldiff failed." ; /bin/false ) install-check: install-plugs - $(LIBPATH_VAR)=$(C_INS)/r$(PLUGLIB)/lib $(C_INS)/r$(PLUGLIB)/bin/icuinfo -L || ( echo "Plugin broken." ; /bin/false ) - $(LIBPATH_VAR)=$(C_INS)/r$(PLUGLIB)/lib out/$(PLUGLIB)/bin/coldiff || ( echo "coldiff failed." ; /bin/false ) + $(LIBPATH_VAR)=$(PLUGLIB_INST)/lib $(PLUGLIB_INST)/bin/icuinfo -L || ( echo "Plugin broken." ; /bin/false ) + $(LIBPATH_VAR)=$(PLUGLIB_INST)/lib out/$(PLUGLIB)/bin/coldiff || ( echo "coldiff failed." ; /bin/false ) $(OUT)/%/bin/$(TESTPROG): $(TESTPROG).cpp $(OUT)/$(PLUGLIB)/provider_version.h -mkdir -p $(OUT)/$*/bin @@ -216,10 +216,12 @@ $(BUILD)/%/$(GLUREN_H): $(BUILD)/%/ok Makefile echo "#define GLUREN_VER" $* >> $@ echo "#define GLUREN_TINY" $(shell echo $* | cut -d_ -f1-2) >> $@ echo >> $@ - echo >> $@ - echo >> $@ + echo '/* old style (<4.4)*/' >> $@ grep "^#define.*$(shell echo $* | cut -d_ -f1-2)$$" $(SRC)/$*/$(SOURCE)/common/unicode/urename.h | fgrep -v '*' | \ sed -e "s@^#define \([^ ]*\) \([^ ]*\)@#define OICU_\1 \2@" >> $@ + echo '/* new style (4.4+) */' >> $@ + fgrep " U_ICU_ENTRY_POINT_RENAME(" $(SRC)/$*/$(SOURCE)/common/unicode/urename.h | \ + sed -e "s@^#define \([^ ]*\) .*@#define OICU_\1 \1_$(shell echo $* | cut -d_ -f1-2 | tr -d '_')@" >> $@ cat $(GLUE)/gluren-bottom.h >> $@ diff --git a/tools/multi/proj/provider/coldiff.cpp b/tools/multi/proj/provider/coldiff.cpp index dfebbbb6fc0..5870b90be66 100644 --- a/tools/multi/proj/provider/coldiff.cpp +++ b/tools/multi/proj/provider/coldiff.cpp @@ -34,12 +34,13 @@ void setup(UErrorCode &status) { int32_t count; StringEnumeration *se = Collator::getAvailableLocales(); count = se->count(status); - fprintf(stderr, "# Collators now available: %d,\t%s - %d providers expected.\n", count, u_errorName(status), PROVIDER_COUNT); + fprintf(stderr, "# Collators now available: %d,\t%s - %d providers expected.\n", count, u_errorName(status), (int32_t)PROVIDER_COUNT); } int main(int /* argc*/ , const char * /*argv*/ []) { UErrorCode status = U_ZERO_ERROR; int diffs = 0; + int gbaddiffs =0; setup(status); if(U_FAILURE(status)) return 1; @@ -63,6 +64,7 @@ int main(int /* argc*/ , const char * /*argv*/ []) { UErrorCode subStatus = U_ZERO_ERROR; uint8_t bytes[200]; + uint8_t bytesb[200]; #define USE_CXX 0 #if USE_CXX @@ -87,6 +89,18 @@ int main(int /* argc*/ , const char * /*argv*/ []) { printf("ERR: %s\n", u_errorName(subStatus)); continue; } + + + char xbuf3[200]; + { + int32_t def = ucol_getShortDefinitionString(col,locID/*NULL*/,xbuf3,200,&subStatus); + if(U_FAILURE(subStatus)) { + printf("Err getting short string name: %s\n", u_errorName(subStatus)); + } else { + printf(" --> %s\n", xbuf3); + } + } + int32_t len = ucol_getSortKey(col, stuff, -1, bytes, 200); #endif @@ -100,6 +114,38 @@ int main(int /* argc*/ , const char * /*argv*/ []) { printf("%02X", (0xFF&bytes[i])); } printf("\n"); + + char xbuf4[200]; + UCollator *col2 = ucol_openFromShortString(xbuf3, FALSE, NULL, &subStatus); + if(U_FAILURE(subStatus)) { + printf("Err opening from new short string : %s\n", u_errorName(subStatus)); + continue; + } else { + int32_t def4 = ucol_getShortDefinitionString(col,locID/*NULL*/,xbuf4,300,&subStatus); + printf(" --> reopened = %s (%s)\n", xbuf4, u_errorName(subStatus)); + } + int32_t len2 = ucol_getSortKey(col2, stuff, -1, bytesb, 200); + + int baddiffs=0; + for(int i=0;i0) { + printf(" - ERR! Diffs from %s in %d places", xbuf2,baddiffs); + gbaddiffs+=baddiffs; + } else { + printf(" OK.\n"); + } + printf("\n"); + + + #if USE_CXX delete col; #else @@ -113,9 +159,19 @@ int main(int /* argc*/ , const char * /*argv*/ []) { if(diffs==0) { printf("ERROR: 0 differences found between platforms.. are the platforms installed? Try 'icuinfo -L'\n"); + return 1; } else { - printf("%d differences found among provider versions. Success!\n", diffs); + printf("%d differences found among provider versions!\n", diffs); } + + if(gbaddiffs>0) { + printf("ERROR: %d diffs found between a collator and it's reopened (from shortstring) variant.\n", gbaddiffs); + return 2; + } else { + printf("Collator and reopened (shortstring) are OK.\n"); + } + + printf("Success!\n"); return 0; } diff --git a/tools/multi/proj/provider/glue/coll_fe.c b/tools/multi/proj/provider/glue/coll_fe.c index db672d6fea0..d7627fd6d3c 100644 --- a/tools/multi/proj/provider/glue/coll_fe.c +++ b/tools/multi/proj/provider/glue/coll_fe.c @@ -1,7 +1,7 @@ /* ******************************************************************************* * -* Copyright (C) 2009, International Business Machines +* Copyright (C) 2009-2011, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -12,8 +12,10 @@ not needed. */ -extern void not_needed () { +static void not_needed () { return; } + + diff --git a/tools/multi/proj/provider/glue/coll_fe.cpp b/tools/multi/proj/provider/glue/coll_fe.cpp index 2bab2cf50dc..d2f43ae8198 100644 --- a/tools/multi/proj/provider/glue/coll_fe.cpp +++ b/tools/multi/proj/provider/glue/coll_fe.cpp @@ -19,42 +19,7 @@ #include #include "unicode/ustring.h" -// these from tblcoll.h -static Collator::ECollationStrength _getECollationStrength( - const UCollationStrength &strength) -{ - switch (strength) - { - case UCOL_PRIMARY : - return Collator::PRIMARY; - case UCOL_SECONDARY : - return Collator::SECONDARY; - case UCOL_TERTIARY : - return Collator::TERTIARY; - case UCOL_QUATERNARY : - return Collator::QUATERNARY; - default : - return Collator::IDENTICAL; - } -} -static UCollationStrength _getUCollationStrength( - const Collator::ECollationStrength &strength) -{ - switch (strength) - { - case Collator::PRIMARY : - return UCOL_PRIMARY; - case Collator::SECONDARY : - return UCOL_SECONDARY; - case Collator::TERTIARY : - return UCOL_TERTIARY; - case Collator::QUATERNARY : - return UCOL_QUATERNARY; - default : - return UCOL_IDENTICAL; - } -} /** @@ -90,69 +55,55 @@ static UCollationStrength _getUCollationStrength( virtual int32_t getSortKey(const UChar*, int32_t, uint8_t*, int32_t) const; \ public: static int32_t countAvailable(); \ public: static int32_t appendAvailable(UnicodeString* strs, int32_t i, int32_t count); \ + public: virtual int32_t internalGetShortDefinitionString(const char *locale, char *buffer, int32_t capacity, UErrorCode &status); \ }; /** ==================================== The following code runs inside the 'target' version (i.e. old ICU) ========== **/ #if defined ( ICUGLUE_VER ) -/* code for some version */ -#include - -/** - uclean.h -*/ -U_STABLE void U_EXPORT2 -OICU_u_init(UErrorCode *status); - -/** - ucol.h -*/ -U_STABLE UCollator* U_EXPORT2 -OICU_ucol_open(const char *loc, UErrorCode& status); - -U_STABLE void U_EXPORT2 -OICU_ucol_close(UCollator*); - -U_STABLE UCollationResult OICU_ucol_strcoll ( const UCollator * coll, -const UChar * source, -int32_t sourceLength, -const UChar * target, -int32_t targetLength -); - -U_STABLE int32_t U_EXPORT2 -OICU_ucol_countAvailable(); - -U_STABLE void U_EXPORT2 -OICU_ucol_setStrength(const UCollator *, UCollationStrength ); - -U_STABLE const char * U_EXPORT2 -OICU_ucol_getAvailable(int32_t i); - -U_STABLE UCollationStrength U_EXPORT2 -OICU_ucol_getStrength(UCollator *col); - -U_STABLE int32_t U_EXPORT2 -OICU_ucol_getSortKey(const UCollator *coll, - const UChar *source, - int32_t sourceLength, - uint8_t *result, - int32_t resultLength); +// these from tblcoll.h +static Collator::ECollationStrength _getECollationStrength( + const UCollationStrength &strength) +{ + switch (strength) + { + case UCOL_PRIMARY : + return Collator::PRIMARY; + case UCOL_SECONDARY : + return Collator::SECONDARY; + case UCOL_TERTIARY : + return Collator::TERTIARY; + case UCOL_QUATERNARY : + return Collator::QUATERNARY; + default : + return Collator::IDENTICAL; + } +} -U_STABLE UCollator* U_EXPORT2 -OICU_ucol_safeClone(const UCollator *coll, - void *stackBuffer, - int32_t *pBufferSize, - UErrorCode *status); +static UCollationStrength _getUCollationStrength( + const Collator::ECollationStrength &strength) +{ + switch (strength) + { + case Collator::PRIMARY : + return UCOL_PRIMARY; + case Collator::SECONDARY : + return UCOL_SECONDARY; + case Collator::TERTIARY : + return UCOL_TERTIARY; + case Collator::QUATERNARY : + return UCOL_QUATERNARY; + default : + return UCOL_IDENTICAL; + } +} -/** - end ucol.h -*/ -// define version -GLUE_VER( ICUGLUE_VER ) +/* code for some version */ +#include +#include "oicu.h" GLUE_SYM ( Collator ) :: ~ GLUE_SYM(Collator) () { #if COLL_FE_DEBUG @@ -174,7 +125,8 @@ GLUE_SYM ( glue_calcSortKey) (const UCollator *coll, #endif Collator * -GLUE_SYM ( Collator ) :: create (const Locale &loc, const char *ver) { +GLUE_SYM ( Collator ) :: create (const Locale &loc, const char */*ver*/) { + // TODO: save 'ver' off. UErrorCode status = U_ZERO_ERROR; char locBuf[200]; char kwvBuf[200]; @@ -224,7 +176,7 @@ UCollationResult GLUE_SYM ( Collator ) :: compare(const UnicodeString&, const Un } -UCollationResult GLUE_SYM ( Collator ) :: compare(const UChar* s, int32_t sl, const UChar* d , int32_t dl, UErrorCode&e ) const { +UCollationResult GLUE_SYM ( Collator ) :: compare(const UChar* s, int32_t sl, const UChar* d , int32_t dl, UErrorCode&/*e*/ ) const { return OICU_ucol_strcoll(_this, s, sl, d, dl); } @@ -321,13 +273,37 @@ int32_t GLUE_SYM ( Collator ) :: getSortKey(const UChar*s, int32_t l, uint8_t*d, return OICU_ucol_getSortKey(_this, s,l,d,b); } +int32_t GLUE_SYM (Collator ) :: internalGetShortDefinitionString(const char *locale, char *buffer, int32_t capacity, UErrorCode &status) { + if(U_FAILURE(status)) return 0; + int32_t intRes = OICU_ucol_getShortDefinitionString(_this, locale, buffer, capacity, &status); + int32_t newRes = (intRes += 7); /* _PICU38 */ + int32_t remainCap = capacity - newRes; + + if(remainCap < 0 && U_SUCCESS(status)) { + status = U_BUFFER_OVERFLOW_ERROR; /* ran out of space on our watch */ + } + if(U_SUCCESS(status)) { + char *p = buffer+strlen(buffer); + strncat(p,"_PICU",5); + p +=5 ; + *(p++) = ICUGLUE_VER_STR[0]; + *(p++) = ICUGLUE_VER_STR[2]; + if(remainCap>0) { + *(p++)=0; + } + } + return newRes; +} + + + int32_t GLUE_SYM ( Collator ) :: countAvailable() { int32_t count = OICU_ucol_countAvailable(); return count; } - int32_t GLUE_SYM ( Collator ) :: appendAvailable(UnicodeString* strs, int32_t i, int32_t count) { +int32_t GLUE_SYM ( Collator ) :: appendAvailable(UnicodeString* strs, int32_t i, int32_t /*count*/) { int avail = OICU_ucol_countAvailable(); UErrorCode status = U_ZERO_ERROR; OICU_u_init(&status); @@ -353,7 +329,6 @@ int32_t GLUE_SYM ( Collator ) :: getSortKey(const UChar*s, int32_t l, uint8_t*d, - #else /** ==================================== The following code runs inside the 'provider' version (i.e. current ICU) ========== **/ @@ -413,7 +388,7 @@ static const UnicodeString *gLocales = NULL; static int32_t gLocCount = 0; const UnicodeString -*VersionCollatorFactory::getSupportedIDs(int32_t &count, UErrorCode &status) { +*VersionCollatorFactory::getSupportedIDs(int32_t &count, UErrorCode &/*status*/) { if(gLocales==NULL) { count = 0; diff --git a/tools/multi/proj/provider/glue/oicu.h b/tools/multi/proj/provider/glue/oicu.h new file mode 100644 index 00000000000..beb8bd89515 --- /dev/null +++ b/tools/multi/proj/provider/glue/oicu.h @@ -0,0 +1,81 @@ +/* +******************************************************************************* +* +* Copyright (C) 2009-2011, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +*/ + +#ifndef _OICU +#define _OICU + +/** + uclean.h +*/ +U_STABLE void U_EXPORT2 +OICU_u_init(UErrorCode *status); + +/** + ucol.h +*/ +U_STABLE UCollator* U_EXPORT2 +OICU_ucol_open(const char *loc, UErrorCode& status); + +U_STABLE int32_t U_EXPORT2 +OICU_ucol_getShortDefinitionString(const UCollator *coll, + const char *locale, + char *buffer, + int32_t capacity, + UErrorCode *status); + + +U_STABLE void U_EXPORT2 +OICU_ucol_close(UCollator*); + +U_STABLE UCollationResult OICU_ucol_strcoll ( const UCollator * coll, +const UChar * source, +int32_t sourceLength, +const UChar * target, +int32_t targetLength +); + +U_STABLE int32_t U_EXPORT2 +OICU_ucol_countAvailable(); + +U_STABLE void U_EXPORT2 +OICU_ucol_setStrength(const UCollator *, UCollationStrength ); + + +#ifndef OICU_ucol_getAvailable +#error OICU_ucol_getAvailable not found - urename symbol mismatch? +#endif + +U_STABLE const char * U_EXPORT2 +OICU_ucol_getAvailable(int32_t i); + +U_STABLE UCollationStrength U_EXPORT2 +OICU_ucol_getStrength(UCollator *col); + +U_STABLE int32_t U_EXPORT2 +OICU_ucol_getSortKey(const UCollator *coll, + const UChar *source, + int32_t sourceLength, + uint8_t *result, + int32_t resultLength); + + +U_STABLE UCollator* U_EXPORT2 +OICU_ucol_safeClone(const UCollator *coll, + void *stackBuffer, + int32_t *pBufferSize, + UErrorCode *status); + + +/** + end ucol.h +*/ + +// define version +GLUE_VER( ICUGLUE_VER ) +#endif