]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java
Turn to Regex in ModuleReader.java
[mirror_edk2.git] / Tools / Source / MigrationTools / org / tianocore / migration / SourceFileReplacer.java
index 34eb6be45478750a83e6d5523c772cf4854bbba7..03617ab7167cc61e51d0031b20be09fced2b994a 100644 (file)
@@ -71,7 +71,7 @@ public class SourceFileReplacer {
                PrintWriter outfile;\r
                String outname = null;\r
                String inname = null;\r
-               if (ui.yesOrNo("Change Source Code is to be doing . See details ?")) {\r
+               if (ui.yesOrNo("Changes will be made to the Source Code.  View details?")) {\r
                        showdetails = true;\r
                }\r
                \r
@@ -84,8 +84,8 @@ public class SourceFileReplacer {
                                } else {\r
                                        outname = inname;\r
                                }\r
-                               ui.println("\nModifying file : " + inname);\r
-                               mi.ensureDir(modulepath + File.separator + "result" + File.separator + outname);\r
+                               ui.println("\nModifying file: " + inname);\r
+                               Common.ensureDir(modulepath + File.separator + "result" + File.separator + outname);\r
                                outfile = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "result" + File.separator + outname)));\r
                                outfile.append(sourcefilereplace(modulepath + File.separator + "temp" + File.separator + inname));\r
                                outfile.flush();\r
@@ -96,10 +96,10 @@ public class SourceFileReplacer {
                                } else {\r
                                        outname = inname;\r
                                }\r
-                               ui.println("\nCopying file : " + inname);\r
-                               mi.ensureDir(modulepath + File.separator + "result" + File.separator + outname);\r
+                               ui.println("\nCopying file: " + inname);\r
+                               Common.ensureDir(modulepath + File.separator + "result" + File.separator + outname);\r
                                outfile = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "result" + File.separator + outname)));\r
-                               outfile.append(sourcefiletostring(modulepath + File.separator + "temp" + File.separator + inname));\r
+                               outfile.append(Common.sourcefiletostring(modulepath + File.separator + "temp" + File.separator + inname));\r
                                outfile.flush();\r
                                outfile.close();\r
                        }\r
@@ -112,8 +112,8 @@ public class SourceFileReplacer {
        \r
        private void addr8only() throws Exception {\r
                String paragraph = null;\r
-               String line = sourcefiletostring(Database.defaultpath + File.separator + "R8Lib.c");\r
-               mi.ensureDir(modulepath + File.separator + "result" + File.separator + "R8Lib.c");\r
+               String line = Common.sourcefiletostring(Database.defaultpath + File.separator + "R8Lib.c");\r
+               Common.ensureDir(modulepath + File.separator + "result" + File.separator + "R8Lib.c");\r
                PrintWriter outfile1 = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "result" + File.separator + "R8Lib.c")));\r
                PrintWriter outfile2 = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "result" + File.separator + "R8Lib.h")));\r
                Pattern ptnr8only = Pattern.compile("////#?(\\w*)?.*?R8_(\\w*).*?////~", Pattern.DOTALL);\r
@@ -142,16 +142,6 @@ public class SourceFileReplacer {
                mi.localmodulesources.add("R8Lib.c");\r
        }\r
        \r
-       private String sourcefiletostring(String filename) throws Exception {\r
-               BufferedReader rd = new BufferedReader(new FileReader(filename));\r
-               StringBuffer wholefile = new StringBuffer();\r
-               String line;\r
-               while ((line = rd.readLine()) != null) {\r
-                       wholefile.append(line + "\n");\r
-               }\r
-               return wholefile.toString();\r
-       }\r
-       \r
        // Caution : if there is @ in file , it will be replaced with \n , so is you use Doxygen ... God Bless you!\r
        private String sourcefilereplace(String filename) throws Exception {\r
                BufferedReader rd = new BufferedReader(new FileReader(filename));\r
@@ -173,7 +163,7 @@ public class SourceFileReplacer {
                // replace BS -> gBS , RT -> gRT\r
                Matcher mat = pat.matcher(line);\r
                if (mat.find()) {                                                                                               // add a library here\r
-                       ui.println("Converting all BS->gBS,RT->gRT");\r
+                       ui.println("Converting all BS->gBS, RT->gRT");\r
                        line = mat.replaceAll("g$1$2$3");                                                       //unknown correctiveness\r
                }\r
                mat.reset();\r