mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-27 07:34:20 +00:00
Removed two functions from nsICollation which use nsString, r=mkaply@us.ibm.com, sr=sspitzer.
This commit is contained in:
parent
0c9333704b
commit
cbc4c7b484
@ -82,19 +82,12 @@ public:
|
||||
NS_IMETHOD CreateRawSortKey(const nsCollationStrength strength,
|
||||
const nsString& stringIn, PRUint8* key, PRUint32 *outLen) = 0;
|
||||
|
||||
// create a sort key (nsString)
|
||||
NS_IMETHOD CreateSortKey(const nsCollationStrength strength,
|
||||
const nsString& stringIn, nsString& key) = 0;
|
||||
|
||||
// compare two sort keys
|
||||
// length is a byte length, result is same as strcmp
|
||||
NS_IMETHOD CompareRawSortKey(const PRUint8* key1, const PRUint32 len1,
|
||||
const PRUint8* key2, const PRUint32 len2,
|
||||
PRInt32* result) = 0;
|
||||
|
||||
// compare two sort keys (nsString)
|
||||
NS_IMETHOD CompareSortKey(const nsString& key1, const nsString& key2, PRInt32* result) = 0;
|
||||
|
||||
// init this interface to a specified locale (should only be called by collation factory)
|
||||
//
|
||||
NS_IMETHOD Initialize(nsILocale* locale) = 0;
|
||||
|
@ -57,10 +57,6 @@ public:
|
||||
NS_IMETHOD CreateRawSortKey(const nsCollationStrength strength,
|
||||
const nsString& stringIn, PRUint8* key, PRUint32* outLen);
|
||||
|
||||
// create a sort key (nsString)
|
||||
NS_IMETHOD CreateSortKey(const nsCollationStrength strength,
|
||||
const nsString& stringIn, nsString& key)
|
||||
{return mCollation->CreateSortKey(this, strength, stringIn, key);}
|
||||
// compare two sort keys
|
||||
// length is character length not byte length, result is same as strcmp
|
||||
NS_IMETHOD CompareRawSortKey(const PRUint8* key1, const PRUint32 len1,
|
||||
@ -68,10 +64,6 @@ public:
|
||||
PRInt32* result)
|
||||
{*result = mCollation->CompareRawSortKey(key1, len1, key2, len2);return NS_OK;}
|
||||
|
||||
// compare two sort keys (nsString)
|
||||
NS_IMETHOD CompareSortKey(const nsString& key1, const nsString& key2, PRInt32* result)
|
||||
{*result = mCollation->CompareSortKey(key1, key2);return NS_OK;}
|
||||
|
||||
// init this interface to a specified locale (should only be called by collation factory)
|
||||
//
|
||||
NS_IMETHOD Initialize(nsILocale* locale);
|
||||
|
@ -136,44 +136,6 @@ nsresult nsCollation::CompareString(nsICollation *inst, const nsCollationStrengt
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult nsCollation::CreateSortKey(nsICollation *inst, const nsCollationStrength strength,
|
||||
const nsString& stringIn, nsString& key)
|
||||
{
|
||||
PRUint32 aLength;
|
||||
PRUint8 *aKey;
|
||||
nsresult res;
|
||||
|
||||
res = inst->GetSortKeyLen(strength, stringIn, &aLength);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
PRUint32 bufferLength = (aLength==0) ? 2 :((aLength + 1) / 2 * 2); // should be even
|
||||
|
||||
aKey = new PRUint8[bufferLength];
|
||||
if (nsnull != aKey) {
|
||||
aKey[bufferLength-1] = 0; // pre-set zero to the padding
|
||||
res = inst->CreateRawSortKey(strength, stringIn, aKey, &aLength);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
PRUnichar *aKeyInUnichar = (PRUnichar *) aKey;
|
||||
PRUint32 aLengthUnichar = bufferLength / 2;
|
||||
|
||||
// to avoid nsString to assert, chop off the last null word (padding)
|
||||
// however, collation key may contain zero's anywhere in the key
|
||||
// so we may still get assertion as long as nsString is used to hold collation key
|
||||
// use CreateRawSortKey instead (recommended) to avoid this to happen
|
||||
if (aKeyInUnichar[aLengthUnichar-1] == 0)
|
||||
aLengthUnichar--;
|
||||
|
||||
key.Assign(aKeyInUnichar, aLengthUnichar);
|
||||
}
|
||||
delete [] aKey;
|
||||
}
|
||||
else {
|
||||
res = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
PRInt32 nsCollation::CompareRawSortKey(const PRUint8* key1, const PRUint32 len1,
|
||||
const PRUint8* key2, const PRUint32 len2)
|
||||
{
|
||||
@ -188,19 +150,6 @@ PRInt32 nsCollation::CompareRawSortKey(const PRUint8* key1, const PRUint32 len1,
|
||||
return result;
|
||||
}
|
||||
|
||||
PRInt32 nsCollation::CompareSortKey(const nsString& key1, const nsString& key2)
|
||||
{
|
||||
PRUint8 *rawKey1, *rawKey2;
|
||||
PRUint32 len1, len2;
|
||||
|
||||
rawKey1 = (PRUint8 *) key1.GetUnicode();
|
||||
len1 = key1.Length() * sizeof(PRUnichar);
|
||||
rawKey2 = (PRUint8 *) key2.GetUnicode();
|
||||
len2 = key2.Length() * sizeof(PRUnichar);
|
||||
|
||||
return CompareRawSortKey(rawKey1, len1, rawKey2, len2);
|
||||
}
|
||||
|
||||
nsresult nsCollation::NormalizeString(nsString& stringInOut)
|
||||
{
|
||||
if (mCaseConversion == NULL) {
|
||||
|
@ -57,18 +57,11 @@ public:
|
||||
nsresult CompareString(nsICollation *inst, const nsCollationStrength strength,
|
||||
const nsString& string1, const nsString& string2, PRInt32* result);
|
||||
|
||||
// create a sort key (nsString)
|
||||
nsresult CreateSortKey(nsICollation *inst, const nsCollationStrength strength,
|
||||
const nsString& stringIn, nsString& key);
|
||||
|
||||
// compare two sort keys
|
||||
// length is a byte length, result is same as strcmp
|
||||
PRInt32 CompareRawSortKey(const PRUint8* key1, const PRUint32 len1,
|
||||
const PRUint8* key2, const PRUint32 len2);
|
||||
|
||||
// compare two sort keys (nsString)
|
||||
PRInt32 CompareSortKey(const nsString& key1, const nsString& key2);
|
||||
|
||||
// normalize string before collation key generation
|
||||
nsresult NormalizeString(nsString& stringInOut);
|
||||
|
||||
|
@ -53,11 +53,6 @@ public:
|
||||
NS_IMETHOD CreateRawSortKey(const nsCollationStrength strength,
|
||||
const nsString& stringIn, PRUint8* key, PRUint32* outLen);
|
||||
|
||||
// create a sort key (nsString)
|
||||
NS_IMETHOD CreateSortKey(const nsCollationStrength strength,
|
||||
const nsString& stringIn, nsString& key)
|
||||
{return mCollation->CreateSortKey(this, strength, stringIn, key);}
|
||||
|
||||
// compare two sort keys
|
||||
// length is character length not byte length, result is same as strcmp
|
||||
NS_IMETHOD CompareRawSortKey(const PRUint8* key1, const PRUint32 len1,
|
||||
@ -65,10 +60,6 @@ public:
|
||||
PRInt32* result)
|
||||
{*result = mCollation->CompareRawSortKey(key1, len1, key2, len2);return NS_OK;}
|
||||
|
||||
// compare two sort keys (nsString)
|
||||
NS_IMETHOD CompareSortKey(const nsString& key1, const nsString& key2, PRInt32* result)
|
||||
{*result = mCollation->CompareSortKey(key1, key2);return NS_OK;}
|
||||
|
||||
// init this interface to a specified locale (should only be called by collation factory)
|
||||
//
|
||||
NS_IMETHOD Initialize(nsILocale* locale);
|
||||
|
@ -60,11 +60,6 @@ public:
|
||||
NS_IMETHOD CreateRawSortKey(const nsCollationStrength strength,
|
||||
const nsString& stringIn, PRUint8* key, PRUint32* outLen);
|
||||
|
||||
// create a sort key (nsString)
|
||||
NS_IMETHOD CreateSortKey(const nsCollationStrength strength,
|
||||
const nsString& stringIn, nsString& key)
|
||||
{return mCollation->CreateSortKey(this, strength, stringIn, key);}
|
||||
|
||||
// compare two sort keys
|
||||
// length is character length not byte length, result is same as strcmp
|
||||
NS_IMETHOD CompareRawSortKey(const PRUint8* key1, const PRUint32 len1,
|
||||
@ -72,10 +67,6 @@ public:
|
||||
PRInt32* result)
|
||||
{*result = mCollation->CompareRawSortKey(key1, len1, key2, len2);return NS_OK;}
|
||||
|
||||
// compare two sort keys (nsString)
|
||||
NS_IMETHOD CompareSortKey(const nsString& key1, const nsString& key2, PRInt32* result)
|
||||
{*result = mCollation->CompareSortKey(key1, key2);return NS_OK;}
|
||||
|
||||
// init this interface to a specified locale (should only be called by collation factory)
|
||||
//
|
||||
NS_IMETHOD Initialize(nsILocale* locale);
|
||||
|
@ -56,11 +56,6 @@ public:
|
||||
NS_IMETHOD CreateRawSortKey(const nsCollationStrength strength,
|
||||
const nsString& stringIn, PRUint8* key, PRUint32* outLen);
|
||||
|
||||
// create a sort key (nsString)
|
||||
NS_IMETHOD CreateSortKey(const nsCollationStrength strength,
|
||||
const nsString& stringIn, nsString& key)
|
||||
{return mCollation->CreateSortKey(this, strength, stringIn, key);}
|
||||
|
||||
// compare two sort keys
|
||||
// length is a byte length, result is same as strcmp
|
||||
NS_IMETHOD CompareRawSortKey(const PRUint8* key1, const PRUint32 len1,
|
||||
@ -68,11 +63,6 @@ public:
|
||||
PRInt32* result)
|
||||
{*result = mCollation->CompareRawSortKey(key1, len1, key2, len2);return NS_OK;}
|
||||
|
||||
// compare two sort keys (nsString)
|
||||
NS_IMETHOD CompareSortKey(const nsString& key1, const nsString& key2, PRInt32* result)
|
||||
{*result = mCollation->CompareSortKey(key1, key2);return NS_OK;}
|
||||
|
||||
|
||||
// init this interface to a specified locale (should only be called by collation factory)
|
||||
//
|
||||
NS_IMETHOD Initialize(nsILocale* locale);
|
||||
|
Loading…
x
Reference in New Issue
Block a user