fixed the 3 instances of Compare() to work with empty strings

git-svn-id: svn://10.0.0.236/trunk@14052 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
pierre%netscape.com
1998-11-04 06:48:11 +00:00
parent 7ee2406a60
commit f6b4569d23
4 changed files with 84 additions and 0 deletions

View File

@@ -1518,6 +1518,13 @@ PRInt32 nsString::Compare(const char *anISOLatin1,PRBool aIgnoreCase,PRInt32 aLe
//In some cases, this can speed up the string comparison.
int maxlen=(aLength<mLength) ? aLength : mLength;
if (maxlen == 0) {
if ((mLength == 0) && (aLength == 0))
return 0;
if (mLength == 0)
return -1;
return 1;
}
if (aIgnoreCase) {
return nsCRT::strncasecmp(mStr,anISOLatin1,maxlen);
}
@@ -1538,6 +1545,13 @@ PRInt32 nsString::Compare(const char *anISOLatin1,PRBool aIgnoreCase,PRInt32 aLe
*/
PRInt32 nsString::Compare(const nsString &S,PRBool aIgnoreCase) const {
int maxlen=(S.mLength<mLength) ? S.mLength : mLength;
if (maxlen == 0) {
if ((mLength == 0) && (S.mLength == 0))
return 0;
if (mLength == 0)
return -1;
return 1;
}
if (aIgnoreCase) {
return nsCRT::strncasecmp(mStr,S.mStr,maxlen);
}
@@ -1558,6 +1572,13 @@ PRInt32 nsString::Compare(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aL
//In some cases, this can speed up the string comparison.
int maxlen=(aLength<mLength) ? aLength : mLength;
if (maxlen == 0) {
if ((mLength == 0) && (aLength == 0))
return 0;
if (mLength == 0)
return -1;
return 1;
}
if (aIgnoreCase) {
return nsCRT::strncasecmp(mStr,aString,maxlen);
}