cleaned all trailing white space from source files.
[sdk] / ide / src / project / ProjectNode.ec
index c12bb27..cee70a6 100644 (file)
@@ -35,7 +35,7 @@ bool eString_PathInsideOfMore(char * path, char * of, char * pathRest)
       strcpy(pathRest, path);
       for(; ofRest[0] && pathRest[0];)
       {
-         SplitDirectory(ofRest, ofPart, ofRest);      
+         SplitDirectory(ofRest, ofPart, ofRest);
          SplitDirectory(pathRest, pathPart, pathRest);
          if(fstrcmp(pathPart, ofPart))
             return false;
@@ -177,6 +177,57 @@ class TwoStrings : struct
    }
 }
 
+class DotMain : bool
+{
+   //property char * { set { } }
+   DotMain ::FromFileName(char * fileName)
+   {
+      DotMain dotMain = false;
+      if(fileName && fileName[0])
+      {
+         char ext[MAX_EXTENSION];
+         GetExtension(fileName, ext);
+         if(!strcmp(ext, "c") || !strcmp(ext, "ec"))
+         {
+            char stripExt[MAX_LOCATION];
+            strcpy(stripExt, fileName);
+            StripExtension(stripExt);
+            GetExtension(stripExt, ext);
+            if(!strcmp(ext, "main"))
+               dotMain = true;
+         }
+      }
+      return dotMain;
+   }
+}
+
+enum IntermediateFileType
+{
+   none, ec, c, sym, imp, bowl, o;
+
+   //property char * { set { } }
+   IntermediateFileType ::FromExtension(char * extension)
+   {
+      IntermediateFileType type = none;
+      if(extension && extension[0])
+      {
+         if(!fstrcmp(extension, "ec"))
+            type = ec;
+         else if(!fstrcmp(extension, "c"))
+            type = c;
+         else if(!fstrcmp(extension, "sym"))
+            type = sym;
+         else if(!fstrcmp(extension, "imp"))
+            type = imp;
+         else if(!fstrcmp(extension, "bowl"))
+            type = bowl;
+         else if(!fstrcmp(extension, "o"))
+            type = o;
+      }
+      return type;
+   }
+};
+
 class ProjectNode : ListItem
 {
 public:
@@ -385,14 +436,14 @@ private:
    // For folders, it includes the folder it refers to. If there is a name difference between the
    // file system folder and the grouping folder of the project view, it maps to that folder.
    char * path;
-   
+
    NodeTypes type;
    NodeIcons icon;
    int indent;
    DataRow row;
 
    bool modified;
-   
+
    // This is only set for Top Nodes
    Project project;
 
@@ -478,6 +529,52 @@ private:
       return buffer;
    }
 
+   char * GetObjectFileName(char * buffer, Map<String, NameCollisionInfo> namesInfo, IntermediateFileType type, bool dotMain)
+   {
+      if(buffer && (this.type == file || (this.type == project && dotMain == true)))
+      {
+         bool collision;
+         char extension[MAX_EXTENSION];
+         char moduleName[MAX_FILENAME];
+         NameCollisionInfo info;
+
+         GetExtension(name, extension);
+         ReplaceSpaces(moduleName, name);
+         StripExtension(moduleName);
+         info = namesInfo[moduleName];
+         collision = info ? info.IsExtensionColliding(extension) : false;
+
+         if(dotMain)
+         {
+            Project prj = property::project;
+            ReplaceSpaces(buffer, prj.moduleName);
+            StripExtension(buffer);
+            strcat(buffer, ".main.ec");
+         }
+         else
+            strcpy(buffer, name);
+         if(!strcmp(extension, "ec") || dotMain)
+         {
+            if(type == c)
+               ChangeExtension(buffer, "c", buffer);
+            else if(type == sym)
+               ChangeExtension(buffer, "sym", buffer);
+            else if(type == imp)
+               ChangeExtension(buffer, "imp", buffer);
+            else if(type == bowl)
+               ChangeExtension(buffer, "bowl", buffer);
+         }
+         if(type == o)
+         {
+            if(collision)
+               strcat(buffer, ".o");
+            else
+               ChangeExtension(buffer, "o", buffer);
+         }
+      }
+      return buffer;
+   }
+
    char * GetFileSysMatchingPath(char * buffer)
    {
       if(buffer)
@@ -547,7 +644,7 @@ private:
          while(n && n.type != project) n = n.parent;
          return n ? (*&n.project) : null;
       }
