ide: tweak compiler config support for specifying output file extensions.
[sdk] / ide / src / IDESettings.ec
index 05325dd..53191c2 100644 (file)
@@ -11,6 +11,18 @@ public import static "ecere"
 public import "ecere"
 #endif
 
+define ecpDefaultCommand = "ecp";
+define eccDefaultCommand = "ecc";
+define ecsDefaultCommand = "ecs";
+define earDefaultCommand = "ear";
+define cppDefaultCommand = "gcc"; // As per #624 we decided to default to "gcc"...
+define ccDefaultCommand = "gcc";
+define cxxDefaultCommand = "g++";
+//define ldDefaultCommand = "gcc";
+define arDefaultCommand = "ar";
+define objectDefaultFileExt = "o";
+define outputDefaultFileExt = "";
+
 import "StringsBox"
 
 import "OldIDESettings"
@@ -23,7 +35,7 @@ define defaultCompilerName = "Default";
 
 define defaultObjDirExpression = "obj/$(CONFIG).$(PLATFORM)$(COMPILER_SUFFIX)$(DEBUG_SUFFIX)";
 
-char * settingsDirectoryNames[DirTypes] =
+const char * settingsDirectoryNames[DirTypes] =
 {
    "Include Files",
    "Library Files",
@@ -32,7 +44,7 @@ char * settingsDirectoryNames[DirTypes] =
 
 // This function cannot accept same pointer for source and output
 // todo: rename ReplaceSpaces to EscapeSpaceAndSpecialChars or something
-void ReplaceSpaces(char * output, char * source)
+void ReplaceSpaces(char * output, const char * source)
 {
    int c, dc;
    char ch, pch = 0;
@@ -58,7 +70,7 @@ void ReplaceSpaces(char * output, char * source)
 enum GlobalSettingsChange { none, editorSettings, projectOptions, compilerSettings };
 
 enum PathRelationship { unrelated, identical, siblings, subPath, parentPath, insuficientInput, pathEmpty, toEmpty, pathNull, toNull, bothEmpty, bothNull };
-PathRelationship eString_PathRelated(char * path, char * to, char * pathDiff)
+PathRelationship eString_PathRelated(const char * path, const char * to, char * pathDiff)
 {
    PathRelationship result;
    if(pathDiff) *pathDiff = '\0';
@@ -99,7 +111,7 @@ PathRelationship eString_PathRelated(char * path, char * to, char * pathDiff)
    return result;
 }
 
-char * CopyValidateMakefilePath(char * path)
+char * CopyValidateMakefilePath(const char * path)
 {
    const int map[]  =    {           0,           1,             2,             3,           4,                    5,                 6,            0,                   1,                    2,        7 };
    const char * vars[] = { "$(MODULE)", "$(CONFIG)", "$(PLATFORM)", "$(COMPILER)", "$(TARGET)", "$(COMPILER_SUFFIX)", "$(DEBUG_SUFFIX)", "$(PROJECT)",  "$(CONFIGURATION)", "$(TARGET_PLATFORM)",(char *)0 };
@@ -115,7 +127,7 @@ char * CopyValidateMakefilePath(char * path)
          int c;
          char * tmp = copy;
          char * start = tmp;
-         Array<char *> parts { };
+         Array<const char *> parts { };
 
          for(c=0; c<len; c++)
          {
@@ -157,7 +169,7 @@ char * CopyValidateMakefilePath(char * path)
    return copy;
 }
 
-void ValidPathBufCopy(char *output, char *input)
+void ValidPathBufCopy(char *output, const char *input)
 {
 #ifdef __WIN32__
    bool volumePath = false;
@@ -174,7 +186,7 @@ void ValidPathBufCopy(char *output, char *input)
    }
 #endif
    {
-      char * chars = "*|:\",<>?";
+      const char * chars = "*|:\",<>?";
       char ch, * s = output, * o = output;
       while((ch = *s++)) { if(!strchr(chars, ch)) *o++ = ch; }
       *o = '\0';
@@ -201,14 +213,14 @@ void BasicValidatePathBoxPath(PathBox pathBox)
    pathBox.path = path;
 }
 
-CompilerConfig MakeDefaultCompiler(char * name, bool readOnly)
+CompilerConfig MakeDefaultCompiler(const char * name, bool readOnly)
 {
    CompilerConfig defaultCompiler
    {
       name,
       readOnly,
       gcc,
-      GetRuntimePlatform(),
+      __runtimePlatform,
       1,
       makeDefaultCommand,
       ecpDefaultCommand,
@@ -217,20 +229,24 @@ CompilerConfig MakeDefaultCompiler(char * name, bool readOnly)
       earDefaultCommand,
       cppDefaultCommand,
       ccDefaultCommand,
-      cxxDefaultCommand
+      cxxDefaultCommand,
+      arDefaultCommand
+      //ldDefaultCommand
    };
    incref defaultCompiler;
    return defaultCompiler;
 }
 
-class IDESettingsContainer : GlobalSettings
-{
 #ifdef SETTINGS_TEST
-   settingsName = "ecereIDESettingsTest";
+define settingsName = "ecereIDE-SettingsTest";
 #else
-   settingsName = "ecereIDE";
+define ideSettingsName = "ecereIDE";
 #endif
 
+class IDESettingsContainer : GlobalSettings
+{
+   settingsName = ideSettingsName;
+
    virtual void OnLoad(GlobalSettingsData data);
 
    char moduleLocation[MAX_LOCATION];
@@ -256,12 +272,14 @@ private:
 
          strcpy(configFilePath, path);
          PathCat(configFilePath, "Data");
-         PathCat(configFilePath, "ecereIDE.ini");
+         PathCat(configFilePath, ideSettingsName);
+         ChangeExtension(configFilePath, "ini", configFilePath);
 
          strcpy(defaultConfigFilePath, path);
          PathCat(defaultConfigFilePath, "App");
          PathCat(defaultConfigFilePath, "DefaultData");
-         PathCat(defaultConfigFilePath, "ecereIDE.ini");
+         PathCat(defaultConfigFilePath, ideSettingsName);
+         ChangeExtension(defaultConfigFilePath, "ini", defaultConfigFilePath);
 
          if(FileExists(defaultConfigFilePath))
          {
@@ -286,30 +304,26 @@ private:
 
    void OnAskReloadSettings()
    {
-      /*if(MessageBox { type = YesNo, master = this,
-            text = "Global Settings Modified Externally",
-            contents = "The global settings were modified by another instance.\n"
-            "Would you like to reload them?" }.Modal() == Yes)*/
+      FileSize newSettingsFileSize;
+
+      if(OpenAndLock(&newSettingsFileSize))
       {
-         double o, n;
-         FileSize newSettingsFileSize;
-         FileGetSize(settingsFilePath, &newSettingsFileSize);
-         o = settingsFileSize;
-         n = newSettingsFileSize;
-         if(o - n < 2048)
+         if((double)settingsFileSize - (double)newSettingsFileSize < 2048)
             Load();
          else
          {
             GuiApplication app = ((GuiApplication)__thisModule.application);
             Window w;
             for(w = app.desktop.firstChild; w && (!w.created || !w.visible); w = w.next);
-            MessageBox { master = w, type = ok,
+
+            CloseAndMonitor();
+
+            MessageBox { master = w, type = ok, isModal = true,
                   text = "Global Settings Modified Externally",
                   contents = "The global settings were modified by another process and a drastic shrinking of the settings file was detected.\n"
                   "The new settings will not be loaded to prevent loss of your ide settings.\n"
                   "Please check your settings file and make sure to save this IDE's global settings if your settings file has been compromised."
                   }.Create();
-            //Save();
          }
       }
    }
@@ -380,13 +394,35 @@ private:
       FileGetSize(settingsFilePath, &settingsFileSize);
       if(data.compilerConfigs)
       {
-         for(c : data.compilerConfigs)
+         for(ccfg : data.compilerConfigs)
          {
-            CompilerConfig compiler = c;
-            char * cxxCommand = compiler.cxxCommand;
-            if(!cxxCommand || !cxxCommand[0])
-               compiler.cxxCommand = cxxDefaultCommand;
-            incref compiler;
+            if(!ccfg.ecpCommand || !ccfg.ecpCommand[0])
+               ccfg.ecpCommand = ecpDefaultCommand;
+            if(!ccfg.eccCommand || !ccfg.eccCommand[0])
+               ccfg.eccCommand = eccDefaultCommand;
+            if(!ccfg.ecsCommand || !ccfg.ecsCommand[0])
+               ccfg.ecsCommand = ecsDefaultCommand;
+            if(!ccfg.earCommand || !ccfg.earCommand[0])
+               ccfg.earCommand = earDefaultCommand;
+            if(!ccfg.cppCommand || !ccfg.cppCommand[0])
+               ccfg.cppCommand = cppDefaultCommand;
+            if(!ccfg.ccCommand || !ccfg.ccCommand[0])
+               ccfg.ccCommand = ccDefaultCommand;
+            if(!ccfg.cxxCommand || !ccfg.cxxCommand[0])
+               ccfg.cxxCommand = cxxDefaultCommand;
+            /*if(!ccfg.ldCommand || !ccfg.ldCommand[0])
+               ccfg.ldCommand = ldDefaultCommand;*/
+            if(!ccfg.arCommand || !ccfg.arCommand[0])
+               ccfg.arCommand = arDefaultCommand;
+            if(!ccfg.objectFileExt || !ccfg.objectFileExt[0])
+               ccfg.objectFileExt = objectDefaultFileExt;
+            /*if(!ccfg.staticLibFileExt || !ccfg.staticLibFileExt[0])
+               ccfg.staticLibFileExt = staticLibDefaultFileExt;*/
+            /*if(!ccfg.sharedLibFileExt || !ccfg.sharedLibFileExt[0])
+               ccfg.sharedLibFileExt = sharedLibDefaultFileExt;*/
+            /*if(!ccfg.executableFileExt || !ccfg.executableFileExt[0])
+               ccfg.executableFileExt = outputDefaultFileExt;*/
+            incref ccfg;
          }
       }
       if(portable && moduleLocation[0] && FileExists(moduleLocation).isDirectory)
@@ -401,7 +437,6 @@ private:
       SettingsIOResult result;
 
       IDESettings data = (IDESettings)this.data;
-      Platform runtimePlatform = GetRuntimePlatform();
       if(portable && moduleLocation[0] && FileExists(moduleLocation).isDirectory)
          data.ManagePortablePaths(moduleLocation, false);
       data.ForcePathSeparatorStyle(true);
@@ -422,19 +457,19 @@ public:
    List<CompilerConfig> compilerConfigs { };
    Array<String> recentFiles { };
    Array<String> recentProjects { };
-   property char * docDir
+   property const char * docDir
    {
       set { delete docDir; if(value && value[0]) docDir = CopyString(value); }
       get { return docDir ? docDir : ""; }
       isset { return docDir && docDir[0]; }
    }
-   property char * ideFileDialogLocation
+   property const char * ideFileDialogLocation
    {
       set { delete ideFileDialogLocation; if(value && value[0]) ideFileDialogLocation = CopyString(value); }
       get { return ideFileDialogLocation ? ideFileDialogLocation : ""; }
       isset { return ideFileDialogLocation && ideFileDialogLocation[0]; }
    }
-   property char * ideProjectFileDialogLocation
+   property const char * ideProjectFileDialogLocation
    {
       set { delete ideProjectFileDialogLocation; if(value && value[0]) ideProjectFileDialogLocation = CopyString(value); }
       get { return ideProjectFileDialogLocation ? ideProjectFileDialogLocation : ""; }
@@ -448,34 +483,34 @@ public:
    // TODO: Classify settings
    //EditorSettings editor { };
 
-   property char * projectDefaultTargetDir
+   property const char * projectDefaultTargetDir
    {
       set { delete projectDefaultTargetDir; if(value && value[0]) projectDefaultTargetDir = CopyValidateMakefilePath(value); }
       get { return projectDefaultTargetDir ? projectDefaultTargetDir : ""; }
       isset { return projectDefaultTargetDir && projectDefaultTargetDir[0]; }
    }
-   property char * projectDefaultIntermediateObjDir
+   property const char * projectDefaultIntermediateObjDir
    {
       set { delete projectDefaultIntermediateObjDir; if(value && value[0]) projectDefaultIntermediateObjDir = CopyValidateMakefilePath(value); }
       get { return projectDefaultIntermediateObjDir ? projectDefaultIntermediateObjDir : ""; }
       isset { return projectDefaultIntermediateObjDir && projectDefaultIntermediateObjDir[0]; }
    }
 
-   property char * compilerConfigsDir
+   property const char * compilerConfigsDir
    {
       set { delete compilerConfigsDir; if(value && value[0]) compilerConfigsDir = CopyString(value); }
       get { return compilerConfigsDir ? compilerConfigsDir : ""; }
       isset { return compilerConfigsDir && compilerConfigsDir[0]; }
    }
 
-   property char * defaultCompiler
+   property const char * defaultCompiler
    {
       set { delete defaultCompiler; if(value && value[0]) defaultCompiler = CopyString(value); }
       get { return defaultCompiler && defaultCompiler[0] ? defaultCompiler : defaultCompilerName; }
       isset { return defaultCompiler && defaultCompiler[0]; }
    }
 
-   property String language
+   property const String language
    {
       set
       {
@@ -486,6 +521,21 @@ public:
       isset { return language != null; }
    }
 
+   property Array<NamedString> findInFileFileFilters
+   {
+      set
+      {
+         findInFileFileFilters.Free();
+         if(value)
+         {
+            delete findInFileFileFilters;
+            findInFileFileFilters = value;
+         }
+      }
+      get { return findInFileFileFilters; }
+      isset { return findInFileFileFilters.count != 0; }
+   }
+
 private:
    char * docDir;
    char * ideFileDialogLocation;
@@ -495,10 +545,11 @@ private:
    char * compilerConfigsDir;
    char * defaultCompiler;
    String language;
+   Array<NamedString> findInFileFileFilters { };
 
-   CompilerConfig GetCompilerConfig(String compilerName)
+   CompilerConfig GetCompilerConfig(const String compilerName)
    {
-      char * name = compilerName && compilerName[0] ? compilerName : defaultCompilerName;
+      const char * name = compilerName && compilerName[0] ? compilerName : defaultCompilerName;
       CompilerConfig compilerConfig = null;
       for(compiler : compilerConfigs)
       {
@@ -529,10 +580,13 @@ private:
       delete projectDefaultIntermediateObjDir;
       delete compilerConfigsDir;
       delete defaultCompiler;
+      delete language;
 
       delete ideFileDialogLocation;
       delete ideProjectFileDialogLocation;
       delete displayDriver;
+
+      if(findInFileFileFilters) findInFileFileFilters.Free();
    }
 
    void ForcePathSeparatorStyle(bool unixStyle)
@@ -664,7 +718,7 @@ private:
          compilerConfigsDir = UpdatePortablePath(compilerConfigsDir, location, makeAbsolute);
    }
 
-   char * UpdatePortablePath(char * path, char * location, bool makeAbsolute)
+   char * UpdatePortablePath(char * path, const char * location, bool makeAbsolute)
    {
       char * output;
       if(makeAbsolute)
@@ -693,7 +747,7 @@ private:
       return output;
    }
 
-   void AddRecentFile(char * fileName)
+   void AddRecentFile(const char * fileName)
    {
       int c;
       char * filePath = CopyString(fileName);
@@ -712,7 +766,7 @@ private:
       //UpdateRecentMenus(owner);
    }
 
-   void AddRecentProject(char * projectName)
+   void AddRecentProject(const char * projectName)
    {
       int c;
       char * filePath = CopyString(projectName);
@@ -738,7 +792,7 @@ static const char * compilerTypeSolutionFileVersionString[CompilerType] = { "",
 static const char * compilerTypeYearString[CompilerType] = { "", "", "", "2005", "2008", "2010" };
 static const char * compilerTypeProjectFileExtension[CompilerType] = { "", "", "", "vcproj", "vcproj", "vcxproj" };
 // TODO: i18n with Array
-static Array<String> compilerTypeLongNames
+static Array<const String> compilerTypeLongNames
 { [
    $"GNU Compiler Collection (GCC) / GNU Make",
    $"Tiny C Compiler / GNU Make",
@@ -758,14 +812,14 @@ public enum CompilerType
       get { return this == vs8 || this == vs9 || this == vs10; }
    }
 
-   property char *
+   property const char *
    {
       get { return OnGetString(null, null, null); }
       set
       {
          if(value)
          {
-            Platform c;
+            CompilerType c;
             for(c = firstCompilerType; c <= lastCompilerType; c++)
                if(!strcmpi(value, compilerTypeNames[c]))
                   return c;
@@ -774,13 +828,13 @@ public enum CompilerType
       }
    };
 
-   property char * longName { get { return OnGetString(null, (void*)1, null); } };
-   property char * versionString { get { return OnGetString(null, (void*)2, null); } };
-   property char * yearString { get { return OnGetString(null, (void*)3, null); } };
-   property char * projectFileExtension { get { return OnGetString(null, (void*)4, null); } };
-   property char * solutionFileVersionString { get { return OnGetString(null, (void*)5, null); } };
+   property const char * longName { get { return OnGetString(null, (void*)1, null); } };
+   property const char * versionString { get { return OnGetString(null, (void*)2, null); } };
+   property const char * yearString { get { return OnGetString(null, (void*)3, null); } };
+   property const char * projectFileExtension { get { return OnGetString(null, (void*)4, null); } };
+   property const char * solutionFileVersionString { get { return OnGetString(null, (void*)5, null); } };
 
-   char * OnGetString(char * tempString, void * fieldData, bool * needClass)
+   const char * OnGetString(char * tempString, void * fieldData, bool * needClass)
    {
       if(this >= firstCompilerType && this <= lastCompilerType)
       {
@@ -809,7 +863,7 @@ class CompilerConfig
 
    numJobs = 1;
 public:
-   property char * name
+   property const char * name
    {
       set
       {
@@ -823,55 +877,92 @@ public:
    CompilerType type;
    Platform targetPlatform;
    int numJobs;
-   property char * makeCommand
+   property const char * makeCommand
    {
       set { delete makeCommand; if(value && value[0]) makeCommand = CopyString(value); }
       get { return makeCommand; }
       isset { return makeCommand && makeCommand[0]; }
    }
-   property char * ecpCommand
+   property const char * ecpCommand
    {
       set { delete ecpCommand; if(value && value[0]) ecpCommand = CopyString(value); }
       get { return ecpCommand; }
       isset { return ecpCommand && ecpCommand[0]; }
    }
-   property char * eccCommand
+   property const char * eccCommand
    {
       set { delete eccCommand; if(value && value[0]) eccCommand = CopyString(value); }
       get { return eccCommand; }
       isset { return eccCommand && eccCommand[0]; }
    }
-   property char * ecsCommand
+   property const char * ecsCommand
    {
       set { delete ecsCommand; if(value && value[0]) ecsCommand = CopyString(value); }
       get { return ecsCommand; }
       isset { return ecsCommand && ecsCommand[0]; }
    }
-   property char * earCommand
+   property const char * earCommand
    {
       set { delete earCommand; if(value && value[0]) earCommand = CopyString(value); }
       get { return earCommand; }
       isset { return earCommand && earCommand[0]; }
    }
-   property char * cppCommand
+   property const char * cppCommand
    {
       set { delete cppCommand; if(value && value[0]) cppCommand = CopyString(value); }
       get { return cppCommand; }
       isset { return cppCommand && cppCommand[0]; }
    }
-   property char * ccCommand
+   property const char * ccCommand
    {
       set { delete ccCommand; if(value && value[0]) ccCommand = CopyString(value); }
       get { return ccCommand; }
       isset { return ccCommand && ccCommand[0]; }
    }
-   property char * cxxCommand
+   property const char * cxxCommand
    {
       set { delete cxxCommand; if(value && value[0]) cxxCommand = CopyString(value); }
       get { return cxxCommand; }
       isset { return cxxCommand && cxxCommand[0]; }
    }
-   property char * execPrefixCommand // <-- old name for json ide settings file compatibility
+   property const char * arCommand
+   {
+      set { delete arCommand; if(value && value[0]) arCommand = CopyString(value); }
+      get { return arCommand; }
+      isset { return arCommand && arCommand[0]; }
+   }
+   property const char * ldCommand
+   {
+      set { delete ldCommand; if(value && value[0]) ldCommand = CopyString(value); }
+      get { return ldCommand; }
+      isset { return ldCommand && ldCommand[0]; }
+   }
+   bool noStripTarget;
+   property const char * objectFileExt
+   {
+      set { delete objectFileExt; if(value && value[0]) objectFileExt = CopyString(value); }
+      get { return objectFileExt && objectFileExt[0] ? objectFileExt : objectDefaultFileExt ; }
+      isset { return objectFileExt && objectFileExt[0] && strcmp(objectFileExt, objectDefaultFileExt); }
+   }
+   property const char * staticLibFileExt
+   {
+      set { delete staticLibFileExt; if(value && value[0]) staticLibFileExt = CopyString(value); }
+      get { return staticLibFileExt; }
+      isset { return staticLibFileExt && staticLibFileExt[0]; }
+   }
+   property const char * sharedLibFileExt
+   {
+      set { delete sharedLibFileExt; if(value && value[0]) sharedLibFileExt = CopyString(value); }
+      get { return sharedLibFileExt; }
+      isset { return sharedLibFileExt && sharedLibFileExt[0]; }
+   }
+   property const char * executableFileExt
+   {
+      set { delete executableFileExt; if(value && value[0]) executableFileExt = CopyString(value); }
+      get { return executableFileExt; }
+      isset { return executableFileExt && executableFileExt[0]; }
+   }
+   property const char * executableLauncher
    {
       set { delete executableLauncher; if(value && value[0]) executableLauncher = CopyString(value); }
       get { return executableLauncher; }
@@ -883,19 +974,19 @@ public:
    // deprecated
    property bool supportsBitDepth { set { } get { return true; } isset { return false; } }
 
-   property char * distccHosts
+   property const char * distccHosts
    {
       set { delete distccHosts; if(value && value[0]) distccHosts = CopyString(value); }
       get { return distccHosts; }
       isset { return distccHosts && distccHosts[0]; }
    }
-   property char * gccPrefix // <-- old name for json ide settings file compatibility
+   property const char * gnuToolchainPrefix
    {
       set { delete gnuToolchainPrefix; if(value && value[0]) gnuToolchainPrefix = CopyString(value); }
       get { return gnuToolchainPrefix; }
       isset { return gnuToolchainPrefix && gnuToolchainPrefix[0]; }
    }
-   property char * sysroot
+   property const char * sysroot
    {
       set { delete sysroot; if(value && value[0]) sysroot = CopyString(value); }
       get { return sysroot; }
@@ -1027,6 +1118,36 @@ public:
       get { return linkerFlags; }
       isset { return linkerFlags.count != 0; }
    }
+   // json backward compatibility
+   property const char * gccPrefix
+   {
+      set { delete gnuToolchainPrefix; if(value && value[0]) gnuToolchainPrefix = CopyString(value); }
+      get { return gnuToolchainPrefix; }
+      isset { return false; }
+   }
+   property const char * execPrefixCommand
+   {
+      set { delete executableLauncher; if(value && value[0]) executableLauncher = CopyString(value); }
+      get { return executableLauncher; }
+      isset { return false; }
+   }
+   property const char * outputFileExt
+   {
+      set { delete executableFileExt; if(value && value[0]) executableFileExt = CopyString(value); }
+      get { return executableFileExt; }
+      isset { return false; }
+   }
+   // utility
+   property bool hasDocumentOutput
+   {
+      get
+      {
+         bool result = executableFileExt && executableFileExt[0] &&
+               (!strcmpi(executableFileExt, "htm") || !strcmpi(executableFileExt, "html"));
+         return result;
+      }
+      isset { return false; }
+   }
 private:
    Array<String> includeDirs { };
    Array<String> libraryDirs { };
@@ -1048,6 +1169,12 @@ private:
    char * cppCommand;
    char * ccCommand;
    char * cxxCommand;
+   char * ldCommand;
+   char * arCommand;
+   char * objectFileExt;
+   char * staticLibFileExt;
+   char * sharedLibFileExt;
+   char * executableFileExt;
    char * executableLauncher;
    char * distccHosts;
    char * gnuToolchainPrefix;
@@ -1068,6 +1195,12 @@ private:
       delete cppCommand;
       delete ccCommand;
       delete cxxCommand;
+      delete ldCommand;
+      delete arCommand;
+      delete objectFileExt;
+      delete staticLibFileExt;
+      delete sharedLibFileExt;
+      delete executableFileExt;
       delete makeCommand;
       delete executableLauncher;
       delete distccHosts;
@@ -1083,6 +1216,8 @@ private:
       if(eCcompilerFlags) { eCcompilerFlags.Free(); }
       if(linkerFlags) { linkerFlags.Free(); }
    }
+
+public:
    CompilerConfig Copy()
    {
       CompilerConfig copy
@@ -1100,6 +1235,13 @@ private:
          cppCommand,
          ccCommand,
          cxxCommand,
+         arCommand,
+         ldCommand,
+         noStripTarget,
+         objectFileExt,
+         staticLibFileExt,
+         sharedLibFileExt,
+         executableFileExt,
          executableLauncher,
          ccacheEnabled,
          distccEnabled,
@@ -1125,12 +1267,12 @@ private:
 
 struct LanguageOption
 {
-   String name;
-   String bitmap;
-   String code;
+   const String name;
+   const String bitmap;
+   const String code;
    BitmapResource res;
 
-   char * OnGetString(char * tempString, void * fieldData, bool * needClass)
+   const char * OnGetString(char * tempString, void * fieldData, bool * needClass)
    {
       return name;
    }
@@ -1159,18 +1301,36 @@ Array<LanguageOption> languages
    { "Magyar (8%)",        ":countryCode/hu.png", "hu" }
 ] };
 
-String GetLanguageString()
+const String GetLanguageString()
 {
-   String language = getenv("ECERE_LANGUAGE");
+   char * dot, * colon;
+   static char lang[256];
+   const String language = getenv("ECERE_LANGUAGE");
    if(!language) language = getenv("LANGUAGE");
    if(!language) language = getenv("LC_ALL");
    if(!language) language = getenv("LC_MESSAGES");
    if(!language) language = getenv("LANG");
    if(!language) language = "";
+   if(language && (colon = strchr(language, ':')))
+   {
+      if(lang != language)
+         strncpy(lang, language, sizeof(lang));
+      lang[sizeof(lang)-1] = 0;
+      lang[colon - language] = 0;
+      language = lang;
+   }
+   if(language && (dot = strchr(language, '.')))
+   {
+      if(lang != language)
+         strncpy(lang, language, sizeof(lang));
+      lang[sizeof(lang)-1] = 0;
+      lang[dot - language] = 0;
+      language = lang;
+   }
    return language;
 }
 
-bool LanguageRestart(char * code, Application app, IDESettings settings, IDESettingsContainer settingsContainer, Window ide, Window projectView, bool wait)
+bool LanguageRestart(const char * code, Application app, IDESettings settings, IDESettingsContainer settingsContainer, Window ide, Window projectView, bool wait)
 {
    bool restart = true;
    String command = null;
@@ -1203,7 +1363,7 @@ bool LanguageRestart(char * code, Application app, IDESettings settings, IDESett
                restart = false;
             if(projectView.fileName)
             {
-               char * name = projectView.fileName;
+               const char * name = projectView.fileName;
                if(name)
                {
                   for(j = 0; (ch = name[j]); j++)
@@ -1243,7 +1403,7 @@ bool LanguageRestart(char * code, Application app, IDESettings settings, IDESett
                }
                if(w.fileName)
                {
-                  char * name = w.fileName;
+                  const char * name = w.fileName;
                   len++;
                   for(j = 0; (ch = name[j]); j++)
                      len += (ch == ' ' || ch == '\"' || ch == '&' || ch == '$' || ch == '(' || ch == ')') ? 2 : 1;
@@ -1261,7 +1421,7 @@ bool LanguageRestart(char * code, Application app, IDESettings settings, IDESett
             {
                if(w.isActiveClient && w.isDocument)
                {
-                  char * name = w.fileName;
+                  const char * name = w.fileName;
                   if(name)
                   {
                      strcat(command, " ");
@@ -1289,10 +1449,10 @@ bool LanguageRestart(char * code, Application app, IDESettings settings, IDESett
          {
             HKEY key = null;
             uint16 wLanguage[256];
-            HRESULT status;
+            DWORD status;
             wLanguage[0] = 0;
 
-            RegCreateKeyEx(HKEY_CURRENT_USER, "Environment", 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, null, &key, &status);
+            RegCreateKeyEx(HKEY_CURRENT_USER, "Environment", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, null, &key, &status);
             if(key)
             {
                UTF8toUTF16Buffer(code, wLanguage, sizeof(wLanguage) / sizeof(uint16));
@@ -1314,7 +1474,7 @@ bool LanguageRestart(char * code, Application app, IDESettings settings, IDESett
       int i;
       for(i = 1; i < app.argc; i++)
       {
-         char * arg = app.argv[i];
+         const char * arg = app.argv[i];
          len++;
          for(j = 0; (ch = arg[j]); j++)
             len += (ch == ' ' || ch == '\"' || ch == '&' || ch == '$' || ch == '(' || ch == ')') ? 2 : 1;