Adjust the behavior of the MdePkg Print Library class to produce a consistent style of EOL characters.

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
This commit is contained in:
mdkinney 2009-06-30 23:13:06 +00:00
parent 40f2c45434
commit c553db4b78
2 changed files with 64 additions and 7 deletions

View 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 strings. Many of the output functions use a format string to describe how to
format the output of variable arguments. The format string consists of normal format the output of variable arguments. The format string consists of normal
text and argument descriptors. There are no restrictions for how the normal text and argument descriptors. There are no restrictions for how the normal
text and argument descriptors can be mixed. A normal text character '\n' must text and argument descriptors can be mixed. The following end of line(EOL)
always be converted to '\n\r'. This does not follow the ANSI C standard for translations must be performed on the contents of the format string:
sprint(). The format of argument descriptors is described below. The ANSI C
standard for sprint() has been followed for some of the format types, and has - '\\r' is translated to '\\r'
not been followed for others. The exceptions are noted below. - '\\r\\n' is translated to '\\r\\n'
- '\\n' is translated to '\\r\\n'
- '\\n\\r' is translated to '\\r\\n'
This does not follow the ANSI C standard for sprint(). The format of argument
descriptors is described below. The ANSI C standard for sprint() has been
followed for some of the format types, and has not been followed for others.
The exceptions are noted below.
%[flags][width][.precision]type %[flags][width][.precision]type

View File

@ -702,8 +702,33 @@ BasePrintLibSPrintMarker (
} }
break; break;
case '\r':
Format += BytesPerFormatCharacter;
FormatCharacter = ((*Format & 0xff) | (*(Format + 1) << 8)) & FormatMask;
if (FormatCharacter == '\n') {
//
// Translate '\r\n' to '\r\n'
//
ArgumentString = "\r\n";
} else {
//
// Translate '\r' to '\r'
//
ArgumentString = "\r";
Format -= BytesPerFormatCharacter;
}
break;
case '\n': case '\n':
ArgumentString = "\n\r"; //
// Translate '\n' to '\r\n' and '\n\r' to '\r\n'
//
ArgumentString = "\r\n";
Format += BytesPerFormatCharacter;
FormatCharacter = ((*Format & 0xff) | (*(Format + 1) << 8)) & FormatMask;
if (FormatCharacter != '\r') {
Format -= BytesPerFormatCharacter;
}
break; break;
case '%': case '%':
@ -717,8 +742,33 @@ BasePrintLibSPrintMarker (
} }
break; break;
case '\r':
Format += BytesPerFormatCharacter;
FormatCharacter = ((*Format & 0xff) | (*(Format + 1) << 8)) & FormatMask;
if (FormatCharacter == '\n') {
//
// Translate '\r\n' to '\r\n'
//
ArgumentString = "\r\n";
} else {
//
// Translate '\r' to '\r'
//
ArgumentString = "\r";
Format -= BytesPerFormatCharacter;
}
break;
case '\n': case '\n':
ArgumentString = "\n\r"; //
// Translate '\n' to '\r\n' and '\n\r' to '\r\n'
//
ArgumentString = "\r\n";
Format += BytesPerFormatCharacter;
FormatCharacter = ((*Format & 0xff) | (*(Format + 1) << 8)) & FormatMask;
if (FormatCharacter != '\r') {
Format -= BytesPerFormatCharacter;
}
break; break;
default: default: