First part of fix for bug 107575 - remove nsString::FindChar because there is already an nsAString::FindChar, and remove the "ignore case" option in RFindChar
r=dougt, sr=jag git-svn-id: svn://10.0.0.236/trunk@113200 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -528,8 +528,7 @@ inline PRInt32 FindChar1(const char* aDest,PRUint32 aDestLength,PRInt32 anOffset
|
||||
* @param aCount tells us how many characters to iterate through (which may be different than aLength); -1 means use full length.
|
||||
* @return index of pos if found, else -1 (kNotFound)
|
||||
*/
|
||||
inline PRInt32 FindChar2(const PRUnichar* aDest,PRUint32 aDestLength,PRInt32 anOffset,const PRUnichar aChar,PRBool aIgnoreCase,PRInt32 aCount) {
|
||||
#ifndef XPCOM_STANDALONE
|
||||
inline PRInt32 FindChar2(const PRUnichar* aDest,PRUint32 aDestLength,PRInt32 anOffset,const PRUnichar aChar,PRInt32 aCount) {
|
||||
|
||||
if(anOffset<0)
|
||||
anOffset=0;
|
||||
@@ -547,33 +546,14 @@ inline PRInt32 FindChar2(const PRUnichar* aDest,PRUint32 aDestLength,PRInt32 anO
|
||||
const PRUnichar* max = root+aDestLength;
|
||||
const PRUnichar* end = (last<max) ? last : max;
|
||||
|
||||
if (aIgnoreCase && NS_FAILED(NS_InitCaseConversion()))
|
||||
aIgnoreCase = PR_FALSE;
|
||||
|
||||
if (aIgnoreCase) {
|
||||
PRUnichar theChar;
|
||||
gCaseConv->ToUpper(aChar, &theChar);
|
||||
while(left<end){
|
||||
PRUnichar leftChar;
|
||||
gCaseConv->ToUpper(*left, &leftChar);
|
||||
if (leftChar == theChar)
|
||||
return left-root;
|
||||
++left;
|
||||
}
|
||||
}
|
||||
else {
|
||||
while(left<end){
|
||||
if(*left==aChar)
|
||||
return (left-root);
|
||||
++left;
|
||||
}
|
||||
while(left<end){
|
||||
if(*left==aChar)
|
||||
return (left-root);
|
||||
++left;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
NS_ERROR("call not supported in XPCOM_STANDALONE");
|
||||
#endif
|
||||
return kNotFound;
|
||||
}
|
||||
|
||||
@@ -647,8 +627,7 @@ inline PRInt32 RFindChar1(const char* aDest,PRUint32 aDestLength,PRInt32 anOffse
|
||||
* @param aCount tells us how many characters to iterate through (which may be different than aLength); -1 means use full length.
|
||||
* @return index of pos if found, else -1 (kNotFound)
|
||||
*/
|
||||
inline PRInt32 RFindChar2(const PRUnichar* aDest,PRUint32 aDestLength,PRInt32 anOffset,const PRUnichar aChar,PRBool aIgnoreCase,PRInt32 aCount) {
|
||||
#ifndef XPCOM_STANDALONE
|
||||
inline PRInt32 RFindChar2(const PRUnichar* aDest,PRUint32 aDestLength,PRInt32 anOffset,const PRUnichar aChar,PRInt32 aCount) {
|
||||
|
||||
if(anOffset<0)
|
||||
anOffset=(PRInt32)aDestLength-1;
|
||||
@@ -665,33 +644,13 @@ inline PRInt32 RFindChar2(const PRUnichar* aDest,PRUint32 aDestLength,PRInt32 an
|
||||
const PRUnichar* min = rightmost-aCount+1;
|
||||
const PRUnichar* leftmost = (min<root) ? root: min;
|
||||
|
||||
if (aIgnoreCase && NS_FAILED(NS_InitCaseConversion()))
|
||||
aIgnoreCase = PR_FALSE;
|
||||
|
||||
if(aIgnoreCase) {
|
||||
PRUnichar theChar;
|
||||
gCaseConv->ToUpper(aChar, &theChar);
|
||||
while(leftmost<rightmost){
|
||||
PRUnichar rightChar;
|
||||
gCaseConv->ToUpper(*rightmost, &rightChar);
|
||||
if(rightChar==theChar)
|
||||
return rightmost-root;
|
||||
--rightmost;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
while(leftmost<=rightmost){
|
||||
if((*rightmost)==aChar)
|
||||
return rightmost-root;
|
||||
--rightmost;
|
||||
}
|
||||
while(leftmost<=rightmost){
|
||||
if((*rightmost)==aChar)
|
||||
return rightmost-root;
|
||||
--rightmost;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
NS_ERROR("call not supported in XPCOM_STANDALONE");
|
||||
#endif
|
||||
|
||||
return kNotFound;
|
||||
}
|
||||
|
||||
@@ -781,9 +781,9 @@ PRInt32 nsStr::FindChar1(const nsStr& aDest,PRUnichar aChar, PRBool aIgnoreCase,
|
||||
return ::FindChar1(aDest.mStr,aDest.mLength,anOffset,aChar,aIgnoreCase,aCount);
|
||||
}
|
||||
|
||||
PRInt32 nsStr::FindChar2(const nsStr& aDest,PRUnichar aChar, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) {
|
||||
PRInt32 nsStr::FindChar2(const nsStr& aDest,PRUnichar aChar, PRInt32 anOffset,PRInt32 aCount) {
|
||||
NS_ASSERTION(aDest.GetCharSize() == eTwoByte, "Must be 2 byte");
|
||||
return ::FindChar2(aDest.mUStr,aDest.mLength,anOffset,aChar,aIgnoreCase,aCount);
|
||||
return ::FindChar2(aDest.mUStr,aDest.mLength,anOffset,aChar,aCount);
|
||||
}
|
||||
|
||||
|
||||
@@ -817,7 +817,7 @@ PRInt32 nsStr::FindCharInSet1(const nsStr& aDest,const nsStr& aSet,PRBool aIgnor
|
||||
}
|
||||
return kNotFound;
|
||||
}
|
||||
PRInt32 nsStr::FindCharInSet2(const nsStr& aDest,const nsStr& aSet,PRBool aIgnoreCase,PRInt32 anOffset) {
|
||||
PRInt32 nsStr::FindCharInSet2(const nsStr& aDest,const nsStr& aSet,PRInt32 anOffset) {
|
||||
|
||||
NS_ASSERTION(aSet.GetCharSize() == eTwoByte, "Must be 2 byte");
|
||||
|
||||
@@ -830,7 +830,7 @@ PRInt32 nsStr::FindCharInSet2(const nsStr& aDest,const nsStr& aSet,PRBool aIgnor
|
||||
if((0<aDest.mLength) && (0<aSet.mLength)){
|
||||
while(++index<(PRInt32)aDest.mLength) {
|
||||
PRUnichar theChar=GetCharAt(aDest,index);
|
||||
thePos=::FindChar2(aSet.mUStr,aSet.mLength,0,theChar,aIgnoreCase,aSet.mLength);
|
||||
thePos=::FindChar2(aSet.mUStr,aSet.mLength,0,theChar,aSet.mLength);
|
||||
if(kNotFound!=thePos)
|
||||
return index;
|
||||
} //while
|
||||
@@ -1031,9 +1031,9 @@ PRInt32 nsStr::RFindChar1(const nsStr& aDest,PRUnichar aChar, PRBool aIgnoreCase
|
||||
NS_ASSERTION(aDest.GetCharSize() == eOneByte, "Must be 1 bytes");
|
||||
return ::RFindChar1(aDest.mStr,aDest.mLength,anOffset,aChar,aIgnoreCase,aCount);
|
||||
}
|
||||
PRInt32 nsStr::RFindChar2(const nsStr& aDest,PRUnichar aChar, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) {
|
||||
PRInt32 nsStr::RFindChar2(const nsStr& aDest,PRUnichar aChar, PRInt32 anOffset,PRInt32 aCount) {
|
||||
NS_ASSERTION(aDest.GetCharSize() == eTwoByte, "Must be 2 bytes");
|
||||
return ::RFindChar2(aDest.mUStr,aDest.mLength,anOffset,aChar,aIgnoreCase,aCount);
|
||||
return ::RFindChar2(aDest.mUStr,aDest.mLength,anOffset,aChar,aCount);
|
||||
}
|
||||
|
||||
|
||||
@@ -1067,7 +1067,7 @@ PRInt32 nsStr::RFindCharInSet1(const nsStr& aDest,const nsStr& aSet,PRBool aIgno
|
||||
return kNotFound;
|
||||
}
|
||||
|
||||
PRInt32 nsStr::RFindCharInSet2(const nsStr& aDest,const nsStr& aSet,PRBool aIgnoreCase,PRInt32 anOffset) {
|
||||
PRInt32 nsStr::RFindCharInSet2(const nsStr& aDest,const nsStr& aSet,PRInt32 anOffset) {
|
||||
|
||||
NS_ASSERTION(aSet.GetCharSize() == eTwoByte, "Must be 2 byte");
|
||||
|
||||
@@ -1079,7 +1079,7 @@ PRInt32 nsStr::RFindCharInSet2(const nsStr& aDest,const nsStr& aSet,PRBool aIgno
|
||||
if(0<aDest.mLength) {
|
||||
while(--index>=0) {
|
||||
PRUnichar theChar=GetCharAt(aDest,index);
|
||||
thePos=::FindChar2(aSet.mUStr,aSet.mLength,0,theChar,aIgnoreCase,aSet.mLength);
|
||||
thePos=::FindChar2(aSet.mUStr,aSet.mLength,0,theChar,aSet.mLength);
|
||||
if(kNotFound!=thePos)
|
||||
return index;
|
||||
} //while
|
||||
|
||||
@@ -450,10 +450,10 @@ protected:
|
||||
static PRInt32 FindSubstr2in2(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount);
|
||||
|
||||
static PRInt32 FindChar1(const nsStr& aDest,PRUnichar aChar, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount);
|
||||
static PRInt32 FindChar2(const nsStr& aDest,PRUnichar aChar, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount);
|
||||
static PRInt32 FindChar2(const nsStr& aDest,PRUnichar aChar, PRInt32 anOffset,PRInt32 aCount);
|
||||
|
||||
static PRInt32 FindCharInSet1(const nsStr& aDest,const nsStr& aSet,PRBool aIgnoreCase,PRInt32 anOffset);
|
||||
static PRInt32 FindCharInSet2(const nsStr& aDest,const nsStr& aSet,PRBool aIgnoreCase,PRInt32 anOffset);
|
||||
static PRInt32 FindCharInSet2(const nsStr& aDest,const nsStr& aSet,PRInt32 anOffset);
|
||||
|
||||
static PRInt32 RFindSubstr1in1(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount);
|
||||
static PRInt32 RFindSubstr2in1(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount);
|
||||
@@ -461,10 +461,10 @@ protected:
|
||||
static PRInt32 RFindSubstr2in2(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount);
|
||||
|
||||
static PRInt32 RFindChar1(const nsStr& aDest,PRUnichar aChar, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount);
|
||||
static PRInt32 RFindChar2(const nsStr& aDest,PRUnichar aChar, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount);
|
||||
static PRInt32 RFindChar2(const nsStr& aDest,PRUnichar aChar, PRInt32 anOffset,PRInt32 aCount);
|
||||
|
||||
static PRInt32 RFindCharInSet1(const nsStr& aDest,const nsStr& aSet,PRBool aIgnoreCase,PRInt32 anOffset);
|
||||
static PRInt32 RFindCharInSet2(const nsStr& aDest,const nsStr& aSet,PRBool aIgnoreCase,PRInt32 anOffset);
|
||||
static PRInt32 RFindCharInSet2(const nsStr& aDest,const nsStr& aSet,PRInt32 anOffset);
|
||||
|
||||
static void Overwrite(nsStr& aDest,const nsStr& aSource,PRInt32 anOffset);
|
||||
|
||||
|
||||
@@ -612,7 +612,7 @@ void nsCString::AssignWithConversion(const PRUnichar* aString,PRInt32 aCount) {
|
||||
// If this assertion fires, the caller is probably lying about the length of
|
||||
// the passed-in string. File a bug on the caller.
|
||||
#ifdef NS_DEBUG
|
||||
PRInt32 len=nsStr::FindChar2(temp,0,PR_FALSE,0,temp.mLength);
|
||||
PRInt32 len=nsStr::FindChar2(temp,0,PR_FALSE,temp.mLength);
|
||||
if(kNotFound<len) {
|
||||
NS_WARNING(kPossibleNull);
|
||||
}
|
||||
@@ -949,7 +949,7 @@ PRInt32 nsCString::FindCharInSet(const PRUnichar* aStringSet,PRInt32 anOffset) c
|
||||
nsStr::Initialize(temp,eTwoByte);
|
||||
temp.mLength=nsCRT::strlen(aStringSet);
|
||||
temp.mStr=(char*)aStringSet;
|
||||
result=nsStr::FindCharInSet2(*this,temp,PR_FALSE,anOffset);
|
||||
result=nsStr::FindCharInSet2(*this,temp,anOffset);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -969,7 +969,7 @@ PRInt32 nsCString::FindCharInSet(const nsCString& aSet,PRInt32 anOffset) const{
|
||||
}
|
||||
|
||||
PRInt32 nsCString::FindCharInSet(const nsString& aSet,PRInt32 anOffset) const{
|
||||
PRInt32 result=nsStr::FindCharInSet2(*this,aSet,PR_FALSE,anOffset);
|
||||
PRInt32 result=nsStr::FindCharInSet2(*this,aSet,anOffset);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1072,7 +1072,7 @@ PRInt32 nsCString::RFindCharInSet(const PRUnichar* aStringSet,PRInt32 anOffset)
|
||||
nsStr::Initialize(temp,eTwoByte);
|
||||
temp.mLength=nsCRT::strlen(aStringSet);
|
||||
temp.mUStr=(PRUnichar*)aStringSet;
|
||||
result=nsStr::RFindCharInSet2(*this,temp,PR_FALSE,anOffset);
|
||||
result=nsStr::RFindCharInSet2(*this,temp,anOffset);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -1092,7 +1092,7 @@ PRInt32 nsCString::RFindCharInSet(const nsCString& aSet,PRInt32 anOffset) const{
|
||||
}
|
||||
|
||||
PRInt32 nsCString::RFindCharInSet(const nsString& aSet,PRInt32 anOffset) const{
|
||||
PRInt32 result=nsStr::RFindCharInSet2(*this,aSet,PR_FALSE,anOffset);
|
||||
PRInt32 result=nsStr::RFindCharInSet2(*this,aSet,anOffset);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -945,22 +945,6 @@ PRInt32 nsString::Find(const nsString& aString,PRBool aIgnoreCase,PRInt32 anOffs
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Search for a given char, starting at given offset
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aChar is the unichar to be sought
|
||||
* @param aIgnoreCase tells us whether or not to do caseless compare
|
||||
* @param anOffset tells us where in this string to start searching
|
||||
* @param aCount tells us how many iterations to make starting at the given offset
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 nsString::FindChar(PRUnichar aChar,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{
|
||||
PRInt32 result=nsStr::FindChar2(*this,aChar,aIgnoreCase,anOffset,aCount);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method finds the offset of the first char in this string that is
|
||||
* a member of the given charset, starting the search at anOffset
|
||||
@@ -1002,7 +986,7 @@ PRInt32 nsString::FindCharInSet(const PRUnichar* aStringSet,PRInt32 anOffset) co
|
||||
nsStr::Initialize(temp,eTwoByte);
|
||||
temp.mLength=nsCRT::strlen(aStringSet);
|
||||
temp.mStr=(char*)aStringSet;
|
||||
result=nsStr::FindCharInSet2(*this,temp,PR_FALSE,anOffset);
|
||||
result=nsStr::FindCharInSet2(*this,temp,anOffset);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -1017,7 +1001,7 @@ PRInt32 nsString::FindCharInSet(const PRUnichar* aStringSet,PRInt32 anOffset) co
|
||||
* @return
|
||||
*/
|
||||
PRInt32 nsString::FindCharInSet(const nsString& aSet,PRInt32 anOffset) const{
|
||||
PRInt32 result=nsStr::FindCharInSet2(*this,aSet,PR_FALSE,anOffset);
|
||||
PRInt32 result=nsStr::FindCharInSet2(*this,aSet,anOffset);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1090,8 +1074,8 @@ PRInt32 nsString::RFind(const char* aString,PRBool aIgnoreCase,PRInt32 anOffset,
|
||||
* @param anOffset
|
||||
* @return offset of found char, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 nsString::RFindChar(PRUnichar aChar,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{
|
||||
PRInt32 result=nsStr::RFindChar2(*this,aChar,aIgnoreCase,anOffset,aCount);
|
||||
PRInt32 nsString::RFindChar(PRUnichar aChar,PRInt32 anOffset,PRInt32 aCount) const{
|
||||
PRInt32 result=nsStr::RFindChar2(*this,aChar,anOffset,aCount);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1128,7 +1112,7 @@ PRInt32 nsString::RFindCharInSet(const char* aCStringSet,PRInt32 anOffset) const
|
||||
* @return offset of found char, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 nsString::RFindCharInSet(const nsString& aSet,PRInt32 anOffset) const{
|
||||
PRInt32 result=nsStr::RFindCharInSet2(*this,aSet,PR_FALSE,anOffset);
|
||||
PRInt32 result=nsStr::RFindCharInSet2(*this,aSet,anOffset);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1156,7 +1140,7 @@ PRInt32 nsString::RFindCharInSet(const PRUnichar* aStringSet,PRInt32 anOffset) c
|
||||
nsStr::Initialize(temp,eTwoByte);
|
||||
temp.mLength=nsCRT::strlen(aStringSet);
|
||||
temp.mUStr=(PRUnichar*)aStringSet;
|
||||
result=nsStr::RFindCharInSet2(*this,temp,PR_FALSE,anOffset);
|
||||
result=nsStr::RFindCharInSet2(*this,temp,anOffset);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -329,19 +329,6 @@ public:
|
||||
PRInt32 Find(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=0,PRInt32 aCount=-1) const;
|
||||
PRInt32 Find(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=0,PRInt32 aCount=-1) const;
|
||||
|
||||
|
||||
/**
|
||||
* Search for given char within this string
|
||||
*
|
||||
* @param aString is substring to be sought in this
|
||||
* @param anOffset tells us where in this strig to start searching
|
||||
* @param aIgnoreCase selects case sensitivity
|
||||
* @param aCount tells us how many iterations to make starting at the given offset
|
||||
* @return find pos in string, or -1 (kNotFound)
|
||||
*/
|
||||
//PRInt32 Find(PRUnichar aChar,PRInt32 offset=-1,PRBool aIgnoreCase=PR_FALSE) const;
|
||||
PRInt32 FindChar(PRUnichar aChar,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=0,PRInt32 aCount=-1) const;
|
||||
|
||||
/**
|
||||
* This method searches this string for the first character
|
||||
* found in the given charset
|
||||
@@ -379,7 +366,7 @@ public:
|
||||
* @return find pos in string, or -1 (kNotFound)
|
||||
*/
|
||||
//PRInt32 RFind(PRUnichar aChar,PRInt32 offset=-1,PRBool aIgnoreCase=PR_FALSE) const;
|
||||
PRInt32 RFindChar(PRUnichar aChar,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1,PRInt32 aCount=-1) const;
|
||||
PRInt32 RFindChar(PRUnichar aChar,PRInt32 anOffset=-1,PRInt32 aCount=-1) const;
|
||||
|
||||
/**
|
||||
* This method searches this string for the last character
|
||||
|
||||
Reference in New Issue
Block a user