diff --git a/mozilla/string/obsolete/nsStr.cpp b/mozilla/string/obsolete/nsStr.cpp index bd40c1191c7..a1b21c11225 100644 --- a/mozilla/string/obsolete/nsStr.cpp +++ b/mozilla/string/obsolete/nsStr.cpp @@ -389,53 +389,44 @@ void nsStr::StripChars(nsStr& aDest,const char* aSet){ Searching methods... **************************************************************/ - /** * This searches aDest for a given substring * - * @update gess 2/04/00: added aCount argument to restrict search + * @update gess 3/25/98 * @param aDest string to search * @param aTarget is the substring you're trying to find. * @param aIgnorecase indicates case sensitivity of search * @param anOffset tells us where to start the search - * @param aCount tells us how many iterations to make from offset; -1 means the full length of the string * @return index in aDest where member of aSet occurs, or -1 if not found */ PRInt32 nsStr::FindSubstr(const nsStr& aDest,const nsStr& aTarget, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) { - PRInt32 theMaxPos = aDest.mLength-aTarget.mLength; //this is the last pos that is feasible for starting the search, with given lengths... + // NS_PRECONDITION(aTarget.mLength!=1,kCallFindChar); - if(0<=theMaxPos) { - - if(anOffset<0) - anOffset=0; - - if((0=aTarget.mLength) && (aTarget.mLength>0) && (index>=0)){ + PRInt32 theTargetMax=aTarget.mLength; + while(index<=theMax) { + PRInt32 theSubIndex=-1; + PRBool matches=PR_TRUE; + while((++theSubIndex=aTarget.mLength) && (aTarget.mLength>0) && (index>=0)){ - const char* leftmost = (min=0) { + PRInt32 theSubIndex=-1; + PRBool matches=PR_FALSE; + if(index+theCopy.mLength<=aDest.mLength) { + matches=PR_TRUE; + while((++theSubIndex=aTarget.mLength) && (aTarget.mLength>0) && (index>=0)){ + PRInt32 theTargetMax=aTarget.mLength; + while(index<=theMax) { + PRInt32 theSubIndex=-1; + PRBool matches=PR_TRUE; + while((++theSubIndex=aTarget.mLength) && (aTarget.mLength>0) && (index>=0)){ - const char* leftmost = (min=0) { + PRInt32 theSubIndex=-1; + PRBool matches=PR_FALSE; + if(index+theCopy.mLength<=aDest.mLength) { + matches=PR_TRUE; + while((++theSubIndex=aTarget.mLength) && (aTarget.mLength>0) && (index>=0)){ + PRInt32 theTargetMax=aTarget.mLength; + while(index<=theMax) { + PRInt32 theSubIndex=-1; + PRBool matches=PR_TRUE; + while((++theSubIndex=aTarget.mLength) && (aTarget.mLength>0) && (index>=0)){ - const char* leftmost = (min=0) { + PRInt32 theSubIndex=-1; + PRBool matches=PR_FALSE; + if(index+theCopy.mLength<=aDest.mLength) { + matches=PR_TRUE; + while((++theSubIndex