Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Bug: AString<B>::ReverseFind broken for wchar
Re: Bug: AString<B>::ReverseFind broken for wchar [message #42259 is a reply to message #42257] Sun, 02 March 2014 18:35 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14256
Registered: November 2005
Ultimate Member
I might be wrong, but:

int AString<B>::ReverseFind(int len, const tchar *s, int from) const
{
	ASSERT(from >= 0 && from <= GetLength());
	if(from < GetLength()) {
		const tchar *ptr = B::Begin();
		const tchar *p = ptr + from - len + 1;
		len *= sizeof(tchar); <<<<<<<<<<<<<<<<<<<<<<<<<<
		while(p >= ptr) {
			if(*s == *p && memcmp(s, p, len) == 0)
				return (int)(p - ptr);
			p--;
		}
	}
	return -1;
}


should do the trick, IMO?

But tvo_memeq problem is real, thank you! (fixed)

Mirek
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: To get xml errors from LoadFromXML
Next Topic: String should implement the Boyer Moore algo
Goto Forum:
  


Current Time: Tue Apr 29 21:03:41 CEST 2025

Total time taken to generate the page: 0.01078 seconds