-   }   
+   }
 
    void RenameConfig(char * oldName, char * newName)
    {
@@ -578,7 +675,7 @@ private:
          {
             ProjectConfig config = c.data;
             if(!strcmp(configToDelete.name, config.name))
-            {               
+            {
                c.Remove();
                delete config;
                break;
@@ -845,7 +942,7 @@ private:
          result.b = exp;
       }
       delete exclusionInfo;
-      
+
       return result;
    }
 
@@ -893,7 +990,7 @@ private:
 
       if(options && options.excludeFromBuild)
          output[unknown] = options.excludeFromBuild;
-      
+
       if(config && config.options && config.options.excludeFromBuild)
          output[unknown] = config.options.excludeFromBuild;
 
@@ -982,6 +1079,17 @@ private:
 
    ProjectNode FindByFullPath(char * path, bool includeResources)
    {
+      if(files)
+      {
+         char name[MAX_FILENAME];
+         GetLastDirectory(path, name);
+         return InternalFindByFullPath(path, includeResources, name);
+      }
+      return null;
+   }
+
+   ProjectNode InternalFindByFullPath(char * path, bool includeResources, char * lastDirName)
+   {
       ProjectNode result = null;
       if(files)
       {
@@ -989,17 +1097,18 @@ private:
          {
             if(includeResources || child.type != resources)
             {
-               if(child.type != folder && child.name)
+               if(child.type != file)
+                  result = child.InternalFindByFullPath(path, includeResources, lastDirName);
+               else if(child.name && !fstrcmp(lastDirName, child.name))
                {
                   char p[MAX_LOCATION];
                   child.GetFullFilePath(p);
-                  if(!strcmpi(p, path))
+                  if(!fstrcmp(p, path))
                   {
                      result = child;
                      break;
                   }
                }
-               result = child.FindByFullPath(path, includeResources);
                if(result)
                   break;
             }
@@ -1008,6 +1117,36 @@ private:
       return result;
    }
 
+   ProjectNode FindByObjectFileName(char * fileName, IntermediateFileType type, bool dotMain, Map<String, NameCollisionInfo> namesInfo)
+   {
+      char p[MAX_LOCATION];
+      ProjectNode result = null;
+      if(dotMain == true && this.type == project)
+      {
+         GetObjectFileName(p, namesInfo, type, dotMain);
+         if(!fstrcmp(p, fileName))
+            result = this;
+      }
+      else if(files)
+      {
+         for(child : files; child.type != resources)
+         {
+            if(child.type != file && (result = child.FindByObjectFileName(fileName, type, dotMain, namesInfo)))
+               break;
+            else if(child.type == file && child.name)
+            {
+               child.GetObjectFileName(p, namesInfo, type, dotMain);
+               if(!fstrcmp(p, fileName))
+               {
+                  result = child;
+                  break;
+               }
+            }
+         }
+      }
+      return result;
+   }
+
    ProjectNode FindSpecial(char * name, bool recursive, bool includeResources, bool includeFolders)
    {
       ProjectNode result = null;
@@ -1093,51 +1232,54 @@ private:
    ProjectNode Add(Project project, char * filePath, ProjectNode after, NodeTypes type, NodeIcons icon, bool checkIfExists)
    {
       ProjectNode node = null;
-      char temp[MAX_LOCATION];
-      Map<Platform, SetBool> exclusionInfo { };
-
-      GetLastDirectory(filePath, temp);
-      //if(!checkIfExists || !project.topNode.Find(temp, false))
-      
-      // TOCHECK: Shouldn't this apply either for all configs or none?
-      CollectExclusionInfo(exclusionInfo, project.config);
-      if(!checkIfExists || !project.topNode.FindSameNameConflict(temp, false, exclusionInfo, project.config))
+      if(!project.topNode.FindByFullPath(filePath, true))
       {
-         // Do the check for folder in the same parent or resource files only here
-         if(type == folder || !checkIfExists)
+         char temp[MAX_LOCATION];
+         Map<Platform, SetBool> exclusionInfo { };
+
+         GetLastDirectory(filePath, temp);
+         //if(!checkIfExists || !project.topNode.Find(temp, false))
+
+         // TOCHECK: Shouldn't this apply either for all configs or none?
+         CollectExclusionInfo(exclusionInfo, project.config);
+         if(!checkIfExists || type == folder || !project.topNode.FindSameNameConflict(temp, false, exclusionInfo, project.config))
          {
-            for(node : files)
+            // Do the check for folder in the same parent or resource files only here
+            if(type == folder || !checkIfExists)
             {
-               if(node.name && !strcmpi(node.name, temp))
-                  return null;
+               for(node : files)
+               {
+                  if(node.name && !strcmpi(node.name, temp))
+                     return null;
+               }
             }
-         }
 
-         node = ProjectNode { parent = this, indent = indent + 1, type = type, icon = icon, name = CopyString(temp) };
-         if(type != file)
-         {
-            node.files = { }; 
-            node.nodeType = folder;
-         }
-         if(type != folder)
-         {
-            if(filePath)
+            node = ProjectNode { parent = this, indent = indent + 1, type = type, icon = icon, name = CopyString(temp) };
+            if(type != file)
             {
-               StripLastDirectory(filePath, temp);
-               MakePathRelative(temp, project.topNode.path, temp);
-               node.path = CopyUnixPath(temp);
+               node.files = { };
+               node.nodeType = folder;
             }
-            node.nodeType = file;
-         }
-         else
-         {
-            strcpy(temp, (type == NodeTypes::project) ? "" : path);
-            PathCatSlash(temp, node.name);
-            node.path = CopyString(temp);
+            if(type != folder)
+            {
+               if(filePath)
+               {
+                  StripLastDirectory(filePath, temp);
+                  MakePathRelative(temp, project.topNode.path, temp);
+                  node.path = CopyUnixPath(temp);
+               }
+               node.nodeType = file;
+            }
+            else
+            {
+               strcpy(temp, (type == NodeTypes::project) ? "" : path);
+               PathCatSlash(temp, node.name);
+               node.path = CopyString(temp);
+            }
+            files.Insert(after, node);
          }
-         files.Insert(after, node);
+         delete exclusionInfo;
       }
-      delete exclusionInfo;
       return node;
    }
 
@@ -1156,8 +1298,8 @@ private:
       {
          showConfig = false;
          projectView = ide.projectView;
-      }         
-      
+      }
+
       bmp = projectView.icons[icon].bitmap;
       xStart = /*indent * indent + */x + (bmp ? (bmp.width + 5) : 0);
 
@@ -1200,7 +1342,7 @@ private:
          }
       }
       len = strlen(label);
-      
+
       if(!bmp)
       {
          if(type == folder || type == folderOpen)
@@ -1211,15 +1353,15 @@ private:
       surface.TextOpacity(false);
       surface.TextExtent(label, len, &w, &h);
       h = Max(h, 16);
-    
+
       // Draw the current row stipple
       if(displayFlags.selected)
          //surface.Area(xStart - 1, y, xStart - 1, y + h - 1);
          //surface.Area(xStart + w - 1, y, xStart + w + 1, y + h - 1);
          surface.Area(xStart - 3, y, xStart + w + 1, y + h - 1);
-      
+
       surface.WriteTextDots(alignment, xStart, y + 2, width, label, len);
-      
+
       if(!app.textMode)
       {
          if(displayFlags.current)
@@ -1329,7 +1471,7 @@ private:
          }
       }
    }
-   
+
    int GenMakefilePrintNode(File f, Project project, GenMakefilePrintTypes printType,
       Map<String, NameCollisionInfo> namesInfo, Array<String> items,
       ProjectConfig prjConfig, bool * containsCXX)
@@ -1360,7 +1502,7 @@ private:
                strcpy(tempPath, path);
                PathCatSlash(tempPath, name);
             }
