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

This commit is contained in:
pierre%netscape.com 1998-11-04 06:48:11 +00:00
Родитель 809c3fa63c
Коммит 57bc56148a
4 изменённых файлов: 84 добавлений и 0 удалений

Просмотреть файл

@ -1518,6 +1518,13 @@ PRInt32 nsString::Compare(const char *anISOLatin1,PRBool aIgnoreCase,PRInt32 aLe
//In some cases, this can speed up the string comparison. //In some cases, this can speed up the string comparison.
int maxlen=(aLength<mLength) ? aLength : mLength; 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) { if (aIgnoreCase) {
return nsCRT::strncasecmp(mStr,anISOLatin1,maxlen); 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 { PRInt32 nsString::Compare(const nsString &S,PRBool aIgnoreCase) const {
int maxlen=(S.mLength<mLength) ? S.mLength : mLength; 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) { if (aIgnoreCase) {
return nsCRT::strncasecmp(mStr,S.mStr,maxlen); 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. //In some cases, this can speed up the string comparison.
int maxlen=(aLength<mLength) ? aLength : mLength; 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) { if (aIgnoreCase) {
return nsCRT::strncasecmp(mStr,aString,maxlen); return nsCRT::strncasecmp(mStr,aString,maxlen);
} }

Просмотреть файл

@ -1518,6 +1518,13 @@ PRInt32 nsString::Compare(const char *anISOLatin1,PRBool aIgnoreCase,PRInt32 aLe
//In some cases, this can speed up the string comparison. //In some cases, this can speed up the string comparison.
int maxlen=(aLength<mLength) ? aLength : mLength; 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) { if (aIgnoreCase) {
return nsCRT::strncasecmp(mStr,anISOLatin1,maxlen); 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 { PRInt32 nsString::Compare(const nsString &S,PRBool aIgnoreCase) const {
int maxlen=(S.mLength<mLength) ? S.mLength : mLength; 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) { if (aIgnoreCase) {
return nsCRT::strncasecmp(mStr,S.mStr,maxlen); 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. //In some cases, this can speed up the string comparison.
int maxlen=(aLength<mLength) ? aLength : mLength; 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) { if (aIgnoreCase) {
return nsCRT::strncasecmp(mStr,aString,maxlen); return nsCRT::strncasecmp(mStr,aString,maxlen);
} }

Просмотреть файл

@ -1518,6 +1518,13 @@ PRInt32 nsString::Compare(const char *anISOLatin1,PRBool aIgnoreCase,PRInt32 aLe
//In some cases, this can speed up the string comparison. //In some cases, this can speed up the string comparison.
int maxlen=(aLength<mLength) ? aLength : mLength; 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) { if (aIgnoreCase) {
return nsCRT::strncasecmp(mStr,anISOLatin1,maxlen); 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 { PRInt32 nsString::Compare(const nsString &S,PRBool aIgnoreCase) const {
int maxlen=(S.mLength<mLength) ? S.mLength : mLength; 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) { if (aIgnoreCase) {
return nsCRT::strncasecmp(mStr,S.mStr,maxlen); 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. //In some cases, this can speed up the string comparison.
int maxlen=(aLength<mLength) ? aLength : mLength; 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) { if (aIgnoreCase) {
return nsCRT::strncasecmp(mStr,aString,maxlen); return nsCRT::strncasecmp(mStr,aString,maxlen);
} }

Просмотреть файл

@ -1518,6 +1518,13 @@ PRInt32 nsString::Compare(const char *anISOLatin1,PRBool aIgnoreCase,PRInt32 aLe
//In some cases, this can speed up the string comparison. //In some cases, this can speed up the string comparison.
int maxlen=(aLength<mLength) ? aLength : mLength; 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) { if (aIgnoreCase) {
return nsCRT::strncasecmp(mStr,anISOLatin1,maxlen); 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 { PRInt32 nsString::Compare(const nsString &S,PRBool aIgnoreCase) const {
int maxlen=(S.mLength<mLength) ? S.mLength : mLength; 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) { if (aIgnoreCase) {
return nsCRT::strncasecmp(mStr,S.mStr,maxlen); 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. //In some cases, this can speed up the string comparison.
int maxlen=(aLength<mLength) ? aLength : mLength; 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) { if (aIgnoreCase) {
return nsCRT::strncasecmp(mStr,aString,maxlen); return nsCRT::strncasecmp(mStr,aString,maxlen);
} }