Fix bug 3495802 to return correct offset of substrings from string.find()

This commit is contained in:
James Roseborough
2013-01-27 16:14:03 +00:00
parent 8a5e811c7f
commit 1f89f30239
3 changed files with 13 additions and 3 deletions

View File

@@ -516,9 +516,9 @@ public class LuaString extends LuaValue {
*/
public int indexOf( LuaString s, int start ) {
final int slen = s.length();
final int limit = m_offset + m_length - slen;
for ( int i = m_offset + start; i <= limit; ++i ) {
if ( equals( m_bytes, i, s.m_bytes, s.m_offset, slen ) ) {
final int limit = m_length - slen;
for ( int i = start; i <= limit; ++i ) {
if ( equals( m_bytes, m_offset + i, s.m_bytes, s.m_offset, slen ) ) {
return i;
}
}