X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FSource%2FTianoTools%2FString%2FString.c;h=9e02231f364f420efd99db96b3d25da43c06ec69;hp=10051806ad59e80e38b045a5218f69d74b7f63e8;hb=cf17111004eeff50dfc138ea11711a242e926b3a;hpb=d2ec0d9ef6af0b8d3dc7113fa8d631709c814a06
diff --git a/Tools/Source/TianoTools/String/String.c b/Tools/Source/TianoTools/String/String.c
index 10051806ad..9e02231f36 100644
--- a/Tools/Source/TianoTools/String/String.c
+++ b/Tools/Source/TianoTools/String/String.c
@@ -1,11 +1,14 @@
/** @file
Unicode string primatives.
- Copyright (c) 2006, Intel Corporation
- All rights reserved. This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
+Copyright (c) 2004-2006 Intel Corporation. All rights reserved
+This software and associated documentation (if any) is furnished
+under a license and may only be used or copied in accordance
+with the terms of the license. Except as permitted by such
+license, no part of this software or documentation may be
+reproduced, stored in a retrieval system, or transmitted in any
+form or by any means without the express written consent of
+Intel Corporation.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@@ -15,13 +18,68 @@
**/
#include
-#include
-#include
-#include
-#include
-#include
-#define _gPcd_FixedAtBuild_PcdMaximumUnicodeStringLength 0
-#define _gPcd_FixedAtBuild_PcdMaximumAsciiStringLength 0
+
+#include
+
+#include "CommonLib.h"
+
+/**
+ Returns the length of a Null-terminated Unicode string.
+
+ This function returns the number of Unicode characters in the Null-terminated
+ Unicode string specified by String.
+
+ If String is NULL, then ASSERT().
+
+ @param String Pointer to a Null-terminated Unicode string.
+
+ @return The length of String.
+
+**/
+UINTN
+EFIAPI
+StrLen (
+ IN CONST CHAR16 *String
+ )
+{
+ UINTN Length;
+
+ ASSERT (String != NULL);
+
+ for (Length = 0; *String != L'\0'; String++, Length++) {
+ ;
+ }
+ return Length;
+}
+
+/**
+ Returns the length of a Null-terminated ASCII string.
+
+ This function returns the number of ASCII characters in the Null-terminated
+ ASCII string specified by String.
+
+ If String is NULL, then ASSERT().
+
+ @param String Pointer to a Null-terminated ASCII string.
+
+ @return The length of String.
+
+**/
+UINTN
+EFIAPI
+AsciiStrLen (
+ IN CONST CHAR8 *String
+ )
+{
+ UINTN Length;
+
+ ASSERT (String != NULL);
+
+ for (Length = 0; *String != '\0'; String++, Length++) {
+ ;
+ }
+ return Length;
+}
/**
Copies one Null-terminated Unicode string to another Null-terminated Unicode
@@ -34,8 +92,6 @@
If Destination is NULL, then ASSERT().
If Source is NULL, then ASSERT().
If Source and Destination overlap, then ASSERT().
- If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
- PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
@param Destination Pointer to a Null-terminated Unicode string.
@param Source Pointer to a Null-terminated Unicode string.
@@ -87,8 +143,6 @@ StrCpy (
If Destination is NULL, then ASSERT().
If Source is NULL, then ASSERT().
If Source and Destination overlap, then ASSERT().
- If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
- PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
@param Destination Pointer to a Null-terminated Unicode string.
@param Source Pointer to a Null-terminated Unicode string.
@@ -130,48 +184,10 @@ StrnCpy (
Length--;
}
- // ZeroMem (Destination, Length * sizeof (*Destination));
memset (Destination, 0, Length * sizeof (*Destination));
return ReturnValue;
}
-/**
- Returns the length of a Null-terminated Unicode string.
-
- This function returns the number of Unicode characters in the Null-terminated
- Unicode string specified by String.
-
- If String is NULL, then ASSERT().
- If PcdMaximumUnicodeStringLength is not zero, and String contains more than
- PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
-
- @param String Pointer to a Null-terminated Unicode string.
-
- @return The length of String.
-
-**/
-UINTN
-EFIAPI
-StrLen (
- IN CONST CHAR16 *String
- )
-{
- UINTN Length;
-
- ASSERT (String != NULL);
-
- for (Length = 0; *String != L'\0'; String++, Length++) {
- //
- // If PcdMaximumUnicodeStringLength is not zero,
- // length should not more than PcdMaximumUnicodeStringLength
- //
- if (FixedPcdGet32 (PcdMaximumUnicodeStringLength) != 0) {
- ASSERT (Length < FixedPcdGet32 (PcdMaximumUnicodeStringLength));
- }
- }
- return Length;
-}
-
/**
Returns the size of a Null-terminated Unicode string in bytes, including the
Null terminator.
@@ -180,8 +196,6 @@ StrLen (
string specified by String.
If String is NULL, then ASSERT().
- If PcdMaximumUnicodeStringLength is not zero, and String contains more than
- PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
@param String Pointer to a Null-terminated Unicode string.
@@ -209,10 +223,6 @@ StrSize (
If FirstString is NULL, then ASSERT().
If SecondString is NULL, then ASSERT().
- If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
- than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
- If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
- than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
@param FirstString Pointer to a Null-terminated Unicode string.
@param SecondString Pointer to a Null-terminated Unicode string.
@@ -229,7 +239,7 @@ StrCmp (
)
{
//
- // ASSERT both strings are less long than PcdMaximumUnicodeStringLength
+ // ASSERT both strings should never be zero
//
ASSERT (StrSize (FirstString) != 0);
ASSERT (StrSize (SecondString) != 0);
@@ -254,10 +264,6 @@ StrCmp (
If FirstString is NULL, then ASSERT().
If SecondString is NULL, then ASSERT().
- If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
- than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
- If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
- than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
@param FirstString Pointer to a Null-terminated Unicode string.
@param SecondString Pointer to a Null-terminated Unicode string.
@@ -280,8 +286,7 @@ StrnCmp (
}
//
- // ASSERT both strings are less long than PcdMaximumUnicodeStringLength.
- // Length tests are performed inside StrLen().
+ // ASSERT both strings should never be zero
//
ASSERT (StrSize (FirstString) != 0);
ASSERT (StrSize (SecondString) != 0);
@@ -310,13 +315,6 @@ StrnCmp (
If Destination is NULL, then ASSERT().
If Source is NULL, then ASSERT().
If Source and Destination overlap, then ASSERT().
- If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
- than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
- If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
- PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
- If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
- and Source results in a Unicode string with more than
- PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
@param Destination Pointer to a Null-terminated Unicode string.
@param Source Pointer to a Null-terminated Unicode string.
@@ -335,7 +333,6 @@ StrCat (
//
// Size of the resulting string should never be zero.
- // PcdMaximumUnicodeStringLength is tested inside StrLen().
//
ASSERT (StrSize (Destination) != 0);
return Destination;
@@ -357,13 +354,6 @@ StrCat (
If Destination is NULL, then ASSERT().
If Source is NULL, then ASSERT().
If Source and Destination overlap, then ASSERT().
- If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
- than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
- If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
- PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
- If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
- and Source results in a Unicode string with more than
- PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
@param Destination Pointer to a Null-terminated Unicode string.
@param Source Pointer to a Null-terminated Unicode string.
@@ -385,7 +375,6 @@ StrnCat (
//
// Size of the resulting string should never be zero.
- // PcdMaximumUnicodeStringLength is tested inside StrLen().
//
ASSERT (StrSize (Destination) != 0);
return Destination;
@@ -402,8 +391,6 @@ StrnCat (
If Destination is NULL, then ASSERT().
If Source is NULL, then ASSERT().
If Source and Destination overlap, then ASSERT().
- If PcdMaximumAsciiStringLength is not zero and Source contains more than
- PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
@param Destination Pointer to a Null-terminated ASCII string.
@param Source Pointer to a Null-terminated ASCII string.
@@ -454,8 +441,6 @@ AsciiStrCpy (
If Destination is NULL, then ASSERT().
If Source is NULL, then ASSERT().
If Source and Destination overlap, then ASSERT().
- If PcdMaximumAsciiStringLength is not zero, and Source contains more than
- PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
@param Destination Pointer to a Null-terminated ASCII string.
@param Source Pointer to a Null-terminated ASCII string.
@@ -501,43 +486,6 @@ AsciiStrnCpy (
return ReturnValue;
}
-/**
- Returns the length of a Null-terminated ASCII string.
-
- This function returns the number of ASCII characters in the Null-terminated
- ASCII string specified by String.
-
- If String is NULL, then ASSERT().
- If PcdMaximumAsciiStringLength is not zero and String contains more than
- PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
-
- @param String Pointer to a Null-terminated ASCII string.
-
- @return The length of String.
-
-**/
-UINTN
-EFIAPI
-AsciiStrLen (
- IN CONST CHAR8 *String
- )
-{
- UINTN Length;
-
- ASSERT (String != NULL);
-
- for (Length = 0; *String != '\0'; String++, Length++) {
- //
- // If PcdMaximumUnicodeStringLength is not zero,
- // length should not more than PcdMaximumUnicodeStringLength
- //
- if (FixedPcdGet32 (PcdMaximumAsciiStringLength) != 0) {
- ASSERT (Length < FixedPcdGet32 (PcdMaximumAsciiStringLength));
- }
- }
- return Length;
-}
-
/**
Returns the size of a Null-terminated ASCII string in bytes, including the
Null terminator.
@@ -546,8 +494,6 @@ AsciiStrLen (
specified by String.
If String is NULL, then ASSERT().
- If PcdMaximumAsciiStringLength is not zero and String contains more than
- PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
@param String Pointer to a Null-terminated ASCII string.
@@ -575,10 +521,6 @@ AsciiStrSize (
If FirstString is NULL, then ASSERT().
If SecondString is NULL, then ASSERT().
- If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
- PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
- If PcdMaximumAsciiStringLength is not zero and SecondString contains more
- than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
@param FirstString Pointer to a Null-terminated ASCII string.
@param SecondString Pointer to a Null-terminated ASCII string.
@@ -595,7 +537,7 @@ AsciiStrCmp (
)
{
//
- // ASSERT both strings are less long than PcdMaximumAsciiStringLength
+ // ASSERT both strings should never be zero
//
ASSERT (AsciiStrSize (FirstString));
ASSERT (AsciiStrSize (SecondString));
@@ -631,10 +573,6 @@ AsciiToUpper (
If FirstString is NULL, then ASSERT().
If SecondString is NULL, then ASSERT().
- If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
- PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
- If PcdMaximumAsciiStringLength is not zero and SecondString contains more
- than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
@param FirstString Pointer to a Null-terminated ASCII string.
@param SecondString Pointer to a Null-terminated ASCII string.
@@ -653,7 +591,7 @@ AsciiStriCmp (
)
{
//
- // ASSERT both strings are less long than PcdMaximumAsciiStringLength
+ // ASSERT both strings should never be zero
//
ASSERT (AsciiStrSize (FirstString));
ASSERT (AsciiStrSize (SecondString));
@@ -680,10 +618,6 @@ AsciiStriCmp (
If FirstString is NULL, then ASSERT().
If SecondString is NULL, then ASSERT().
- If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
- PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
- If PcdMaximumAsciiStringLength is not zero and SecondString contains more
- than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
@param FirstString Pointer to a Null-terminated ASCII string.
@param SecondString Pointer to a Null-terminated ASCII string.
@@ -701,7 +635,7 @@ AsciiStrnCmp (
)
{
//
- // ASSERT both strings are less long than PcdMaximumAsciiStringLength
+ // ASSERT both strings should never be zero
//
ASSERT (AsciiStrSize (FirstString));
ASSERT (AsciiStrSize (SecondString));
@@ -727,13 +661,6 @@ AsciiStrnCmp (
If Destination is NULL, then ASSERT().
If Source is NULL, then ASSERT().
- If PcdMaximumAsciiStringLength is not zero and Destination contains more than
- PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
- If PcdMaximumAsciiStringLength is not zero and Source contains more than
- PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
- If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
- Source results in a ASCII string with more than PcdMaximumAsciiStringLength
- ASCII characters, then ASSERT().
@param Destination Pointer to a Null-terminated ASCII string.
@param Source Pointer to a Null-terminated ASCII string.
@@ -752,7 +679,6 @@ AsciiStrCat (
//
// Size of the resulting string should never be zero.
- // PcdMaximumUnicodeStringLength is tested inside StrLen().
//
ASSERT (AsciiStrSize (Destination) != 0);
return Destination;
@@ -774,13 +700,6 @@ AsciiStrCat (
If Destination is NULL, then ASSERT().
If Source is NULL, then ASSERT().
If Source and Destination overlap, then ASSERT().
- If PcdMaximumAsciiStringLength is not zero, and Destination contains more
- than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
- If PcdMaximumAsciiStringLength is not zero, and Source contains more than
- PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
- If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
- Source results in a ASCII string with more than PcdMaximumAsciiStringLength
- ASCII characters, then ASSERT().
@param Destination Pointer to a Null-terminated ASCII string.
@param Source Pointer to a Null-terminated ASCII string.
@@ -802,7 +721,6 @@ AsciiStrnCat (
//
// Size of the resulting string should never be zero.
- // PcdMaximumUnicodeStringLength is tested inside StrLen().
//
ASSERT (AsciiStrSize (Destination) != 0);
return Destination;