import org.tianocore.*;\r
\r
public final class ModuleReader implements Common.ForDoAll {\r
- private static final ModuleReader modulereader = new ModuleReader();\r
+ private static final ModuleReader modulereader = new ModuleReader();\r
private ModuleInfo mi;\r
private final CommentLaplace commentlaplace = new CommentLaplace();\r
\r
if (mtrsection.group(1).contains("sources.")) {\r
mtrfilename = ptnfilename.matcher(mtrsection.group(2));\r
while (mtrfilename.find()) {\r
- mi.infsources.add(mtrfilename.group());\r
+ mi.infsources.add(mtrfilename.group());\r
if (!mi.localmodulesources.contains(mtrfilename.group())) {\r
MigrationTool.ui.println("Warn: Source File Missing! : " + mtrfilename.group());\r
}\r
if (mtrsection.group(1).matches("includes.")) {\r
mtrfilename = ptnfilename.matcher(mtrsection.group(2));\r
while (mtrfilename.find()) {\r
- mi.infincludes.add(mtrfilename.group());\r
+ mi.infincludes.add(mtrfilename.group());\r
}\r
}\r
}\r
}\r
\r
private final void preProcessModule() throws Exception {\r
- // according to .inf file, add extraordinary includes and sourcefiles\r
- Common.dirCopy(mi.modulepath, mi.temppath); // collect all Laplace.namechange to here???\r
+ // according to .inf file, add extraordinary includes and sourcefiles\r
+ Common.dirCopy(mi.modulepath, mi.temppath); // collect all Laplace.namechange to here???\r
\r
- if (!mi.infincludes.isEmpty()) {\r
+ if (!mi.infincludes.isEmpty()) {\r
Iterator<String> it = mi.infincludes.iterator();\r
String tempincludename = null;\r
- while (it.hasNext()) {\r
- tempincludename = it.next();\r
- if (tempincludename.contains("..")) {\r
- Matcher mtr = Common.PTNSEPARATER.matcher(tempincludename);\r
- if (mtr.find() && !mtr.group(2).matches(".")) {\r
- Common.oneLevelDirCopy(mi.modulepath.replaceAll(Common.STRSEPARATER, "$1") + File.separator + mtr.group(2), mi.temppath, ".h");\r
- } else {\r
- Common.oneLevelDirCopy(mi.modulepath.replaceAll(Common.STRSEPARATER, "$1"), mi.temppath, ".h");\r
- }\r
- }\r
- }\r
- }\r
- if (!mi.infsources.isEmpty()) {\r
+ while (it.hasNext()) {\r
+ tempincludename = it.next();\r
+ if (tempincludename.contains("..")) {\r
+ Matcher mtr = Common.PTNSEPARATER.matcher(tempincludename);\r
+ if (mtr.find() && !mtr.group(2).matches(".")) {\r
+ Common.oneLevelDirCopy(mi.modulepath.replaceAll(Common.STRSEPARATER, "$1") + File.separator + mtr.group(2), mi.temppath, ".h");\r
+ } else {\r
+ Common.oneLevelDirCopy(mi.modulepath.replaceAll(Common.STRSEPARATER, "$1"), mi.temppath, ".h");\r
+ }\r
+ }\r
+ }\r
+ }\r
+ if (!mi.infsources.isEmpty()) {\r
Iterator<String> it = mi.infsources.iterator();\r
String tempsourcename = null;\r
while (it.hasNext()) {\r
- tempsourcename = it.next();\r
- if (tempsourcename.contains("..")) {\r
- Common.ensureDir(mi.temppath + File.separator + "MT_Parent_Sources");\r
- Matcher mtr = Common.PTNSEPARATER.matcher(tempsourcename);\r
- if (mtr.find()) {\r
- Common.fileCopy(mi.modulepath.replaceAll(Common.STRSEPARATER, "$1") + File.separator + mtr.group(2), mi.temppath + File.separator + "MT_Parent_Sources" + File.separator + mtr.group(2));\r
- }\r
- }\r
+ tempsourcename = it.next();\r
+ if (tempsourcename.contains("..")) {\r
+ Common.ensureDir(mi.temppath + File.separator + "MT_Parent_Sources");\r
+ Matcher mtr = Common.PTNSEPARATER.matcher(tempsourcename);\r
+ if (mtr.find()) {\r
+ Common.fileCopy(mi.modulepath.replaceAll(Common.STRSEPARATER, "$1") + File.separator + mtr.group(2), mi.temppath + File.separator + "MT_Parent_Sources" + File.separator + mtr.group(2));\r
+ }\r
+ }\r
}\r
- }\r
+ }\r
\r
//CommentOutNonLocalHFile();\r
Common.toDoAll(mi.temppath, this, Common.FILE);\r
\r
public class CommentLaplace extends Common.Laplace {\r
public String operation(String wholeline) {\r
- StringBuffer wholebuffer = new StringBuffer();\r
- String templine = null;\r
+ StringBuffer wholebuffer = new StringBuffer();\r
+ String templine = null;\r
Pattern ptnincludefile = Pattern.compile("[\"<](.*[.]h)[\">]");\r
Pattern ptninclude = Pattern.compile("#include\\s*(.*)");\r
Matcher mtrinclude = ptninclude.matcher(wholeline);\r
Matcher mtrincludefile = null;\r
while (mtrinclude.find()) {\r
- mtrincludefile = ptnincludefile.matcher(mtrinclude.group(1));\r
- if (mtrincludefile.find() && mi.localmodulesources.contains(mtrincludefile.group(1))) {\r
- templine = mtrinclude.group();\r
- } else {\r
- templine = MigrationTool.MIGRATIONCOMMENT + mtrinclude.group();\r
- }\r
- mtrinclude.appendReplacement(wholebuffer, templine);\r
+ mtrincludefile = ptnincludefile.matcher(mtrinclude.group(1));\r
+ if (mtrincludefile.find() && mi.localmodulesources.contains(mtrincludefile.group(1))) {\r
+ templine = mtrinclude.group();\r
+ } else {\r
+ templine = MigrationTool.MIGRATIONCOMMENT + mtrinclude.group();\r
+ }\r
+ mtrinclude.appendReplacement(wholebuffer, templine);\r
}\r
mtrinclude.appendTail(wholebuffer);\r
return wholebuffer.toString();\r
}\r
\r
public boolean recognize(String filename) {\r
- return filename.contains(".c") || filename.contains(".h");\r
+ return filename.contains(".c") || filename.contains(".h");\r
}\r
\r
public String namechange(String oldname) {\r
- return oldname;\r
+ return oldname;\r
}\r
}\r
\r
//-----------------------------------ForDoAll-----------------------------------//\r
public void run(String filepath) throws Exception {\r
- String name = mi.temppath + File.separator + filepath.replace(mi.temppath + File.separator, "");\r
- commentlaplace.transform(name, name);\r
+ String name = mi.temppath + File.separator + filepath.replace(mi.temppath + File.separator, "");\r
+ commentlaplace.transform(name, name);\r
}\r
\r
public boolean filter(File dir) {\r
//-----------------------------------ForDoAll-----------------------------------//\r
\r
public final void setModuleInfo(ModuleInfo m) {\r
- mi = m;\r
+ mi = m;\r
}\r
\r
public static final void aimAt(ModuleInfo mi) throws Exception {\r
- modulereader.setModuleInfo(mi);\r
- modulereader.ModuleScan();\r
+ modulereader.setModuleInfo(mi);\r
+ modulereader.ModuleScan();\r
}\r
}\r