Fix a bug in HobLib migration.
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 25 Oct 2006 08:36:35 +0000 (08:36 +0000)
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 25 Oct 2006 08:36:35 +0000 (08:36 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1837 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Java/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java

index 4a4d71c..cdb833d 100644 (file)
@@ -261,12 +261,19 @@ public final class SourceFileReplacer implements Common.ForDoAll {
         Matcher mtrhobstatus;\r
         String templine = wholeline;\r
         for (int i = 0; i < specialhoblibfunc.length; i++) {\r
-            ptnhobstatus = Pattern.compile("(Status\\s*=\\s*)?" + specialhoblibfunc[i] + "(.*?\\)\\s*;)", Pattern.DOTALL);\r
-            mtrhobstatus = ptnhobstatus.matcher(templine);\r
-            if (mtrhobstatus.find()) {\r
-                templine = mtrhobstatus.replaceAll(specialhoblibfunc[i] + mtrhobstatus.group(2) + "\n  " + \r
-                           MigrationTool.MIGRATIONCOMMENT +  "R9 Hob-building library functions will assert if build failure.\n  Status = EFI_SUCCESS;");\r
-            }\r
+            do {\r
+                ptnhobstatus = Pattern.compile("((?:\t| )*)(\\w(?:\\w|\\d)*)\\s*=\\s*" + specialhoblibfunc[i] + "(.*?;)", Pattern.DOTALL);\r
+                mtrhobstatus = ptnhobstatus.matcher(templine);\r
+                if (!mtrhobstatus.find()) {\r
+                    break;\r
+                }\r
+                String captureIndent = mtrhobstatus.group(1);\r
+                String captureStatus = mtrhobstatus.group(2);\r
+                String replaceString = captureIndent + specialhoblibfunc[i] + mtrhobstatus.group(3) + "\n";\r
+                replaceString += captureIndent + MigrationTool.MIGRATIONCOMMENT +  "R9 Hob-building library functions will assert if build failure.\n";\r
+                replaceString += captureIndent + captureStatus + " = EFI_SUCCESS;";\r
+                templine = mtrhobstatus.replaceFirst(replaceString);\r
+            } while (true);\r
         }\r
         return templine;\r
     }\r