-            ReplaceSpaces(modulePath, tempPath);
+            EscapeForMake(modulePath, tempPath, false, true, false);
             sprintf(s, "%s%s%s%s", ts.a, useRes ? "$(RES)" : "", modulePath, ts.b);
             items.Add(CopyString(s));
          }
@@ -1371,8 +1513,8 @@ private:
                   !strcmpi(extension, "m") || !strcmpi(extension, "mm"))
             {
                char modulePath[MAX_LOCATION];
-               ReplaceSpaces(modulePath, path);
-               ReplaceSpaces(moduleName, name);
+               EscapeForMake(modulePath, path, false, true, false);
+               EscapeForMake(moduleName, name, false, true, false);
                sprintf(s, "%s%s%s%s%s", ts.a, modulePath, path[0] ? SEPS : "", moduleName, ts.b);
                items.Add(CopyString(s));
             }
@@ -1382,8 +1524,8 @@ private:
             if(!strcmpi(extension, "ec"))
             {
                char modulePath[MAX_LOCATION];
-               ReplaceUnwantedMakeChars(modulePath, path);
-               ReplaceUnwantedMakeChars(moduleName, name);
+               EscapeForMake(modulePath, path, true, true, false);
+               EscapeForMake(moduleName, name, true, true, false);
                sprintf(s, "%s%s%s%s%s", ts.a, modulePath, path[0] ? SEPS : "", moduleName, ts.b);
                items.Add(CopyString(s));
                count++;
@@ -1394,8 +1536,8 @@ private:
             if(!strcmpi(extension, "rc"))
             {
                char modulePath[MAX_LOCATION];
-               ReplaceUnwantedMakeChars(modulePath, path);
-               ReplaceUnwantedMakeChars(moduleName, name);
+               EscapeForMake(modulePath, path, false, true, false);
+               EscapeForMake(moduleName, name, false, true, false);
                sprintf(s, "%s%s%s%s%s", ts.a, modulePath, path[0] ? SEPS : "", moduleName, ts.b);
                items.Add(CopyString(s));
                count++;
@@ -1410,7 +1552,7 @@ private:
                bool collision;
                NameCollisionInfo info;
                count++;
-               ReplaceSpaces(moduleName, name);
+               EscapeForMake(moduleName, name, false, true, false);
                StripExtension(moduleName);
                info = namesInfo[moduleName];
                collision = info ? info.IsExtensionColliding(extension) : false;
@@ -1501,7 +1643,7 @@ private:
             }
 
             // Execute it
-            if((dep = DualPipeOpen(PipeOpenMode { output = 1, error = 1, input = 2 }, command)))
+            if((dep = DualPipeOpen(PipeOpenMode { output = true, error = true/*, input = true*/ }, command)))
             {
                char line[1024];
                bool firstLine = true;
@@ -1544,8 +1686,8 @@ private:
                   GenMakePrintNodeFlagsVariable(this, nodeECFlagsMapping, "ECFLAGS", f);
                   GenMakePrintNodeFlagsVariable(this, nodeCFlagsMapping, "PRJ_CFLAGS", f);
 
-                  f.Printf(" -c %s%s.%s -o $@\n",
-                     modulePath, moduleName, extension, moduleName);
+                  f.Printf(" -c $(call quote_path,%s%s.%s) -o $(call quote_path,$@)\n",
+                     modulePath, moduleName, extension);
                   if(ifCount) f.Puts("endif\n");
                   f.Puts("\n");
 #if 0
@@ -1725,7 +1867,7 @@ private:
             }
 
             // Execute it
-            if((dep = DualPipeOpen(PipeOpenMode { output = 1, error = 1, input = 2 }, command)))
+            if((dep = DualPipeOpen(PipeOpenMode { output = true, error = true/*, input = true*/ }, command)))
             {
                char line[1024];
                bool result = true;
@@ -1780,8 +1922,8 @@ private:
             GenMakePrintNodeFlagsVariable(this, nodeCFlagsMapping, "PRJ_CFLAGS", f);
             f.Puts(" $(FVISIBILITY)");
 
-            f.Printf(" -c %s%s.%s -o $@ -symbols $(OBJ)\n",
-               modulePath, moduleName, extension, moduleName);
+            f.Printf(" -c $(call quote_path,%s%s.%s) -o $(call quote_path,$@) -symbols $(OBJ)\n",
+               modulePath, moduleName, extension);
             if(ifCount) f.Puts("endif\n");
             f.Puts("\n");
          }
@@ -1847,7 +1989,7 @@ private:
 
             info = namesInfo[moduleName];
             collision = info ? info.IsExtensionColliding(extension) : false;
-            
+
             ReplaceSpaces(modulePath, path);
             if(modulePath[0]) strcat(modulePath, SEPS);
 
@@ -1899,7 +2041,7 @@ private:
                }
 
                // Execute it
