aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-06-28 21:30:36 +0100
committerJustin Clark-Casey (justincc)2012-06-28 21:30:36 +0100
commit972b0b52f9acedf13114fbed2ec35bb63adeea79 (patch)
tree5fdcd7eb98876288a22b9807879efca7adc4495d /OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
parentAvoid reporting false positives when a colon is in a comment in the first lin... (diff)
downloadopensim-SC_OLD-972b0b52f9acedf13114fbed2ec35bb63adeea79.zip
opensim-SC_OLD-972b0b52f9acedf13114fbed2ec35bb63adeea79.tar.gz
opensim-SC_OLD-972b0b52f9acedf13114fbed2ec35bb63adeea79.tar.bz2
opensim-SC_OLD-972b0b52f9acedf13114fbed2ec35bb63adeea79.tar.xz
If rest of first line after colon is blank then still warn about running in XEngine if engine specified does not exist.
This is to take account of situations where the user was intending to specify a script engine using colon using its default language. This probably generates few false positive as scripts are less likely to end a first line colon with a comment for other purposes.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/XEngine/XEngine.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs29
1 files changed, 18 insertions, 11 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index a709be3..35fac4e 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -780,27 +780,34 @@ namespace OpenSim.Region.ScriptEngine.XEngine
780 if (engine == ScriptEngineName) 780 if (engine == ScriptEngineName)
781 { 781 {
782 // If we are falling back on XEngine as the default engine, then only complain to the user 782 // If we are falling back on XEngine as the default engine, then only complain to the user
783 // if a script language has been explicitly set and it's one that we recognize. If it's 783 // if a script language has been explicitly set and it's one that we recognize or there are
784 // no non-whitespace characters after the colon.
785 //
786 // If the script is
784 // explicitly not allowed or the script is not in LSL then the user will be informed by a later compiler message. 787 // explicitly not allowed or the script is not in LSL then the user will be informed by a later compiler message.
785 // 788 //
789 // If the colon ends the line then we'll risk the false positive as this is more likely
790 // to signal a real scriptengine line where the user wants to use the default compile language.
791 //
786 // This avoids the overwhelming number of false positives where we're in this code because 792 // This avoids the overwhelming number of false positives where we're in this code because
787 // there's a colon in a comment in the first line of a script for entirely 793 // there's a colon in a comment in the first line of a script for entirely
788 // unrelated reasons (e.g. vim settings). 794 // unrelated reasons (e.g. vim settings).
789 // 795 //
790 // TODO: A better fix would be to deprecate simple : detection and look for some less likely 796 // TODO: A better fix would be to deprecate simple : detection and look for some less likely
791 // string to begin the comment (like #! in unix shell scripts). 797 // string to begin the comment (like #! in unix shell scripts).
792 bool scriptExplicitlyInXEngineLanguage = false; 798 bool warnRunningInXEngine = false;
793 string restOfScript = script.Substring(colon + 1); 799 string restOfFirstLine = firstline.Substring(colon + 1);
794 800
795 // FIXME: These are hardcoded because they are currently hardcoded in Compiler.cs 801 // FIXME: These are hardcoded because they are currently hardcoded in Compiler.cs
796 if (restOfScript.StartsWith("c#") 802 if (restOfFirstLine.StartsWith("c#")
797 || restOfScript.StartsWith("vb") 803 || restOfFirstLine.StartsWith("vb")
798 || restOfScript.StartsWith("lsl") 804 || restOfFirstLine.StartsWith("lsl")
799 || restOfScript.StartsWith("js") 805 || restOfFirstLine.StartsWith("js")
800 || restOfScript.StartsWith("yp")) 806 || restOfFirstLine.StartsWith("yp")
801 scriptExplicitlyInXEngineLanguage = true; 807 || restOfFirstLine.Length == 0)
802 808 warnRunningInXEngine = true;
803 if (scriptExplicitlyInXEngineLanguage) 809
810 if (warnRunningInXEngine)
804 { 811 {
805 SceneObjectPart part = 812 SceneObjectPart part =
806 m_Scene.GetSceneObjectPart( 813 m_Scene.GetSceneObjectPart(