]> git.proxmox.com Git - mirror_edk2.git/commitdiff
clarify the logic of the print length counting functions in both PrintLib library...
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 8 Aug 2011 20:50:31 +0000 (20:50 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 8 Aug 2011 20:50:31 +0000 (20:50 +0000)
signed-off-by: jcarsey
reviewed-by: geekboy15a

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12102 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c
MdePkg/Library/BasePrintLib/PrintLibInternal.c

index a239dee2cceaf9a533255a9faf1e28a5eae46293..45aab49176894cd162c7a66c2d27114235bd6c95 100644 (file)
@@ -1660,38 +1660,18 @@ InternalPrintLibSPrintMarker (
     // Pad before the string\r
     //\r
     if ((Flags & (PAD_TO_WIDTH | LEFT_JUSTIFY)) == (PAD_TO_WIDTH)) {\r
-      if (Flags & COUNT_ONLY_NO_PRINT) {\r
-        LengthToReturn += ((Width - Precision) * BytesPerOutputCharacter);\r
-      } else {\r
-//        Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Width - Precision, ' ', BytesPerOutputCharacter);\r
-      }\r
+      LengthToReturn += ((Width - Precision) * BytesPerOutputCharacter);\r
     }\r
 \r
     if (ZeroPad) {\r
       if (Prefix != 0) {\r
-        if (Flags & COUNT_ONLY_NO_PRINT) {\r
-          LengthToReturn += (1 * BytesPerOutputCharacter);\r
-        } else {\r
-//          Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, Prefix, BytesPerOutputCharacter);\r
-        }\r
-      }\r
-      if (Flags & COUNT_ONLY_NO_PRINT) {\r
-        LengthToReturn += ((Precision - Count) * BytesPerOutputCharacter);\r
-      } else {\r
-//        Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Precision - Count, '0', BytesPerOutputCharacter);\r
+        LengthToReturn += (1 * BytesPerOutputCharacter);\r
       }\r
+      LengthToReturn += ((Precision - Count) * BytesPerOutputCharacter);\r
     } else {\r
-      if (Flags & COUNT_ONLY_NO_PRINT) {\r
-        LengthToReturn += ((Precision - Count) * BytesPerOutputCharacter);\r
-      } else {\r
-//        Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Precision - Count, ' ', BytesPerOutputCharacter);\r
-      }\r
+      LengthToReturn += ((Precision - Count) * BytesPerOutputCharacter);\r
       if (Prefix != 0) {\r
-        if (Flags & COUNT_ONLY_NO_PRINT) {\r
-          LengthToReturn += (1 * BytesPerOutputCharacter);\r
-        } else {\r
-//          Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, Prefix, BytesPerOutputCharacter);\r
-        }\r
+        LengthToReturn += (1 * BytesPerOutputCharacter);\r
       }\r
     }\r
 \r
@@ -1709,11 +1689,7 @@ InternalPrintLibSPrintMarker (
     while (Index < Count) {\r
       ArgumentCharacter = ((*ArgumentString & 0xff) | (*(ArgumentString + 1) << 8)) & ArgumentMask;\r
 \r
-      if (Flags & COUNT_ONLY_NO_PRINT) {\r
-        LengthToReturn += (1 * BytesPerOutputCharacter);\r
-      } else {\r
-//        Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, ArgumentCharacter, BytesPerOutputCharacter);\r
-      }\r
+      LengthToReturn += (1 * BytesPerOutputCharacter);\r
       ArgumentString    += BytesPerArgumentCharacter;\r
       Index++;\r
       if (Comma) {\r
@@ -1722,11 +1698,7 @@ InternalPrintLibSPrintMarker (
           Digits = 0;\r
           Index++;\r
           if (Index < Count) {\r
-            if (Flags & COUNT_ONLY_NO_PRINT) {\r
-              LengthToReturn += (1 * BytesPerOutputCharacter);\r
-            } else {\r
-//              Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, ',', BytesPerOutputCharacter);\r
-            }\r
+            LengthToReturn += (1 * BytesPerOutputCharacter);\r
           }\r
         }\r
       }\r
@@ -1736,11 +1708,7 @@ InternalPrintLibSPrintMarker (
     // Pad after the string\r
     //\r
     if ((Flags & (PAD_TO_WIDTH | LEFT_JUSTIFY)) == (PAD_TO_WIDTH | LEFT_JUSTIFY)) {\r
-      if (Flags & COUNT_ONLY_NO_PRINT) {\r
-        LengthToReturn += ((Width - Precision) * BytesPerOutputCharacter);\r
-      } else {\r
-//        Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Width - Precision, ' ', BytesPerOutputCharacter);\r
-      }\r
+      LengthToReturn += ((Width - Precision) * BytesPerOutputCharacter);\r
     }\r
 \r
     //\r
index 205b54aa0903cfa9a5fed3399a813a07cc63be9b..de1b25fa7a71e728973cbff93202dd0dc4c5f9bb 100644 (file)
@@ -334,7 +334,7 @@ BasePrintLibSPrintMarker (
   UINT32            GuidData1;\r
   UINT16            GuidData2;\r
   UINT16            GuidData3;\r
-  UINT            LengthToReturn;\r
+  UINT32            LengthToReturn;\r
 \r
   //\r
   // If you change this code be sure to match the 2 versions of this function.\r
@@ -842,36 +842,31 @@ BasePrintLibSPrintMarker (
     // Pad before the string\r
     //\r
     if ((Flags & (PAD_TO_WIDTH | LEFT_JUSTIFY)) == (PAD_TO_WIDTH)) {\r
-      if (Flags & COUNT_ONLY_NO_PRINT) {\r
-        LengthToReturn += ((Width - Precision) * BytesPerOutputCharacter);\r
-      } else {\r
+      LengthToReturn += ((Width - Precision) * BytesPerOutputCharacter);\r
+      if ((Flags & COUNT_ONLY_NO_PRINT) == 0) {\r
         Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Width - Precision, ' ', BytesPerOutputCharacter);\r
       }\r
     }\r
 \r
     if (ZeroPad) {\r
       if (Prefix != 0) {\r
-        if (Flags & COUNT_ONLY_NO_PRINT) {\r
-          LengthToReturn += (1 * BytesPerOutputCharacter);\r
-        } else {\r
+        LengthToReturn += (1 * BytesPerOutputCharacter);\r
+        if ((Flags & COUNT_ONLY_NO_PRINT) == 0) {\r
           Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, Prefix, BytesPerOutputCharacter);\r
         }\r
       }\r
-      if (Flags & COUNT_ONLY_NO_PRINT) {\r
-        LengthToReturn += ((Precision - Count) * BytesPerOutputCharacter);\r
-      } else {\r
+      LengthToReturn += ((Precision - Count) * BytesPerOutputCharacter);\r
+      if ((Flags & COUNT_ONLY_NO_PRINT) == 0) {\r
         Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Precision - Count, '0', BytesPerOutputCharacter);\r
       }\r
     } else {\r
-      if (Flags & COUNT_ONLY_NO_PRINT) {\r
-        LengthToReturn += ((Precision - Count) * BytesPerOutputCharacter);\r
-      } else {\r
+      LengthToReturn += ((Precision - Count) * BytesPerOutputCharacter);\r
+      if ((Flags & COUNT_ONLY_NO_PRINT) == 0) {\r
         Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Precision - Count, ' ', BytesPerOutputCharacter);\r
       }\r
       if (Prefix != 0) {\r
-        if (Flags & COUNT_ONLY_NO_PRINT) {\r
-          LengthToReturn += (1 * BytesPerOutputCharacter);\r
-        } else {\r
+        LengthToReturn += (1 * BytesPerOutputCharacter);\r
+        if ((Flags & COUNT_ONLY_NO_PRINT) == 0) {\r
           Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, Prefix, BytesPerOutputCharacter);\r
         }\r
       }\r
@@ -891,9 +886,8 @@ BasePrintLibSPrintMarker (
     while (Index < Count) {\r
       ArgumentCharacter = ((*ArgumentString & 0xff) | (*(ArgumentString + 1) << 8)) & ArgumentMask;\r
 \r
-      if (Flags & COUNT_ONLY_NO_PRINT) {\r
-        LengthToReturn += (1 * BytesPerOutputCharacter);\r
-      } else {\r
+      LengthToReturn += (1 * BytesPerOutputCharacter);\r
+      if ((Flags & COUNT_ONLY_NO_PRINT) == 0) {\r
         Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, ArgumentCharacter, BytesPerOutputCharacter);\r
       }\r
       ArgumentString    += BytesPerArgumentCharacter;\r
@@ -904,9 +898,8 @@ BasePrintLibSPrintMarker (
           Digits = 0;\r
           Index++;\r
           if (Index < Count) {\r
-            if (Flags & COUNT_ONLY_NO_PRINT) {\r
-              LengthToReturn += (1 * BytesPerOutputCharacter);\r
-            } else {\r
+            LengthToReturn += (1 * BytesPerOutputCharacter);\r
+            if ((Flags & COUNT_ONLY_NO_PRINT) == 0) {\r
               Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, ',', BytesPerOutputCharacter);\r
             }\r
           }\r
@@ -918,9 +911,8 @@ BasePrintLibSPrintMarker (
     // Pad after the string\r
     //\r
     if ((Flags & (PAD_TO_WIDTH | LEFT_JUSTIFY)) == (PAD_TO_WIDTH | LEFT_JUSTIFY)) {\r
-      if (Flags & COUNT_ONLY_NO_PRINT) {\r
-        LengthToReturn += ((Width - Precision) * BytesPerOutputCharacter);\r
-      } else {\r
+      LengthToReturn += ((Width - Precision) * BytesPerOutputCharacter);\r
+      if ((Flags & COUNT_ONLY_NO_PRINT) == 0) {\r
         Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Width - Precision, ' ', BytesPerOutputCharacter);\r
       }\r
     }\r