Murga-Projects Forums
string.find bug - Printable Version

+- Murga-Projects Forums (http://www.murga-projects.com/forum)
+-- Forum: Project Forums (/forumdisplay.php?fid=1)
+--- Forum: MurgaLua - General (/forumdisplay.php?fid=2)
+--- Thread: string.find bug (/showthread.php?tid=295)


string.find bug - asafp - 03-01-2008 11:53 AM

I have something like this in a loop

i=string.find(string,lookfor,icur,true)

In some cases, it seems that i is being set to 1 when a match is found at the end of the string, which caused my program to go into a loop. I fixed it by testing for i==nil or i<icur so that the test for not found would include i being set to 1 in addition to nil.

It's a complex program and I haven't been able to create a simple program that reproduces the situation.

Has anyone else ever encountered anything like this? Am I crazy? i should never get set to anything less than the starting position which is icur, right?


RE: string.find bug - mikshaw - 03-01-2008 01:37 PM

Quote:
i should never get set to anything less than the starting position which is icur, right?

That's true, as far as I can tell. I suppose it would depend on what the actual string and variable values are, though. We can speculate all we want, but unless you provide more specific info than i=string.find(string,lookfor,icur,true) all it's going to be is speculation.


RE: string.find bug - iGame3D - 03-02-2008 01:43 AM

Yep, need to see the string its failing on.
I'm not getting any bug type result here.

A return of nil seems to occur where appropriate.

Whats your hardware and os?