Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug - llGetSubString and llList2List make wrong result on negative out of range index (when Optimizations are enabled) #35

Closed
PellSmit opened this issue Nov 11, 2016 · 8 comments
Labels
Milestone

Comments

@PellSmit
Copy link

PellSmit commented Nov 11, 2016

(1)

// OutOfRangeNegativeIndex.lslp
default
{
	state_entry()
	{
		string s = llGetSubString("0123456789", -11, -11);
		llOwnerSay("s = " + s + ", length = " + (string)llStringLength(s));
		list l = llList2List([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], -11, -11);
		llOwnerSay("l = [" + llDumpList2String(l, ", ") + "]");
	}
}

was converted to

(2)

// OutOfRangeNegativeIndex.lslp 
// 2016-11-11 13:40:30 - LSLForge (0.1.9) generated
// OutOfRangeNegativeIndex.lslp
default {

	state_entry() {
    string s = "0";
    llOwnerSay(((("s = " + s) + ", length = ") + ((string)llStringLength(s))));
    list l = [0];
    llOwnerSay((("l = [" + llDumpList2String(l,", ")) + "]"));
  }
}

But result of (1) is:
[20:31] Object: s = , length = 0
[20:31] Object: l = []

and (2)
[20:32] Object: s = 0, length = 1
[20:32] Object: l = [0]

It is a bug in InternalLLFuncs.hs

@raysilent
Copy link
Owner

Pell if you rollback InternalLLFuncs.hs to it's previous version will it fix the bug?

@PellSmit
Copy link
Author

Do you mean rollback to 0.1.8?

@raysilent
Copy link
Owner

@PellSmit
Copy link
Author

Tried it but same result...

@raysilent
Copy link
Owner

It must be somewhere here:

subList source start end =
    let n = length source
        s = convertIndex n start
        e = convertIndex n end
    in
        if s <= e then take (e - s + 1) $ drop s source
        else take (e+1) source ++ drop s source

convertIndex length index = if index < 0 then length + index else index

@PellSmit
Copy link
Author

Yes, exactly!
I'll fix it later.

@raysilent
Copy link
Owner

It works with the indecies -1..-10, and then keeps returning the same -10 index

@raysilent raysilent changed the title Bug - llGetSubString and llList2List make wrong result on negative out of range index Bug - llGetSubString and llList2List make wrong result on negative out of range index (when Optimization is turned on) Nov 11, 2016
@raysilent raysilent changed the title Bug - llGetSubString and llList2List make wrong result on negative out of range index (when Optimization is turned on) Bug - llGetSubString and llList2List make wrong result on negative out of range index (when Optimizations are enabled) Nov 11, 2016
raysilent added a commit that referenced this issue Nov 11, 2016
New constants and Pell Smit/bug fix #35
@raysilent
Copy link
Owner

Looks good! Merged everything into https://github.com/raysilent/lslforge/tree/0.1.9.1 branch

@raysilent raysilent added the bug label Nov 13, 2016
@raysilent raysilent added this to the 0.1.9.1 milestone Nov 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants