From 972b0b52f9acedf13114fbed2ec35bb63adeea79 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 28 Jun 2012 21:30:36 +0100 Subject: 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. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 29 ++++++++++++++++---------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region') 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 if (engine == ScriptEngineName) { // If we are falling back on XEngine as the default engine, then only complain to the user - // if a script language has been explicitly set and it's one that we recognize. If it's + // if a script language has been explicitly set and it's one that we recognize or there are + // no non-whitespace characters after the colon. + // + // If the script is // explicitly not allowed or the script is not in LSL then the user will be informed by a later compiler message. // + // If the colon ends the line then we'll risk the false positive as this is more likely + // to signal a real scriptengine line where the user wants to use the default compile language. + // // This avoids the overwhelming number of false positives where we're in this code because // there's a colon in a comment in the first line of a script for entirely // unrelated reasons (e.g. vim settings). // // TODO: A better fix would be to deprecate simple : detection and look for some less likely // string to begin the comment (like #! in unix shell scripts). - bool scriptExplicitlyInXEngineLanguage = false; - string restOfScript = script.Substring(colon + 1); + bool warnRunningInXEngine = false; + string restOfFirstLine = firstline.Substring(colon + 1); // FIXME: These are hardcoded because they are currently hardcoded in Compiler.cs - if (restOfScript.StartsWith("c#") - || restOfScript.StartsWith("vb") - || restOfScript.StartsWith("lsl") - || restOfScript.StartsWith("js") - || restOfScript.StartsWith("yp")) - scriptExplicitlyInXEngineLanguage = true; - - if (scriptExplicitlyInXEngineLanguage) + if (restOfFirstLine.StartsWith("c#") + || restOfFirstLine.StartsWith("vb") + || restOfFirstLine.StartsWith("lsl") + || restOfFirstLine.StartsWith("js") + || restOfFirstLine.StartsWith("yp") + || restOfFirstLine.Length == 0) + warnRunningInXEngine = true; + + if (warnRunningInXEngine) { SceneObjectPart part = m_Scene.GetSceneObjectPart( -- cgit v1.1