-               if((dep = DualPipeOpen(PipeOpenMode { output = 1, error = 1, input = 2 }, command)))
+               if((dep = DualPipeOpen(PipeOpenMode { output = true, error = true, input = false }, command)))
                {
                   char line[1024];
                   bool firstLine = true;
@@ -1948,12 +2090,12 @@ private:
             if(!strcmpi(extension, "ec"))
                f.Printf("$(OBJ)%s.o: $(OBJ)%s.c\n", moduleName, moduleName);
             else
-               f.Printf("$(OBJ)%s%s%s.o: %s%s.%s\n", moduleName, 
+               f.Printf("$(OBJ)%s%s%s.o: %s%s.%s\n", moduleName,
                      collision ? "." : "", collision ? extension : "", modulePath, moduleName, extension);
             if(!strcmpi(extension, "cc") || !strcmpi(extension, "cpp") || !strcmpi(extension, "cxx"))
                f.Printf("\t$(CXX)");
             else if(!strcmpi(extension, "rc"))
-               f.Printf("\t$(GCC_PREFIX)windres $< $@\n"); //$(WINDRES) // TODO: implement CompilerConfig::windresCommand
+               f.Printf("\t$(WINDRES) $(WINDRES_FLAGS) $< \"$(call escspace,$(call quote_path,$@))\"\n");
             else
                f.Printf("\t$(CC)");
 
@@ -1963,11 +2105,10 @@ private:
                GenMakePrintNodeFlagsVariable(this, nodeCFlagsMapping, "PRJ_CFLAGS", f);
 
                if(!strcmpi(extension, "ec"))
-                  f.Printf(" $(FVISIBILITY) -c $(OBJ)%s.c -o $@\n", moduleName, moduleName);
+                  f.Printf(" $(FVISIBILITY) -c $(call quote_path,$(OBJ)%s.c) -o $(call quote_path,$@)\n", moduleName);
                else
-                  f.Printf(" -c %s%s.%s -o $@\n",
-                        modulePath, moduleName, !strcmpi(extension, "ec") ? "c" : extension, moduleName,
-                        collision ? "." : "", collision ? extension : "");
+                  f.Printf(" -c $(call quote_path,%s%s.%s) -o $(call quote_path,$@)\n",
+                        modulePath, moduleName, !strcmpi(extension, "ec") ? "c" : extension);
             }
             if(ifCount) f.Puts("endif\n");
             f.Puts("\n");
@@ -2020,8 +2161,6 @@ private:
                char tempPath[MAX_LOCATION];
                char resPath[MAX_LOCATION];
 
-               char * quotes;
-
                // $(EAR) aw%s --- /*quiet ? "q" : */""
                if(count == 0)
                   f.Printf("\t%s$(EAR) aw$(EARFLAGS) $(TARGET)", ts.a);
@@ -2038,12 +2177,8 @@ private:
                   strcpy(tempPath, child.path);
                   PathCatSlash(tempPath, child.name);
                }
