dbertoni 01/07/17 21:38:25
Modified: c/src/ICUBridge ICUBridgeCollationCompareFunctor.cpp
ICUBridgeCollationCompareFunctor.hpp
Log:
Changes for ICU 1.8.1.
Revision Changes Path
1.15 +45 -16
xml-xalan/c/src/ICUBridge/ICUBridgeCollationCompareFunctor.cpp
Index: ICUBridgeCollationCompareFunctor.cpp
===================================================================
RCS file:
/home/cvs/xml-xalan/c/src/ICUBridge/ICUBridgeCollationCompareFunctor.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- ICUBridgeCollationCompareFunctor.cpp 2001/04/11 21:32:32 1.14
+++ ICUBridgeCollationCompareFunctor.cpp 2001/07/18 04:38:25 1.15
@@ -78,11 +78,11 @@
ICUBridgeCollationCompareFunctor::ICUBridgeCollationCompareFunctor() :
m_isValid(false),
- m_collator(0)
+ m_defaultCollator(0)
{
UErrorCode theStatus = U_ZERO_ERROR;
- m_collator = Collator::createInstance(theStatus);
+ m_defaultCollator = Collator::createInstance(theStatus);
if (theStatus == U_ZERO_ERROR ||
(theStatus >= U_ERROR_INFO_START && theStatus < U_ERROR_INFO_LIMIT))
@@ -95,7 +95,7 @@
ICUBridgeCollationCompareFunctor::~ICUBridgeCollationCompareFunctor()
{
- delete m_collator;
+ delete m_defaultCollator;
}
@@ -114,11 +114,11 @@
{
assert(theCollator.get() != 0);
-#if U_SIZEOF_WCHAR_T==2
+#if defined(XALAN_USE_WCHAR_CAST_HACK)
return theCollator->compare(
- (wchar_t*)theLHS,
+ (const wchar_t*)theLHS,
length(theLHS),
- (wchar_t*)theRHS,
+ (const wchar_t*)theRHS,
length(theRHS));
#else
return theCollator->compare(
@@ -136,6 +136,38 @@
+inline Collator*
+getCollator(
+ const XalanDOMChar* theLocale,
+ UErrorCode& theStatus)
+{
+ char theBuffer[ULOC_FULLNAME_CAPACITY];
+
+ const unsigned int theLength = length(theLocale);
+
+ if (theLength >= ULOC_FULLNAME_CAPACITY)
+ {
+ theStatus = U_ILLEGAL_ARGUMENT_ERROR;
+
+ return 0;
+ }
+ else
+ {
+ // Since language names must be ASCII, this
+ // is the cheapest way to "transcode"...
+ for (unsigned int i = 0; i <= theLength; ++i)
+ {
+ theBuffer[i] = char(theLocale[i]);
+ }
+
+ return Collator::createInstance(
+ Locale::createFromName(theBuffer),
+ theStatus);
+ }
+}
+
+
+
int
ICUBridgeCollationCompareFunctor::operator()(
const XalanDOMChar* theLHS,
@@ -144,18 +176,14 @@
{
UErrorCode theStatus = U_ZERO_ERROR;
-#if U_SIZEOF_WCHAR_T==2
- XalanAutoPtr<Collator>
theCollator(Collator::createInstance(Locale(UnicodeString((const
wchar_t*)theLocale)), theStatus));
-#else
- XalanAutoPtr<Collator>
theCollator(Collator::createInstance(Locale(UnicodeString(theLocale)),
theStatus));
-#endif
+ XalanAutoPtr<Collator> theCollator(getCollator(theLocale, theStatus));
if (theStatus == U_ZERO_ERROR ||
(theStatus >= U_ERROR_INFO_START && theStatus < U_ERROR_INFO_LIMIT))
{
assert(theCollator.get() != 0);
-#if U_SIZEOF_WCHAR_T==2
+#if defined(XALAN_USE_WCHAR_CAST_HACK)
return theCollator->compare(
(const wchar_t*)theLHS,
length(theLHS),
@@ -188,15 +216,16 @@
}
else
{
- assert(m_collator != 0);
-#if U_SIZEOF_WCHAR_T==2
- return m_collator->compare(
+ assert(m_defaultCollator != 0);
+
+#if defined(XALAN_USE_WCHAR_CAST_HACK)
+ return m_defaultCollator->compare(
(const wchar_t*)theLHS,
length(theLHS),
(const wchar_t*)theRHS,
length(theRHS));
#else
- return m_collator->compare(
+ return m_defaultCollator->compare(
theLHS,
length(theLHS),
theRHS,
1.4 +1 -1
xml-xalan/c/src/ICUBridge/ICUBridgeCollationCompareFunctor.hpp
Index: ICUBridgeCollationCompareFunctor.hpp
===================================================================
RCS file:
/home/cvs/xml-xalan/c/src/ICUBridge/ICUBridgeCollationCompareFunctor.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ICUBridgeCollationCompareFunctor.hpp 2001/03/29 22:09:04 1.3
+++ ICUBridgeCollationCompareFunctor.hpp 2001/07/18 04:38:25 1.4
@@ -107,7 +107,7 @@
bool m_isValid;
- Collator* m_collator;
+ Collator* m_defaultCollator;
const static
StylesheetExecutionContextDefault::DefaultCollationCompareFunctor
s_defaultFunctor;
};
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]