diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/Common.java b/Tools/Source/MigrationTools/org/tianocore/migration/Common.java index a7154b6129..da560ec10b 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/Common.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/Common.java @@ -192,4 +192,19 @@ public final class Common { public abstract String namechange(String oldname); } + + public static interface Element { + +// public int replace = 0; +// public int type = 1; + + public String getReplace(String key); + +// public void getType(String key); +// +// public void setReplace(int num); +// +// public void setType(int num); + + } } diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/Critic.java b/Tools/Source/MigrationTools/org/tianocore/migration/Critic.java index 95e95e9dd4..49c13bfa94 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/Critic.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/Critic.java @@ -16,6 +16,7 @@ import java.util.regex.*; import java.io.*; public final class Critic { + public static final Pattern PTN_NEW_HEAD_COMMENT = Pattern.compile("^\\/\\*\\*.*?\\*\\*\\/",Pattern.DOTALL); private static final Pattern ptnheadcomment = Pattern.compile("^\\/\\*\\+\\+(.*?)\\-\\-\\*\\/",Pattern.DOTALL); private static final Pattern ptnfunccomment = Pattern.compile("([\\};\\/\">]\\s*)([\\w\\s]*?[_\\w][_\\w\\d]*\\s*\\([^\\)\\(]*\\)\\s*)\\/\\*\\+\\+(.*?)\\-\\-\\*\\/(\\s*.*?)([\\{;])",Pattern.DOTALL); // find function with {;">/ , may be unsafe //private static Pattern ptncommentstructure = Pattern.compile("\\/\\*\\+\\+\\s*Routine Description:\\s*(.*?)\\s*Arguments:\\s*(.*?)\\s*Returns:\\s*(.*?)\\s*\\-\\-\\*\\/",Pattern.DOTALL); diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java b/Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java index 5fb102091c..07f93cecad 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java @@ -281,12 +281,21 @@ public final class SourceFileReplacer implements Common.ForDoAll { String line = Common.file2string(MigrationTool.db.DatabasePath + File.separator + "R8Lib.c"); PrintWriter outfile1 = new PrintWriter(new BufferedWriter(new FileWriter(MigrationTool.ModuleInfoMap.get(mi) + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.c"))); PrintWriter outfile2 = new PrintWriter(new BufferedWriter(new FileWriter(MigrationTool.ModuleInfoMap.get(mi) + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.h"))); - Pattern ptnr8only = Pattern.compile("////#?(\\w*)?.*?R8_(\\w*).*?////~", Pattern.DOTALL); + Pattern ptnr8only = Pattern.compile("////#?(\\w*)?(.*?R8_(\\w*).*?)////~", Pattern.DOTALL); Matcher mtrr8only = ptnr8only.matcher(line); Matcher mtrr8onlyhead; + + //add head comment + Matcher mtrr8onlyheadcomment = Critic.PTN_NEW_HEAD_COMMENT.matcher(line); + if (mtrr8onlyheadcomment.find()) { + outfile1.append(mtrr8onlyheadcomment.group() + "\n\n"); + outfile2.append(mtrr8onlyheadcomment.group() + "\n\n"); + } + + //add functions body while (mtrr8only.find()) { - if (mi.hashr8only.contains(mtrr8only.group(2))) { - paragraph = mtrr8only.group(); + if (mi.hashr8only.contains(mtrr8only.group(3))) { + paragraph = mtrr8only.group(2); outfile1.append(paragraph + "\n\n"); if (mtrr8only.group(1).length() != 0) { mi.hashrequiredr9libs.add(mtrr8only.group(1));