-               ReplaceSpaces(resPath, tempPath);
-               if(strchr(tempPath, ' '))
-                  quotes = "\"";
-               else
-                  quotes = "";
-               f.Printf(" %s%s%s%s", quotes, useRes ? "$(RES)" : "", tempPath, quotes);
+               EscapeForMake(resPath, tempPath, false, true, false);
+               f.Printf(" %s%s", useRes ? "$(RES)" : "", resPath);
                count++;
             }
             if(count == 10 || (count > 0 && (ts || !child.next)))
@@ -2301,18 +2436,18 @@ private:
 
    void GetTargets(ProjectConfig prjConfig, Map<String, NameCollisionInfo> namesInfo, char * objDir, DynamicString output)
    {
+      char moduleName[MAX_FILENAME];
       if(type == file)
       {
          bool headerAltFailed = false;
          bool collision;
          char extension[MAX_EXTENSION];
-         char moduleName[MAX_FILENAME];
          NameCollisionInfo info;
          Project prj = property::project;
          Map<String, String> headerToSource { [ { "eh", "ec" }, { "h", "c" }, { "hh", "cc" }, { "hpp", "cpp" }, { "hxx", "cxx" } ] };
 
          GetExtension(name, extension);
-         ReplaceSpaces(moduleName, name);
+         strcpy(moduleName, name);
          StripExtension(moduleName);
          info = namesInfo[moduleName];
          collision = info ? info.IsExtensionColliding(extension) : false;
@@ -2359,6 +2494,32 @@ private:
             output.concat("\"");
          }
       }
