#
-# 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
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 _ )
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" > $@
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
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 >> $@
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;
UErrorCode subStatus = U_ZERO_ERROR;
uint8_t bytes[200];
+ uint8_t bytesb[200];
#define USE_CXX 0
#if USE_CXX
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
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;i<len;i++) {
+ if(i<len&&bytes[i]!=bytesb[i]) {
+ baddiffs++;
+ printf("!");
+ } else {
+ printf(" ");
+ }
+ printf("%02X", (0xFF&bytesb[i]));
+ }
+ if(baddiffs>0) {
+ printf(" - ERR! Diffs from %s in %d places", xbuf2,baddiffs);
+ gbaddiffs+=baddiffs;
+ } else {
+ printf(" OK.\n");
+ }
+ printf("\n");
+
+
+
#if USE_CXX
delete col;
#else
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;
}
/*
*******************************************************************************
*
-* Copyright (C) 2009, International Business Machines
+* Copyright (C) 2009-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
*/
-extern void not_needed () {
+static void not_needed () {
return;
}
+
+
#include <stdio.h>
#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;
- }
-}
/**
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 <icuglue/gluren.h>
-
-/**
- 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 <icuglue/gluren.h>
+#include "oicu.h"
GLUE_SYM ( Collator ) :: ~ GLUE_SYM(Collator) () {
#if COLL_FE_DEBUG
#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];
}
-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);
}
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);
-
#else
/** ==================================== The following code runs inside the 'provider' version (i.e. current ICU) ========== **/
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;
--- /dev/null
+/*
+*******************************************************************************
+*
+* 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