diff --git a/mozilla/string/obsolete/nsStr.cpp b/mozilla/string/obsolete/nsStr.cpp index 50b0ca1e1ea..5974b5c5c83 100644 --- a/mozilla/string/obsolete/nsStr.cpp +++ b/mozilla/string/obsolete/nsStr.cpp @@ -438,23 +438,31 @@ void nsStr::CompressSet(nsStr& aDest,const char* aSet,PRUint32 aChar,PRBool aEli PRInt32 nsStr::FindSubstr(const nsStr& aDest,const nsStr& aTarget, PRBool aIgnoreCase,PRUint32 anOffset) { - PRUint32 index=anOffset-1; - PRUint32 theMax=aDest.mLength-aTarget.mLength; if((aDest.mLength>0) && (aTarget.mLength>0) && (anOffset=0) && (GetCharAt(aDest,theBufIndex)==GetCharAt(aTarget,thePatIndex))){ + --theBufIndex; + --thePatIndex; } - if(matches) { - return index; + if(-1==thePatIndex){ + return anOffset+theBufIndex+1; } } }//if diff --git a/mozilla/xpcom/ds/nsStr.cpp b/mozilla/xpcom/ds/nsStr.cpp index 50b0ca1e1ea..5974b5c5c83 100644 --- a/mozilla/xpcom/ds/nsStr.cpp +++ b/mozilla/xpcom/ds/nsStr.cpp @@ -438,23 +438,31 @@ void nsStr::CompressSet(nsStr& aDest,const char* aSet,PRUint32 aChar,PRBool aEli PRInt32 nsStr::FindSubstr(const nsStr& aDest,const nsStr& aTarget, PRBool aIgnoreCase,PRUint32 anOffset) { - PRUint32 index=anOffset-1; - PRUint32 theMax=aDest.mLength-aTarget.mLength; if((aDest.mLength>0) && (aTarget.mLength>0) && (anOffset=0) && (GetCharAt(aDest,theBufIndex)==GetCharAt(aTarget,thePatIndex))){ + --theBufIndex; + --thePatIndex; } - if(matches) { - return index; + if(-1==thePatIndex){ + return anOffset+theBufIndex+1; } } }//if diff --git a/mozilla/xpcom/string/obsolete/nsStr.cpp b/mozilla/xpcom/string/obsolete/nsStr.cpp index 50b0ca1e1ea..5974b5c5c83 100644 --- a/mozilla/xpcom/string/obsolete/nsStr.cpp +++ b/mozilla/xpcom/string/obsolete/nsStr.cpp @@ -438,23 +438,31 @@ void nsStr::CompressSet(nsStr& aDest,const char* aSet,PRUint32 aChar,PRBool aEli PRInt32 nsStr::FindSubstr(const nsStr& aDest,const nsStr& aTarget, PRBool aIgnoreCase,PRUint32 anOffset) { - PRUint32 index=anOffset-1; - PRUint32 theMax=aDest.mLength-aTarget.mLength; if((aDest.mLength>0) && (aTarget.mLength>0) && (anOffset=0) && (GetCharAt(aDest,theBufIndex)==GetCharAt(aTarget,thePatIndex))){ + --theBufIndex; + --thePatIndex; } - if(matches) { - return index; + if(-1==thePatIndex){ + return anOffset+theBufIndex+1; } } }//if