+      else if(type == project && ContainsFilesWithExtension("ec"))
+      {
+         Project prj = property::project;
+
+         ReplaceSpaces(moduleName, prj.moduleName);
+         strcat(moduleName, ".main.ec");
+         output.concat(" \"");
+         output.concat(objDir);
+         output.concat("/");
+         output.concat(moduleName);
+         output.concat("\"");
+
+         ChangeExtension(moduleName, "c", moduleName);
+         output.concat(" \"");
+         output.concat(objDir);
+         output.concat("/");
+         output.concat(moduleName);
+         output.concat("\"");
+
+         ChangeExtension(moduleName, "o", moduleName);
+         output.concat(" \"");
+         output.concat(objDir);
+         output.concat("/");
+         output.concat(moduleName);
+         output.concat("\"");
+      }
       else if(files)
       {
          for(child : files)
@@ -2459,9 +2620,10 @@ static ProjectOptions BlendFileConfigPlatformProjectOptions(ProjectNode node, Pr
    ProjectNode n;
    char * platformName = platform ? platform.OnGetString(0,0,0) : null;
 
-   Array<bool> optionConfigXplatformSet   { size = OPTION(postbuildCommands) };
-   Array<bool> optionDone                 { size = OPTION(postbuildCommands) };
-   Array<Array<String>> optionTempStrings { size = OPTION(postbuildCommands) };
+   // OPTION(ProjectOptions' last member) for size
+   Array<bool> optionConfigXplatformSet   { size = OPTION(installCommands) };
+   Array<bool> optionDone                 { size = OPTION(installCommands) };
+   Array<Array<String>> optionTempStrings { size = OPTION(installCommands) };
 
    GenericOptionTools<SetBool>              utilSetBool {
       bool OptionCheck(ProjectOptions options, int option) {
@@ -2973,12 +3135,14 @@ static void GenCFlagsFromProjectOptions(ProjectOptions options, bool prjWithEcFi
       }
       if(options.profile)
          s.concat(" -pg");
+      if(commonOptions)
+         s.concat(" -DREPOSITORY_VERSION=\"\\\"$(REPOSITORY_VER)\\\"\"");
    }
 
    if(options && options.preprocessorDefinitions)
-      ListOptionToDynamicString("D", options.preprocessorDefinitions, false, lineEach, "\t\t\t", false, s);
+      ListOptionToDynamicString(s, _D, options.preprocessorDefinitions, false, lineEach, "\t\t\t");
    if(options && options.includeDirs)
-      ListOptionToDynamicString("I", options.includeDirs, true, lineEach, "\t\t\t", true, s);
+      ListOptionToDynamicString(s, _I, options.includeDirs, true, lineEach, "\t\t\t");
 }
 
 static void GenECFlagsFromProjectOptions(ProjectOptions options, bool prjWithEcFiles, DynamicString s)
@@ -2993,15 +3157,15 @@ static void GenECFlagsFromProjectOptions(ProjectOptions options, bool prjWithEcF
       s.concatf(" -defaultns %s", options.defaultNameSpace);
 }
 
-static void ListOptionToDynamicString(char * option, Array<String> list, bool prioritize,
-      ListOutputMethod method, String newLineStart, bool noSpace, DynamicString s)
+static void ListOptionToDynamicString(DynamicString output, ToolchainFlag flag, Array<String> list, bool prioritize,
+      LineOutputMethod lineMethod, String newLineStart)
 {
    if(list.count)
    {
-      if(method == newLine)
+      if(lineMethod == newLine)
       {
-         s.concat(" \\\n");
-         s.concat(newLineStart);
+         output.concat(" \\\n");
+         output.concat(newLineStart);
       }
       if(prioritize)
       {
@@ -3012,17 +3176,14 @@ static void ListOptionToDynamicString(char * option, Array<String> list, bool pr
          for(mn = sortedList.root.minimum; mn; mn = mn.next)
          {
             char * start = strstr(mn.key, "\n");
-            if(method == lineEach)
+            if(lineMethod == lineEach)
             {
-               s.concat(" \\\n");
-               s.concat(newLineStart);
+               output.concat(" \\\n");
+               output.concat(newLineStart);
             }
-            s.concat(" -");
-            s.concat(option);
-            if(noSpace)
-               StringNoSpaceToDynamicString(s, start ? start+1 : mn.key);
-            else
-               s.concat(start ? start+1 : mn.key);
+            output.concat(" ");
+            output.concat(flagNames[flag]);
+            EscapeForMakeToDynString(output, start ? start+1 : mn.key, false, true, flag == _D);
          }
          delete sortedList;
       }
@@ -3030,17 +3191,14 @@ static void ListOptionToDynamicString(char * option, Array<String> list, bool pr
       {
          for(item : list)
          {
-            if(method == lineEach)
+            if(lineMethod == lineEach)
             {
-               s.concat(" \\\n");
-               s.concat(newLineStart);
+               output.concat(" \\\n");
+               output.concat(newLineStart);
             }
-            s.concat(" -");
-            s.concat(option);
-            if(noSpace)
-               StringNoSpaceToDynamicString(s, item);
-            else
-               s.concat(item);
+            output.concat(" ");
+            output.concat(flagNames[flag]);
+            EscapeForMakeToDynString(output, item, false, true, flag == _D);
          }
       }
    }