Bug 379339 StringBegins/EndsWith inconsistent with nsReadableUtils.cpp r=bsmedberg sr=darin

This commit is contained in:
neil@parkwaycc.co.uk 2007-05-07 04:09:54 -07:00
Родитель 0c671547ab
Коммит 212b1c5362
1 изменённых файлов: 8 добавлений и 8 удалений

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

@ -1228,32 +1228,32 @@ inline PRBool
StringBeginsWith(const nsAString& aSource, const nsAString& aSubstring, StringBeginsWith(const nsAString& aSource, const nsAString& aSubstring,
nsAString::ComparatorFunc aComparator = nsAString::DefaultComparator) nsAString::ComparatorFunc aComparator = nsAString::DefaultComparator)
{ {
return StringHead(aSource, aSubstring.Length()). return aSubstring.Length() <= aSource.Length() &&
Equals(aSubstring, aComparator); StringHead(aSource, aSubstring.Length()).Equals(aSubstring, aComparator);
} }
inline PRBool inline PRBool
StringEndsWith(const nsAString& aSource, const nsAString& aSubstring, StringEndsWith(const nsAString& aSource, const nsAString& aSubstring,
nsAString::ComparatorFunc aComparator = nsAString::DefaultComparator) nsAString::ComparatorFunc aComparator = nsAString::DefaultComparator)
{ {
return StringTail(aSource, aSubstring.Length()). return aSubstring.Length() <= aSource.Length() &&
Equals(aSubstring, aComparator); StringTail(aSource, aSubstring.Length()).Equals(aSubstring, aComparator);
} }
inline PRBool inline PRBool
StringBeginsWith(const nsACString& aSource, const nsACString& aSubstring, StringBeginsWith(const nsACString& aSource, const nsACString& aSubstring,
nsACString::ComparatorFunc aComparator = nsACString::DefaultComparator) nsACString::ComparatorFunc aComparator = nsACString::DefaultComparator)
{ {
return StringHead(aSource, aSubstring.Length()). return aSubstring.Length() <= aSource.Length() &&
Equals(aSubstring, aComparator); StringHead(aSource, aSubstring.Length()).Equals(aSubstring, aComparator);
} }
inline PRBool inline PRBool
StringEndsWith(const nsACString& aSource, const nsACString& aSubstring, StringEndsWith(const nsACString& aSource, const nsACString& aSubstring,
nsACString::ComparatorFunc aComparator = nsACString::DefaultComparator) nsACString::ComparatorFunc aComparator = nsACString::DefaultComparator)
{ {
return StringTail(aSource, aSubstring.Length()). return aSubstring.Length() <= aSource.Length() &&
Equals(aSubstring, aComparator); StringTail(aSource, aSubstring.Length()).Equals(aSubstring, aComparator);
} }
/** /**