]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Adjust the behavior of the MdePkg Print Library class to produce a consistent style...
authormdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 30 Jun 2009 23:13:06 +0000 (23:13 +0000)
committermdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 30 Jun 2009 23:13:06 +0000 (23:13 +0000)
Previously, the Print Library class would translate '\n' to '\n\r'.

With this update, the following EOL translations are performed:
1) '\r' to '\r'
2) '\r\n' to '\r\n'
3) '\n' to '\r\n'
4) '\n\r' to '\r\n'

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

MdePkg/Include/Library/PrintLib.h
MdePkg/Library/BasePrintLib/PrintLibInternal.c

index 207d33c470506de1e49cd41baa0a7a92dadb616a..9aca725f7ffed5ccd06221a5356ab3e454d4c462 100644 (file)
@@ -15,11 +15,18 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   strings.  Many of the output functions use a format string to describe how to \r
   format the output of variable arguments.  The format string consists of normal \r
   text and argument descriptors.  There are no restrictions for how the normal \r
-  text and argument descriptors can be mixed.  A normal text character '\n' must \r
-  always be converted to '\n\r'.  This does not follow the ANSI C standard for \r
-  sprint().  The format of argument descriptors is described below.  The ANSI C \r
-  standard for sprint() has been followed for some of the format types, and has \r
-  not been followed for others.  The exceptions are noted below.\r
+  text and argument descriptors can be mixed.  The following end of line(EOL) \r
+  translations must be performed on the contents of the format string:\r
+  \r
+     - '\\r' is translated to '\\r'\r
+     - '\\r\\n' is translated to '\\r\\n'\r
+     - '\\n' is translated to '\\r\\n' \r
+     - '\\n\\r' is translated to '\\r\\n'\r
+  \r
+  This does not follow the ANSI C standard for sprint().  The format of argument \r
+  descriptors is described below.  The ANSI C standard for sprint() has been \r
+  followed for some of the format types, and has not been followed for others.  \r
+  The exceptions are noted below.\r
 \r
     %[flags][width][.precision]type\r
 \r
index ef006bbd00619e31239ce0bd53498ad18c44e05c..cf5c28e6f77ec1db39dfde644a9a775b901dedaf 100644 (file)
@@ -702,8 +702,33 @@ BasePrintLibSPrintMarker (
         }\r
         break;\r
 \r
+      case '\r':\r
+        Format += BytesPerFormatCharacter;\r
+        FormatCharacter = ((*Format & 0xff) | (*(Format + 1) << 8)) & FormatMask;\r
+        if (FormatCharacter == '\n') {\r
+          //\r
+          // Translate '\r\n' to '\r\n'\r
+          //\r
+          ArgumentString = "\r\n";\r
+        } else {\r
+          //\r
+          // Translate '\r' to '\r'\r
+          //\r
+          ArgumentString = "\r";\r
+          Format   -= BytesPerFormatCharacter;\r
+        }\r
+        break;\r
+\r
       case '\n':\r
-        ArgumentString = "\n\r";\r
+        //\r
+        // Translate '\n' to '\r\n' and '\n\r' to '\r\n'\r
+        //\r
+        ArgumentString = "\r\n";\r
+        Format += BytesPerFormatCharacter;\r
+        FormatCharacter = ((*Format & 0xff) | (*(Format + 1) << 8)) & FormatMask;\r
+        if (FormatCharacter != '\r') {\r
+          Format   -= BytesPerFormatCharacter;\r
+        }\r
         break;\r
 \r
       case '%':\r
@@ -717,8 +742,33 @@ BasePrintLibSPrintMarker (
       }\r
       break;\r
  \r
+    case '\r':\r
+      Format += BytesPerFormatCharacter;\r
+      FormatCharacter = ((*Format & 0xff) | (*(Format + 1) << 8)) & FormatMask;\r
+      if (FormatCharacter == '\n') {\r
+        //\r
+        // Translate '\r\n' to '\r\n'\r
+        //\r
+        ArgumentString = "\r\n";\r
+      } else {\r
+        //\r
+        // Translate '\r' to '\r'\r
+        //\r
+        ArgumentString = "\r";\r
+        Format   -= BytesPerFormatCharacter;\r
+      }\r
+      break;\r
+\r
     case '\n':\r
-      ArgumentString = "\n\r";\r
+      //\r
+      // Translate '\n' to '\r\n' and '\n\r' to '\r\n'\r
+      //\r
+      ArgumentString = "\r\n";\r
+      Format += BytesPerFormatCharacter;\r
+      FormatCharacter = ((*Format & 0xff) | (*(Format + 1) << 8)) & FormatMask;\r
+      if (FormatCharacter != '\r') {\r
+        Format   -= BytesPerFormatCharacter;\r
+      }\r
       break;\r
 \r
     default:\r