]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Print.c
Add Missing invocations to VA_END() for VA_START().
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / Dxe / Graphics / Print.c
index 03b66623c94132a3ea602b52e645b1dfebe1024c..83939670f65e15acee04a8e5089c7a14b3765a6e 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -65,14 +65,6 @@ Abstract:
 #include EFI_PROTOCOL_DEFINITION (Hii)\r
 #endif\r
 \r
-STATIC\r
-CHAR_W                *\r
-GetFlagsAndWidth (\r
-  IN  CHAR_W      *Format,\r
-  OUT UINTN       *Flags,\r
-  OUT UINTN       *Width,\r
-  IN OUT  VA_LIST *Marker\r
-  );\r
 \r
 STATIC\r
 UINTN\r
@@ -188,6 +180,7 @@ Returns:
   //\r
   // For now, allocate an arbitrarily long buffer\r
   //\r
+  BufferLen = 0;\r
   Buffer = EfiLibAllocateZeroPool (0x10000);\r
   if (Buffer == NULL) {\r
     return 0;\r
@@ -423,19 +416,19 @@ Returns:
   EFI_SIMPLE_TEXT_OUT_PROTOCOL  *Sto;\r
   EFI_STATUS                    Status;\r
   VA_LIST                       Args;\r
-\r
-  VA_START (Args, Fmt);\r
+  UINTN                         LengthOfPrinted;\r
 \r
   Handle = gST->ConsoleOutHandle;\r
 \r
+  GraphicsOutput = NULL;\r
+  UgaDraw        = NULL;\r
   Status = gBS->HandleProtocol (\r
                   Handle,\r
                   &gEfiGraphicsOutputProtocolGuid,\r
                   (VOID**)&GraphicsOutput\r
                   );\r
 \r
-  UgaDraw = NULL;\r
-  if (EFI_ERROR (Status)) {\r
+  if (EFI_ERROR (Status) || (GraphicsOutput == NULL)) {\r
     GraphicsOutput = NULL;\r
 \r
     Status = gBS->HandleProtocol (\r
@@ -460,7 +453,10 @@ Returns:
     return 0;\r
   }\r
 \r
-  return _IPrint (GraphicsOutput, UgaDraw, Sto, X, Y, ForeGround, BackGround, Fmt, Args);\r
+  VA_START (Args, Fmt);\r
+  LengthOfPrinted = _IPrint (GraphicsOutput, UgaDraw, Sto, X, Y, ForeGround, BackGround, Fmt, Args);\r
+  VA_END (Args);\r
+  return LengthOfPrinted;\r
 }\r
 \r
 \r
@@ -550,6 +546,7 @@ Returns:
   UINTN     BufferLeft;\r
   UINT64    Value;\r
   EFI_GUID  *TmpGUID;\r
+  BOOLEAN   Done;\r
 \r
   //\r
   // Process the format string. Stop if Buffer is over run.\r
@@ -576,7 +573,64 @@ Returns:
       //\r
       // Now it's time to parse what follows after %\r
       //\r
-      Format = GetFlagsAndWidth (Format, &Flags, &Width, &Marker);\r
+      Flags  = 0;\r
+      Width  = 0;\r
+      for (Done = FALSE; !Done;) {\r
+        Format++;\r
+    \r
+        switch (*Format) {\r
+    \r
+        case '-':\r
+          Flags |= LEFT_JUSTIFY;\r
+          break;\r
+    \r
+        case '+':\r
+          Flags |= PREFIX_SIGN;\r
+          break;\r
+    \r
+        case ' ':\r
+          Flags |= PREFIX_BLANK;\r
+          break;\r
+    \r
+        case ',':\r
+          Flags |= COMMA_TYPE;\r
+          break;\r
+    \r
+        case 'L':\r
+        case 'l':\r
+          Flags |= LONG_TYPE;\r
+          break;\r
+    \r
+        case '*':\r
+          Width = VA_ARG (Marker, UINTN);\r
+          break;\r
+    \r
+        case '0':\r
+          Flags |= PREFIX_ZERO;\r
+    \r
+        case '1':\r
+        case '2':\r
+        case '3':\r
+        case '4':\r
+        case '5':\r
+        case '6':\r
+        case '7':\r
+        case '8':\r
+        case '9':\r
+          Count = 0;\r
+          do {\r
+            Count = (Count * 10) +*Format - '0';\r
+            Format++;\r
+          } while ((*Format >= '0') && (*Format <= '9'));\r
+          Format--;\r
+          Width = Count;\r
+          break;\r
+    \r
+        default:\r
+          Done = TRUE;\r
+        }\r
+      }\r
+\r
       switch (*Format) {\r
       case 'p':\r
         //\r
@@ -723,103 +777,6 @@ Returns:
   return &Buffer[Index] - StartOfBuffer;\r
 }\r
 \r
-STATIC\r
-CHAR_W *\r
-GetFlagsAndWidth (\r
-  IN  CHAR_W      *Format,\r
-  OUT UINTN       *Flags,\r
-  OUT UINTN       *Width,\r
-  IN OUT  VA_LIST *Marker\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  VSPrint worker function that parses flag and width information from the \r
-  Format string and returns the next index into the Format string that needs\r
-  to be parsed. See file headed for details of Flag and Width.\r
-\r
-Arguments:\r
-\r
-  Format - Current location in the VSPrint format string.\r
-\r
-  Flags  - Returns flags\r
-\r
-  Width  - Returns width of element\r
-\r
-  Marker - Vararg list that may be paritally consumed and returned.\r
-\r
-Returns: \r
-\r
-  Pointer indexed into the Format string for all the information parsed\r
-  by this routine.\r
-\r
---*/\r
-{\r
-  UINTN   Count;\r
-  BOOLEAN Done;\r
-\r
-  *Flags  = 0;\r
-  *Width  = 0;\r
-  for (Done = FALSE; !Done;) {\r
-    Format++;\r
-\r
-    switch (*Format) {\r
-\r
-    case '-':\r
-      *Flags |= LEFT_JUSTIFY;\r
-      break;\r
-\r
-    case '+':\r
-      *Flags |= PREFIX_SIGN;\r
-      break;\r
-\r
-    case ' ':\r
-      *Flags |= PREFIX_BLANK;\r
-      break;\r
-\r
-    case ',':\r
-      *Flags |= COMMA_TYPE;\r
-      break;\r
-\r
-    case 'L':\r
-    case 'l':\r
-      *Flags |= LONG_TYPE;\r
-      break;\r
-\r
-    case '*':\r
-      *Width = VA_ARG (*Marker, UINTN);\r
-      break;\r
-\r
-    case '0':\r
-      *Flags |= PREFIX_ZERO;\r
-\r
-    case '1':\r
-    case '2':\r
-    case '3':\r
-    case '4':\r
-    case '5':\r
-    case '6':\r
-    case '7':\r
-    case '8':\r
-    case '9':\r
-      Count = 0;\r
-      do {\r
-        Count = (Count * 10) +*Format - '0';\r
-        Format++;\r
-      } while ((*Format >= '0') && (*Format <= '9'));\r
-      Format--;\r
-      *Width = Count;\r
-      break;\r
-\r
-    default:\r
-      Done = TRUE;\r
-    }\r
-  }\r
-\r
-  return Format;\r
-}\r
-\r
 STATIC\r
 UINTN\r
 GuidToString (\r