/**
* Constructs a set from the output of serialize().
- * The resulting set will be frozen.
*
* @param buffer the 16 bit array
* @param bufferLen the original length returned from serialize()
UnicodeSet(const uint16_t buffer[], int32_t bufferLen,
ESerialization serialization, UErrorCode &status);
#endif
-
+
/**
* Constructs a set from the given pattern. See the class
* description for the syntax of the pattern language.
/**
* Deserialize constructor.
- * Result will be frozen.
*/
UnicodeSet::UnicodeSet(const uint16_t data[], int32_t dataLen, ESerialization serialization, UErrorCode &ec)
: len(1), capacity(1+START_EXTRA), list(0), bmpSet(0), buffer(0),
setToBogus();
return;
}
-
+
// bmp?
int32_t headerSize = ((data[0]&0x8000)) ?2:1;
int32_t bmpLength = (headerSize==1)?data[0]:data[1];
printf("<<16@%d[%d] %X\n", i+headerSize, i, list[i]);
#endif
}
- /*
- if(bmpLength>0) {
- bmpSet= new BMPSet(list, bmpLength);
- if(bmpSet == NULL) {
- ec = U_MEMORY_ALLOCATION_ERROR;
- setToBogus();
- return;
- }
- }*/
// copy smp
for(i=bmpLength;i<len;i++) {
list[i] = ((UChar32)data[headerSize+bmpLength+(i-bmpLength)*2+0] << 16) +
#include "collationrootelements.h"
#include "collationsettings.h"
#include "collationtailoring.h"
+#include "collunsafe.h"
#include "normalizer2impl.h"
#include "uassert.h"
#include "ucmndata.h"
#include "utrie2.h"
-// #if U_HAVE_COLLUNSAFE
-#if 1
-#include "collunsafe.h"
-
-#endif
-// #end
-
U_NAMESPACE_BEGIN
namespace {
return;
}
if(baseData == NULL) {
-#if defined( COLLUNSAFE_COLL_VERSION )
-#if defined(COLLUNSAFE_RANGES) /* slower but still an improvement*/
- tailoring.unsafeBackwardSet = new UnicodeSet();
-
- for(int32_t i=0;i<unsafe_rangeCount*2;i+=2) {
- tailoring.unsafeBackwardSet->add(unsafe_ranges[i+0],unsafe_ranges[i+1]);
- }
- tailoring.unsafeBackwardSet->freeze();
-#elif defined (COLLUNSAFE_SERIALIZE)
- /* faster */
+#if defined(COLLUNSAFE_COLL_VERSION) && defined (COLLUNSAFE_SERIALIZE)
tailoring.unsafeBackwardSet = new UnicodeSet(unsafe_serializedData, unsafe_serializedCount, UnicodeSet::kSerialized, errorCode);
if(tailoring.unsafeBackwardSet == NULL) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
} else if (U_FAILURE(errorCode)) {
return;
}
-#else
-#error no unsafe-backwards strategy chosen
-#endif
-
#else
// Create the unsafe-backward set for the root collator.
// Include all non-zero combining marks and trail surrogates.
return;
}
data->nfcImpl.addLcccChars(*tailoring.unsafeBackwardSet);
-#endif
+#endif // !COLLUNSAFE_SERIALIZE || !COLLUNSAFE_COLL_VERSION
} else {
// Clone the root collator's set contents.
tailoring.unsafeBackwardSet = static_cast<UnicodeSet *>(
errln("checkSerializeRoundTrip: error %s serializing buffer\n", u_errorName(status));
return;
}
-
-#if 0
- UnicodeString pat; t.toPattern(pat, FALSE);
- infoln(pat);
- printf(" %d: ", len);
- for(int i=0;i<len;i++) {
- printf( " %04X ", serializeBuffer.getAlias()[i]);
- }
- printf("\n");
-#endif
-
UnicodeSet deserialized(serializeBuffer.getAlias(), len, UnicodeSet::kSerialized, status);
if(U_FAILURE(status)) {
errln("checkSerializeRoundTrip: error %s deserializing buffer: buf %p len %d, original %d\n", u_errorName(status), serializeBuffer.getAlias(), len, t.getRangeCount());
/**
* Define the type of generator to use. Choose one.
*/
-#define SERIALIZE 1 //< Default: use UnicodeSet.serialize() (best, fast, requires new UnicodeSet c'tor)
-#define RANGES 0 //< Enumerate ranges (works, not as fast)
-#define PATTERN 0 //< Generate a UnicodeSet pattern (broken AND probably slow)
+#define SERIALIZE 1 //< Default: use UnicodeSet.serialize() and a new internal c'tor
+#define RANGES 0 //< Enumerate ranges (works, not as fast. No support in collationdatareader.cpp)
+#define PATTERN 0 //< Generate a UnicodeSet pattern (depends on #11891 AND probably slower. No support in collationdatareader.cpp)
int main(int argc, const char *argv[]) {
UErrorCode errorCode = U_ZERO_ERROR;
#endif
#if PATTERN
- fprintf(stderr,".. pattern\n");
+ fprintf(stderr,".. pattern. (Note: collationdatareader.cpp does not support this form also see #11891)\n");
// attempt to use pattern
UnicodeString pattern;
#endif
#if RANGE
+ fprintf(stderr, "COLLUNSAFE_RANGE - no code support in collationdatareader.cpp for this\n");
printf("#define COLLUNSAFE_RANGE 1\n");
printf("static const int32_t unsafe_rangeCount = %d;\n", rangeCount);
printf("static const UChar32 unsafe_ranges[%d] = { \n", rangeCount*2);