diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs index 1efe798d2f..0b41bc6baf 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs @@ -729,7 +729,8 @@ namespace SecondLife public int Compare(KeyValuePair a, KeyValuePair b) { - return a.Key.CompareTo(b.Key); + int kc = a.Key.CompareTo(b.Key); + return (kc != 0) ? kc : a.Value.CompareTo(b.Value); } } @@ -751,27 +752,19 @@ namespace SecondLife sorted.Sort(new kvpSorter()); - int l = 1; - int c = 1; + int l = sorted[0].Key; + int c = sorted[0].Value; foreach (KeyValuePair cspos in sorted) { - if (cspos.Key >= line) - { - if (cspos.Key > line) - return new KeyValuePair(l, c); - if (cspos.Value > col) - return new KeyValuePair(l, c); - c = cspos.Value; - if (c == 0) - c++; - } - else - { - l = cspos.Key; - } + if (cspos.Key >= line && + !(cspos.Key == line && cspos.Value <= col)) + break; + l = cspos.Key; + c = cspos.Value; } - return new KeyValuePair(l, c); + positionMap.TryGetValue(new KeyValuePair(l, c), out ret); + return ret; } string ReplaceTypes(string message) diff --git a/OpenSim/Tools/Compiler/Program.cs b/OpenSim/Tools/Compiler/Program.cs index 6c59c313a6..b9c960b532 100644 --- a/OpenSim/Tools/Compiler/Program.cs +++ b/OpenSim/Tools/Compiler/Program.cs @@ -255,12 +255,13 @@ namespace OpenSim.Tools.LSL.Compiler return FindErrorPosition(line, col, null); } - private class kvpSorter : IComparer> + private class kvpSorter : IComparer> { - public int Compare(KeyValuePair a, - KeyValuePair b) + public int Compare(KeyValuePair a, + KeyValuePair b) { - return a.Key.CompareTo(b.Key); + int kc = a.Key.CompareTo(b.Key); + return (kc != 0) ? kc : a.Value.CompareTo(b.Value); } } @@ -277,32 +278,24 @@ namespace OpenSim.Tools.LSL.Compiler out ret)) return ret; - List> sorted = - new List>(positionMap.Keys); + List> sorted = + new List>(positionMap.Keys); sorted.Sort(new kvpSorter()); - int l = 1; - int c = 1; + int l = sorted[0].Key; + int c = sorted[0].Value; foreach (KeyValuePair cspos in sorted) { - if (cspos.Key >= line) - { - if (cspos.Key > line) - return new KeyValuePair(l, c); - if (cspos.Value > col) - return new KeyValuePair(l, c); - c = cspos.Value; - if (c == 0) - c++; - } - else - { - l = cspos.Key; - } + if (cspos.Key >= line && + !(cspos.Key == line && cspos.Value <= col)) + break; + l = cspos.Key; + c = cspos.Value; } - return new KeyValuePair(l, c); + positionMap.TryGetValue(new KeyValuePair(l, c), out ret); + return ret; } } }